public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm_oss: Fix use-after-free in poll via io_uring
@ 2026-04-30  2:14 songxiebing
  2026-04-30  6:07 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: songxiebing @ 2026-04-30  2:14 UTC (permalink / raw)
  To: tiwai, perex
  Cc: linux-sound, linux-kernel, songxiebing,
	syzbot+ee73befabe68e7907adf

From: Bob Song <songxiebing@kylinos.cn>

Fix use-after-free bug in snd_pcm_oss_poll() caused by
io_uring asynchronous poll operations accessing already-freed
pcm_oss_file private data.

The bug happens because file->private_data still points to
kfree()'d memory after snd_pcm_oss_release(), and io_uring
may invoke ->poll() handler later.

Fix by:
1. Clearing file->private_data early in release function
2. Adding NULL check in release to avoid invalid access
3. Adding NULL check in poll handler to prevent UAF

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") /* pcm_oss initial */
Reported-by: syzbot+ee73befabe68e7907adf@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/alsa-devel/000000000000f1068105f20e5e8f@google.com/
Signed-off-by: Bob Song <songxiebing@kylinos.cn>
---
 sound/core/oss/pcm_oss.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index a140a0d9abb8..f3cebfaaa7dc 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2574,6 +2574,14 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
 	struct snd_pcm_oss_file *pcm_oss_file;
 
 	pcm_oss_file = file->private_data;
+
+	/* Prevent double-release and NULL dereference */
+	if (!pcm_oss_file)
+		return 0;
+
+	/* Clear private data to avoid UAF from async poll */
+	file->private_data = NULL;
+
 	substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
 	if (substream == NULL)
 		substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
@@ -2840,6 +2848,10 @@ static __poll_t snd_pcm_oss_poll(struct file *file, poll_table * wait)
 	
 	pcm_oss_file = file->private_data;
 
+	/* Check for already released file to avoid UAF */
+	if (!pcm_oss_file)
+		return EPOLLERR | EPOLLHUP;
+
 	psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
 	csubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-30  6:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30  2:14 [PATCH] ALSA: pcm_oss: Fix use-after-free in poll via io_uring songxiebing
2026-04-30  6:07 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox