Blob Blame History Raw
From: Takashi Iwai <tiwai@suse.de>
Subject: kABI workaround for snd_rawmidi buffer_ref field addition
Patch-mainline: Never, kABI workaround
References: CVE-2020-27786 bsc#1179601

The recent patch
  patches.suse/ALSA-rawmidi-Fix-racy-buffer-resize-under-concurrent.patch
introduced a new int field buffer_ref in snd_rawmidi_runtime and this
broke kABI.  Move it to the bitfields hole and pack it with the
__GENKSYMS__ trick.  It changes the size to 8 bit, but this should be
large enough.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 include/sound/rawmidi.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/include/sound/rawmidi.h
+++ b/include/sound/rawmidi.h
@@ -53,6 +53,9 @@ struct snd_rawmidi_runtime {
 	struct snd_rawmidi_substream *substream;
 	unsigned int drain: 1,	/* drain stage */
 		     oss: 1;	/* OSS compatible mode */
+#ifndef __GENKSYMS__
+	unsigned int buffer_ref:8;	/* buffer reference count */
+#endif
 	/* midi stream buffer */
 	unsigned char *buffer;	/* buffer for MIDI data */
 	size_t buffer_size;	/* size of buffer */
@@ -61,7 +64,6 @@ struct snd_rawmidi_runtime {
 	size_t avail_min;	/* min avail for wakeup */
 	size_t avail;		/* max used buffer for wakeup */
 	size_t xruns;		/* over/underruns counter */
-	int buffer_ref;		/* buffer reference count */
 	/* misc */
 	spinlock_t lock;
 	wait_queue_head_t sleep;