All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: 徐晗翔 <xuhx@hust.edu.cn>
Cc: "Takashi Iwai" <tiwai@suse.de>,
	vkoul@kernel.org, perex@perex.cz, tiwai@suse.com,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	lgirdwood@gmail.com, broonie@kernel.org
Subject: Re: [PATCH] Re: Re: sound: core: compress offload fd does not pin card or module, so  card removal leaves a live fd pointing at freed snd_compr (KASAN UAF)
Date: Wed, 25 Nov 2026 15:21:14 +0100	[thread overview]
Message-ID: <87ik1l6lgl.wl-tiwai@suse.de> (raw)
In-Reply-To: <4aedaffd.567.1a212bc3fce.Coremail.xuhx@hust.edu.cn>

On Wed, 25 Nov 2026 13:44:16 +0100,
徐晗翔 wrote:
> 
> snd_compr_open() dropped the lookup reference before returning and
> took neither a card reference nor a module reference, and kept no
> per-fd node: the card could be unbound and freed while a compress
> fd was still open, and the next ioctl/read/write/poll/close
> dereferenced freed struct snd_compr and snd_soc_pcm_runtime
> objects (KASAN slab-use-after-free in snd_compr_ioctl()).
> 
> Restore the open-file lifetime: snd_card_file_add() (which also
> puts the fd on card->files_list so snd_card_disconnect_sync() waits
> for it) plus try_module_get() at open; a data->list node linked into
> compr->open_list under compr->lock; list_del_init() + module_put() +
> snd_card_file_remove() at free; and a dev_disconnect callback that
> walks open_list, stops RUNNING/DRAINING/PAUSED streams, sets
> SNDRV_PCM_STATE_DISCONNECTED and wakes the poll/read waiters.

This should have been already addressed in the latest upstream.
Please verify again with the latest upstream code.


thanks,

Takashi


> ---
>  sound/core/compress_offload.c   | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/sound/compress_driver.h |  3 +++
>  2 files changed, 70 insertions(+)
> 
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -44,6 +44,10 @@
>  struct snd_compr_file {
>  	unsigned long caps;
>  	struct snd_compr_stream stream;
> +	/* open lifetime: linked into compr->open_list so the card
> +	 * disconnect callback can find and stop this stream, and so the
> +	 * fd pins the card and the module while it is open */
> +	struct list_head list;
>  };
>  
>  static void error_delayed_work(struct work_struct *work);
> @@ -137,7 +141,38 @@
>  	if (ret) {
>  		kfree(runtime);
>  		kfree(data);
> +		snd_card_unref(compr->card);
> +		return ret;
>  	}
> +
> +	/* Open lifetime: pin the card against removal (snd_card_file_add
> +	 * also links the file into card->files_list, so the card teardown
> +	 * waits for this fd) and pin the module, and make the fd visible
> +	 * to the disconnect callback via compr->open_list.  Without this
> +	 * the card could be unbound and freed while the fd stays open,
> +	 * leaving ioctl/read/write/poll/close to dereference freed
> +	 * snd_compr / snd_soc_pcm_runtime objects. */
> +	INIT_LIST_HEAD(&data->list);
> +	ret = snd_card_file_add(compr->card, f);
> +	if (ret)
> +		goto err_card_file;
> +	if (!try_module_get(compr->card->module)) {
> +		ret = -ENODEV;
> +		goto err_module;
> +	}
> +	scoped_guard(mutex, &compr->lock)
> +		list_add_tail(&data->list, &compr->open_list);
> +
> +	snd_card_unref(compr->card);
> +	return ret;
> +
> + err_module:
> +	snd_card_file_remove(compr->card, f);
> + err_card_file:
> +	scoped_guard(mutex, &compr->lock)
> +		data->stream.ops->free(&data->stream);
> +	kfree(runtime);
> +	kfree(data);
>  	snd_card_unref(compr->card);
>  	return ret;
>  }
> @@ -145,10 +180,16 @@
>  static int snd_compr_free(struct inode *inode, struct file *f)
>  {
>  	struct snd_compr_file *data = f->private_data;
> +	struct snd_compr *compr = data->stream.device;
>  	struct snd_compr_runtime *runtime = data->stream.runtime;
>  
>  	cancel_delayed_work_sync(&data->stream.error_work);
>  
> +	/* unlink from the open list first, so the disconnect callback
> +	 * cannot walk this stream while it is being freed */
> +	scoped_guard(mutex, &compr->lock)
> +		list_del_init(&data->list);
> +
>  	switch (runtime->state) {
>  	case SNDRV_PCM_STATE_RUNNING:
>  	case SNDRV_PCM_STATE_DRAINING:
> @@ -166,6 +207,11 @@
>  		kfree(data->stream.runtime->buffer);
>  	kfree(data->stream.runtime);
>  	kfree(data);
> +
> +	/* drop the references taken at open; the file object is released
> +	 * by the caller afterwards, so this is the last possible point */
> +	module_put(compr->card->module);
> +	snd_card_file_remove(compr->card, f);
>  	return 0;
>  }
>  
> @@ -1432,8 +1478,28 @@
>  static int snd_compress_dev_disconnect(struct snd_device *device)
>  {
>  	struct snd_compr *compr;
> +	struct snd_compr_file *compr_file;
> +	struct snd_compr_stream *stream;
>  
>  	compr = device->device_data;
> +
> +	/* stop the streams of still-open fds: the card core disconnect no
> +	 * longer waits only for the files_list (which our fds are on via
> +	 * snd_card_file_add()), but the streams must also be told that the
> +	 * device went away, or a blocked read/poll would never wake up */
> +	scoped_guard(mutex, &compr->lock) {
> +		list_for_each_entry(compr_file, &compr->open_list, list) {
> +			stream = &compr_file->stream;
> +			if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING &&
> +			    stream->runtime->state != SNDRV_PCM_STATE_DRAINING &&
> +			    stream->runtime->state != SNDRV_PCM_STATE_PAUSED)
> +				continue;
> +			compr->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
> +			stream->runtime->state = SNDRV_PCM_STATE_DISCONNECTED;
> +			wake_up(&stream->runtime->sleep);
> +		}
> +	}
> +
>  	snd_unregister_device(compr->dev);
>  	return 0;
>  }
> @@ -1541,6 +1607,7 @@
>  	compr->device = device;
>  	compr->direction = dirn;
>  	mutex_init(&compr->lock);
> +	INIT_LIST_HEAD(&compr->open_list);
>  
>  	snd_compress_set_id(compr, id);
>  
> diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
> --- a/include/sound/compress_driver.h
> +++ b/include/sound/compress_driver.h
> @@ -188,6 +188,8 @@
>   * @card: sound card pointer
>   * @direction: Playback or capture direction
>   * @lock: device lock
> + * @open_list: list of open fds, protected by @lock; the disconnect
> + *	callback walks it to stop the streams of files that are still open
>   * @device: device id
>   * @use_pause_in_draining: allow pause in draining, true when set
>   */
> @@ -199,6 +201,7 @@
>  	struct snd_card *card;
>  	unsigned int direction;
>  	struct mutex lock;
> +	struct list_head open_list;	/* list of open fds (snd_compr_file.list) */
>  	int device;
>  	bool use_pause_in_draining;
>  #ifdef CONFIG_SND_VERBOSE_PROCFS
> 
> 
> > -----原始邮件-----
> > 发件人: "Takashi Iwai" <tiwai@suse.de>
> > 发送时间:2026-11-22 16:07:00 (星期日)
> > 收件人: 徐晗翔 <xuhx@hust.edu.cn>
> > 抄送: vkoul@kernel.org, perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org
> > 主题: Re: sound: core: compress offload fd does not pin card or module, so  card removal leaves a live fd pointing at freed snd_compr (KASAN UAF)
> > 
> > On Sun, 22 Nov 2026 08:43:32 +0100,
> > 徐晗翔 wrote:
> > > 
> > > snd_compr_open() opens /dev/snd/comprC*D* without adding the file to
> > > card->files_list, without taking a persistent card device reference and
> > > without taking a module reference; it even drops the lookup reference
> > > with snd_card_unref() before returning.  The ASoC card can therefore be
> > > unbound and freed while the compress fd is still open, after which
> > > ioctl/read/write/poll/close dereference freed struct snd_compr and
> > > snd_soc_pcm_runtime objects.  I reproduced this on a Linux 7.3 KASAN
> > > kernel with a small test module: open the compress device, call
> > > snd_card_free(), then issue ioctl() on the stale fd; the ioctl entry
> > > already reports slab-use-after-free in mutex_lock(&stream->device->lock)
> > > inside snd_compr_ioctl().
> > > 
> > > This is not a theoretical lost-reference issue.  The upstream compress
> > > offload code has an explicit open-file lifetime: snd_card_file_add() plus
> > > try_module_get() at open, a data->list node linked into compr->open_list,
> > > list_del_init() + module_put() + snd_card_file_remove() at free, and a
> > > dev_disconnect callback that walks open_list, stops RUNNING/DRAINING/
> > > PAUSED streams, sets SNDRV_PCM_STATE_DISCONNECTED and wakes waiters.
> > > The current tree removed all of it at the structure level: struct
> > > snd_compr_file no longer has a list node and struct snd_compr no longer
> > > has open_list.  Consequently snd_card_disconnect_sync(), which waits for
> > > card->files_list to drain, returns immediately with the compress fd still
> > > open, and the subsequent snd_soc_remove_pcm_runtime() / snd_card_free()
> > > frees the objects the fd still points to.
> > > 
> > > The detailed description:
> > > 
> > > * Test environment / affected version
> > > 
> > >   Linux version 7.3.0 (gcc 13.3.0, GNU ld 2.42) #6 SMP PREEMPT_DYNAMIC,
> > >   vanilla 7.3 source tree with KASAN and QEMU/KVM x86_64 (4 vCPU, 4 GB).
> > >   The only build-time changes were temporary Kconfig prompts to build
> > >   snd-compress.ko and snd-rawmidi.ko as modules; no functional source
> > >   change was made for this case.  The exact version line is in
> > >   evidence/kernel-version.txt.
> > > 
> > > * Root cause and object lifetime
> > > 
> > >   The open path, sound/core/compress_offload.c:75-143, does only:
> > > 
> > >     compr = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_COMPRESS);
> > >     ...
> > >     data = kzalloc_obj(*data);
> > >     runtime = kzalloc_obj(*runtime);
> > >     data->stream.device = compr;
> > >     f->private_data = data;
> > >     scoped_guard(mutex, &compr->lock)
> > >         ret = compr->ops->open(&data->stream);
> > >     snd_card_unref(compr->card);
> > > 
> > >   There is no snd_card_file_add(compr->card, f), no
> > >   try_module_get(compr->card->module), and no list_add_tail() into an
> > >   open list.  The structure definitions were changed too:
> > >   sound/core/compress_offload.c:44-49 has
> > > 
> > >     struct snd_compr_file {
> > >         unsigned long caps;
> > >         struct snd_compr_stream stream;
> > >     };
> > > 
> > >   while include/sound/compress_driver.h:194-210 has no open_list member
> > >   in struct snd_compr.
> > > 
> > >   The free path, sound/core/compress_offload.c:145-170, calls
> > >   cancel_delayed_work_sync(), optionally trigger(STOP), task-free,
> > >   ops->free() and kfree() -- but no list_del_init(), no module_put() and
> > >   no snd_card_file_remove().
> > > 
> > >   The disconnect callback, sound/core/compress_offload.c:1432-1447, is
> > >   only:
> > > 
> > >     compr = device->device_data;
> > >     snd_unregister_device(compr->dev);
> > >     return 0;
> > > 
> > >   It does not walk open streams, does not stop them, does not set
> > >   SNDRV_PCM_STATE_DISCONNECTED and does not wake poll/read waiters.
> > > 
> > >   Upstream by contrast has all of these: snd_card_file_add() and
> > >   try_module_get() in snd_compr_open(), data->list linked into
> > >   compr->open_list, matching list_del_init()/module_put()/
> > >   snd_card_file_remove() in snd_compr_free(), and a dev_disconnect that
> > >   takes compr->lock, stops active streams and sets DISCONNECTED.
> > > 
> > > * Why card removal reaches the freed objects
> > > 
> > >   The ASoC cleanup order is in sound/soc/soc-core.c:1944-1981:
> > >   soc_cleanup_card_resources() calls snd_card_disconnect_sync() first,
> > >   then for_each_card_rtds_safe() -> snd_soc_remove_pcm_runtime(), then
> > >   snd_soc_card_remove(), then snd_card_free().  snd_card_disconnect_sync()
> > >   (sound/core/init.c:571-582) waits under files_lock for files_list to
> > >   become empty.  A compress fd is not in files_list, so this wait is a
> > >   no-op for it.  snd_soc_remove_pcm_runtime() then releases rtd via
> > >   device_unregister(rtd->dev), while the fd still has
> > >   data->stream.device = compr and data->stream.private_data = rtd.
> > >   snd_compr_ioctl(), snd_compr_read(), snd_compr_write() and
> > >   snd_compr_poll() all begin with
> > >   guard(mutex)(&stream->device->lock), i.e. they lock a mutex inside
> > >   freed struct snd_compr before looking at stream->runtime.
> > > 
> > > * Trigger model
> > > 
> > >   - A compress offload device must exist (real ASoC compress driver, or
> > >     the attached test module);
> > >   - a user with access to /dev/snd/comprC*D* opens it;
> > >   - the card is removed/unbound (driver unbind, card unregister, module
> > >     unload, or the test module's free parameter);
> > >   - the same fd is used again (ioctl/read/write/poll) or closed.
> > > 
> > >   The card-removal step normally needs a privileged action, but the fd
> > >   and the removal can belong to different processes and the kernel must
> > >   not free objects that an open file still references.  No hardware is
> > >   required for the reproducer.
> > > 
> > > * Reproducer (attached: sndcore_compress.c, sndcore_test.c) and results on 7.3
> > > 
> > >   sndcore_compress.c registers one card with one compress device and a
> > >   minimal struct snd_compr_ops; the card private_free function kfree()s
> > >   the struct snd_compr, matching ASoC's devm_kzalloc lifetime.  The
> > >   userspace program sndcore_test.c opens /dev/snd/comprC0D0, writes the
> > >   module's "free" parameter to call snd_card_free(), then calls ioctl()
> > >   on the stale fd.
> > > 
> > >   Observed (evidence/mr03-kasan-uaf.log):
> > > 
> > >     free: calling snd_card_free(...)
> > >     BUG: KASAN: slab-use-after-free in mutex_lock+0x72/0xe0
> > >     Write of size 8 at addr ... by task sndcore_test/88
> > >     Call Trace:
> > >      mutex_lock+0x72/0xe0
> > >      snd_compr_ioctl+0xd2/0xff0 [snd_compress]
> > >      ...
> > >     BUG: KASAN: slab-use-after-free in mutex_unlock+0x6c/0xd0
> > >      snd_compr_ioctl+0x1d3/0xff0 [snd_compress]
> > >     KASAN bug count: 2
> > > 
> > >   The bug count is the number of KASAN reports collected in that run;
> > >   the first report is the mutex_lock() inside the ioctl entry.
> > > 
> > > 
> > > 
> > > * Suggested direction 
> > > 
> > >   Restore the upstream lifetime in one series:
> > >   - snd_compr_open(): snd_card_file_add(), try_module_get(), link
> > >     data->list into compr->open_list;
> > >   - snd_compr_free(): list_del_init(), module_put() and
> > >     snd_card_file_remove(), with the error paths undoing in reverse;
> > >   - snd_compress_dev_disconnect(): walk compr->open_list under
> > >     compr->lock, STOP RUNNING/DRAINING/PAUSED streams, set
> > >     SNDRV_PCM_STATE_DISCONNECTED and wake waiters;
> > >   - restore struct snd_compr_file.list and struct snd_compr.open_list.
> > > 
> > > 
> > >   Please keep me in Cc; I am not subscribed to the lists.
> > > 
> > > Regards,
> > > Hanxiang Xu
> > > xuhx@hust.edu.cn
> > > // SPDX-License-Identifier: GPL-2.0
> > > #define _GNU_SOURCE
> > > #include <stdio.h>
> > > #include <stdlib.h>
> > > #include <string.h>
> > > #include <fcntl.h>
> > > #include <unistd.h>
> > > #include <errno.h>
> > > #include <pthread.h>
> > > #include <sys/ioctl.h>
> > > #include <sound/asound.h>
> > > 
> > > static int write_free(const char *mod)
> > > {
> > > 	char path[256];
> > > 	int fd;
> > > 
> > > 	snprintf(path, sizeof(path), "/sys/module/%s/parameters/free", mod);
> > > 	fd = open(path, O_WRONLY);
> > > 	if (fd < 0) {
> > > 		fprintf(stderr, "open %s: %s\n", path, strerror(errno));
> > > 		return -1;
> > > 	}
> > > 	if (write(fd, "1\n", 2) != 2)
> > > 		fprintf(stderr, "write %s: %s\n", path, strerror(errno));
> > > 	close(fd);
> > > 	return 0;
> > > }
> > > 
> > > static int do_hwdep(void)
> > > {
> > > 	struct snd_hwdep_dsp_image img;
> > > 	int fd;
> > > 
> > > 	fd = open("/dev/snd/hwC0D0", O_RDWR);
> > > 	if (fd < 0) {
> > > 		fprintf(stderr, "open hwdep: %s\n", strerror(errno));
> > > 		return 1;
> > > 	}
> > > 	memset(&img, 0, sizeof(img));
> > > 	img.index = 0;
> > > 	img.length = 0;
> > > 	img.image = 0;
> > > 	for (int i = 0; i < 4; i++) {
> > > 		if (ioctl(fd, SNDRV_HWDEP_IOCTL_DSP_LOAD, &img) < 0)
> > > 			fprintf(stderr, "ioctl dsp_load: %s\n", strerror(errno));
> > > 	}
> > > 	close(fd);
> > > 	printf("HWDEP: ioctl done (max_active should be >= 2)\n");
> > > 	sleep(1);
> > > 	return 0;
> > > }
> > > 
> > > static void *hwdep_thread(void *arg)
> > > {
> > > 	int fd = *(int *)arg;
> > > 	struct snd_hwdep_dsp_image img;
> > > 
> > > 	memset(&img, 0, sizeof(img));
> > > 	img.index = 0;
> > > 	ioctl(fd, SNDRV_HWDEP_IOCTL_DSP_LOAD, &img);
> > > 	return NULL;
> > > }
> > > 
> > > static int do_hwdep_race(void)
> > > {
> > > 	pthread_t th[4];
> > > 	int fd;
> > > 
> > > 	fd = open("/dev/snd/hwC0D0", O_RDWR);
> > > 	if (fd < 0) {
> > > 		fprintf(stderr, "open hwdep: %s\n", strerror(errno));
> > > 		return 1;
> > > 	}
> > > 	for (int i = 0; i < 4; i++)
> > > 		pthread_create(&th[i], NULL, hwdep_thread, &fd);
> > > 	for (int i = 0; i < 4; i++)
> > > 		pthread_join(th[i], NULL);
> > > 	close(fd);
> > > 	printf("HWDEP: 4 concurrent DSP_LOAD issued\n");
> > > 	sleep(1);
> > > 	return 0;
> > > }
> > > 
> > > static int do_compress(void)
> > > {
> > > 	int fd;
> > > 
> > > 	fd = open("/dev/snd/comprC0D0", O_WRONLY);
> > > 	if (fd < 0) {
> > > 		fprintf(stderr, "open compress: %s\n", strerror(errno));
> > > 		return 1;
> > > 	}
> > > 	printf("COMPRESS: fd open, freeing card\n");
> > > 	write_free("sndcore_compress");
> > > 	printf("COMPRESS: card free returned, issuing ioctl on stale fd\n");
> > > 	if (ioctl(fd, 0x4300, 0) < 0)
> > > 		fprintf(stderr, "ioctl stale fd: %s\n", strerror(errno));
> > > 	printf("COMPRESS: ioctl returned without KASAN report\n");
> > > 	close(fd);
> > > 	sleep(1);
> > > 	return 0;
> > > }
> > > 
> > > static int do_rawmidi(void)
> > > {
> > > 	int fd;
> > > 
> > > 	fd = open("/dev/snd/midiC0D0", O_RDONLY);
> > > 	if (fd < 0) {
> > > 		fprintf(stderr, "open rawmidi: %s\n", strerror(errno));
> > > 		return 1;
> > > 	}
> > > 	printf("RAWMIDI: fd open, letting flood thread run\n");
> > > 	sleep(2);
> > > 	printf("RAWMIDI: closing (trigger/cancel/free window)\n");
> > > 	close(fd);
> > > 	sleep(3);
> > > 	printf("RAWMIDI: close returned, freeing card\n");
> > > 	write_free("sndcore_rawmidi");
> > > 	sleep(1);
> > > 	return 0;
> > > }
> > > 
> > > int main(int argc, char **argv)
> > > {
> > > 	if (argc < 2) {
> > > 		fprintf(stderr, "usage: %s jackfree|compress|rawmidi|hwdep|hwdep-race\n", argv[0]);
> > > 		return 2;
> > > 	}
> > > 	if (!strcmp(argv[1], "jackfree"))
> > > 		return write_free("sndcore_jack");
> > > 	if (!strcmp(argv[1], "compress"))
> > > 		return do_compress();
> > > 	if (!strcmp(argv[1], "rawmidi"))
> > > 		return do_rawmidi();
> > > 	if (!strcmp(argv[1], "hwdep"))
> > > 		return do_hwdep();
> > > 	if (!strcmp(argv[1], "hwdep-race"))
> > > 		return do_hwdep_race();
> > > 	fprintf(stderr, "unknown mode %s\n", argv[1]);
> > > 	return 2;
> > > }
> > > 
> > > // SPDX-License-Identifier: GPL-2.0
> > > #include <linux/module.h>
> > > #include <linux/kernel.h>
> > > #include <linux/slab.h>
> > > #include <sound/core.h>
> > > #include <sound/compress_driver.h>
> > > #include "sndcore_parent.h"
> > > 
> > > static struct snd_card *card;
> > > static struct snd_compr *compr;
> > > 
> > > static int c_open(struct snd_compr_stream *stream) { return 0; }
> > > static int c_free(struct snd_compr_stream *stream) { return 0; }
> > > static int c_trigger(struct snd_compr_stream *stream, int cmd) { return 0; }
> > > 
> > > static struct snd_compr_ops compr_ops = {
> > > 	.open = c_open,
> > > 	.free = c_free,
> > > 	.trigger = c_trigger,
> > > };
> > > 
> > > static int free_set(const char *val, const struct kernel_param *kp)
> > > {
> > > 	if (card) {
> > > 		pr_info("free: calling snd_card_free(%p)\n", card);
> > > 		snd_card_free(card);
> > > 		card = NULL;
> > > 	}
> > > 	return 0;
> > > }
> > > static const struct kernel_param_ops free_ops = { .set = free_set };
> > > module_param_cb(free, &free_ops, NULL, 0200);
> > > 
> > > static void card_private_free(struct snd_card *c)
> > > {
> > > 	pr_info("card private_free: kfree(compr=%p)\n", compr);
> > > 	kfree(compr);
> > > 	compr = NULL;
> > > }
> > > 
> > > static int __init sndcore_compress_init(void)
> > > {
> > > 	int err;
> > > 
> > > 	err = sndcore_card_new(&card, "sndcore_compress");
> > > 	if (err < 0)
> > > 		return err;
> > > 
> > > 	compr = kzalloc(sizeof(*compr), GFP_KERNEL);
> > > 	if (!compr) {
> > > 		snd_card_free(card);
> > > 		card = NULL;
> > > 		sndcore_parent_put();
> > > 		return -ENOMEM;
> > > 	}
> > > 	compr->ops = &compr_ops;
> > > 	card->private_free = card_private_free;
> > > 
> > > 	err = snd_compress_new(card, 0, SND_COMPRESS_PLAYBACK, "sndcore", compr);
> > > 	if (err < 0) {
> > > 		kfree(compr);
> > > 		compr = NULL;
> > > 		snd_card_free(card);
> > > 		card = NULL;
> > > 		sndcore_parent_put();
> > > 		return err;
> > > 	}
> > > 	err = snd_card_register(card);
> > > 	if (err < 0) {
> > > 		snd_card_free(card);
> > > 		card = NULL;
> > > 		sndcore_parent_put();
> > > 		return err;
> > > 	}
> > > 	pr_info("compress card registered\n");
> > > 	return 0;
> > > }
> > > 
> > > static void __exit sndcore_compress_exit(void)
> > > {
> > > 	if (card) {
> > > 		snd_card_free(card);
> > > 		card = NULL;
> > > 	}
> > > 	sndcore_parent_put();
> > > }
> > > 
> > > module_init(sndcore_compress_init);
> > > module_exit(sndcore_compress_exit);
> > > MODULE_LICENSE("GPL");
> > > MODULE_DESCRIPTION("sound/core MR-03 compress open_list verifier");
> > 
> > Thanks for the report.
> > 
> > But, as I already requested in your previous reports, could you rather
> > submit a fix patch along with the report?  I suppose you're working
> > with AI, so it's just a matter of asking it to the model.
> > 
> > 
> > Takashi

  reply	other threads:[~2026-11-25 14:21 UTC|newest]

Thread overview: 167+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 12:35 usb: devio: usbdev_release() has no barrier against an in-flight async_completed() callback (use-after-free window on struct usb_dev_state)gregkh@linuxfoundation.org 徐晗翔
2026-10-27 14:12 ` Greg KH
2026-11-03 11:21   ` mm/slub: has_pcs_used() reads remote per-CPU sheaf state from flush_all_cpus_locked() without synchronization (data race; KCSAN blind spot: slub.o is uninstrumented) 徐晗翔
2026-11-04  9:41     ` Qing Wang
2026-11-04 10:07       ` Qing Wang
2026-11-03 11:30   ` futex/hrtimer: hrtimer_sleeper::task is read unsynchronized in 16 places on v7.3 -- the accessor series that fixes this is not in 7.3; please make sure it reaches the affected trees (backport nudge + stock-kernel KCSAN evidence) 徐晗翔
2026-11-03 11:48   ` cgroup: fork vs cgroup.procs write race in favordynmods mode -- v7.3 is affected; please make sure bf6fbf46b5ff reaches the stable trees (repro incl. uninstrumented natural hit) 徐晗翔
2026-11-03 14:51     ` Sasha Levin
2026-11-03 11:57   ` net: rtnetlink: rtnl_link_unregister() vs in-flight RTM_GETLINK dump readers -- v7.3 lacks the synchronize_rcu() fix (Fixes: 6b57ff21a310 family); A/B reproduction on stock 7.3 徐晗翔
2026-11-03 15:49     ` Eric Dumazet
2026-11-04 15:03     ` Sasha Levin
2026-11-03 12:07   ` wifi: wilc1000: SDIO/SPI remove destroys the srcu_struct before wiphy_unregister() -- late cfg80211 callbacks write through dangling srcu state (unfixed upstream; controlled + natural Oops) 徐晗翔
2026-11-03 12:10   ` gpio: gpiolib: final put of the gpio_device happens inside the SRCU read critical section on the setup-failure path -- deterministic use-after-free read at guard release (unfixed upstream) 徐晗翔
2026-11-05  8:52     ` Linus Walleij
2026-11-04 12:54   ` soc: qcom: pmic_glink_altmode: fix use-after-free on unbind (no cancel_work_sync for port work and enable_work) 徐晗翔
2026-11-04 13:04     ` Greg KH
2026-11-04 12:57   ` usb: typec: anx7411: unregister partner/altmodes before stopping the IRQ work -- use-after-free, double unregister, orphan partner on remove 徐晗翔
2026-11-04 13:28     ` Greg KH
2026-11-04 12:58   ` usb: typec: ucsi: deadlock on cros_ec unbind -- connector lock held across cancel_delayed_work_sync vs the mode-selection work's unbounded trylock polling 徐晗翔
2026-11-04 13:00   ` usb: typec: stusb160x/rt1719/hd3ss3220: IRQ thread vs remove -- double unregister / use-after-free on the partner and port 徐晗翔
2026-11-04 13:01   ` usb: typec: ucsi: displayport: data race on dp->header/ vdo_data/vdo_size -- work reads them unlocked while writers hold con->lock (VDM mismatch) 徐晗翔
2026-11-04 13:02   ` usb: typec: class: three lifetime/locking gaps around the mux/switch handles and mode_selection (drvdata UAF after provider unbind; no concurrent protocol for set/put; unlocked state_update vs delete) 徐晗翔
2026-11-10 12:56   ` driver core: uevent: netns teardown frees uevent_sock while a tagged uevent is still being broadcast (UAF) 徐晗翔
2026-11-10 13:00   ` 徐晗翔
2026-11-10 18:48     ` Greg KH
2026-11-10 13:05   ` ACPI: CPPC: per-CPU cpc_desc is freed on processor unbind without clearing the published pointer, causing UAF in cpufreq accessors 徐晗翔
2026-11-10 13:07   ` ACPI: CPPC: shared PCC subspace data can be freed while another CPU probes, reads, or tears it down 徐晗翔
2026-11-10 14:47     ` Christian Loehle
2026-11-10 13:11   ` ACPI: ACPICA: Reset can delete an event semaphore while another thread is blocked in Wait 徐晗翔
2026-11-10 13:14   ` power: supply: bq25890: pump-express work can call power_supply_changed after the psy is unregistered 徐晗翔
2026-11-10 13:17   ` power: supply: core: get/set property callbacks can run after unregister and read freed driver data 徐晗翔
2026-11-10 13:18   ` power: supply: core: system-battery enumeration can return an unregistered battery 徐晗翔
2026-11-10 13:21   ` power: supply: core: changed work can run after unregister and use freed LED triggers 徐晗翔
2026-11-10 13:23   ` power: supply: bq24190: IRQ handler can call power_supply_changed after the psy is unregistered 徐晗翔
2026-11-10 13:34   ` 徐晗翔
2026-11-11  7:17   ` genirq: NMI dispatch reads struct irqaction with no quiescence -- use-after-free across free_nmi()'s kfree (x86 verification on the arch-independent core path) 徐晗翔
2026-11-11  7:26   ` genirq: NMI API lacks the request_mutex / dev_id matching / idempotency semantics that free_irq() has -- double free_nmi releases chip PM and module references twice (verified) 徐晗翔
2026-11-11  7:30   ` kernfs: kernfs_drain()'s fast-path decision reads the active count without acquire ordering -- on weakly-ordered architectures the forced ->release()/unmap can be skipped 徐晗翔
2026-11-11 13:41     ` Greg KH
2026-11-13 11:58   ` ALSA: ctxfi: free atimer only after the timer IRQ is quiesced 徐晗翔
2026-11-13 16:30     ` Takashi Iwai
2026-11-25 12:51       ` [PATCH] Re: " 徐晗翔
2026-11-25 13:00         ` sashiko-bot
2026-11-25 14:33         ` Takashi Iwai
2026-11-13 12:03   ` ALSA: ctxfi: do not free a running system timer when timer_delete_sync_try() returns -1 (UAF) 徐晗翔
2026-11-25 12:51     ` [PATCH] " 徐晗翔
2026-11-25 13:05       ` sashiko-bot
2026-11-25 14:35       ` Takashi Iwai
2026-11-26  2:13         ` 徐晗翔
2026-11-26  2:27           ` sashiko-bot
2026-11-26  7:54           ` Takashi Iwai
2026-11-13 12:04   ` ALSA: asihpi: free IRQ before snd_card_free()/HPI delete on HPI6205 removal (UAF) 徐晗翔
2026-11-25 12:50     ` [PATCH] " 徐晗翔
2026-11-25 13:03       ` sashiko-bot
2026-11-25 14:43       ` Takashi Iwai
2026-11-13 12:06   ` ALSA: asihpi: quiesce PCM timer and IRQ before freeing dpcm on close (UAF) 徐晗翔
2026-11-25 12:50     ` [PATCH] " 徐晗翔
2026-11-25 13:06       ` sashiko-bot
2026-11-25 14:46       ` Takashi Iwai
2026-11-13 12:15   ` ALSA: pcm: link-group walk in timer callback can use a closed substream's freed runtime (UAF) 徐晗翔
2026-11-25 12:55     ` [PATCH] " 徐晗翔
2026-11-25 13:12       ` sashiko-bot
2026-11-25 13:27       ` Takashi Iwai
2026-11-13 12:28   ` ALSA: usb-audio: us144mkii: PCM close frees runtime while playback/feedback URB completion and capture work still use it (UAF) 徐晗翔
2026-11-25 12:48     ` [PATCH] " 徐晗翔
2026-11-25 13:13       ` sashiko-bot
2026-11-25 16:25       ` Takashi Iwai
2026-11-13 12:29   ` ALSA: usb-audio: us144mkii: queued stop_pcm_work calls snd_pcm_stop() after PCM close and dereferences NULL runtime 徐晗翔
2026-11-25 12:49     ` [PATCH] " 徐晗翔
2026-11-25 13:03       ` sashiko-bot
2026-11-13 12:33   ` sched/topology: old domain chains are queued for RCU freeing before the per-CPU pointers are updated, so a late reader can still dereference a freed sched_domain and sched_domain_shared (UAF) 徐晗翔
2026-11-13 12:47   ` xfs: use-after-free in stats_clear sysctl handler during module unload 徐晗翔
2026-11-13 12:48   ` xfs: data races on xfs_params and xfs_globals tunables 徐晗翔
2026-11-13 23:34     ` Eric Sandeen
2026-11-17 12:32   ` jbd2: fix unsynchronized read of j_average_commit_time in procfs stats (KCSAN data race) 徐晗翔
2026-11-17 12:33   ` jbd2: read j_stats.ts_tid under j_history_lock in fast commit path " 徐晗翔
2026-11-17 12:35   ` jbd2: fix unlocked read/write of j_last_sync_writer in jbd2_journal_stop " 徐晗翔
2026-11-17 12:38   ` btrfs: compression: data race on compr_pool.count between shrinker scan and folio alloc/free " 徐晗翔
2026-11-17 12:47   ` fs/ceph: debugfs mdsmap_show() can dereference a freed MDS map after a concurrent map update (UAF) 徐晗翔
2026-11-17 12:48   ` fs/ceph: ceph_statfs() can dereference a freed MDS map (double evaluation of mdsc->mdsmap) (UAF) 徐晗翔
2026-11-17 12:49   ` fs/ceph: ceph_get_tree() out_splat path walks mdsc->mdsmap without mdsc->mutex (UAF) 徐晗翔
2026-11-17 12:50   ` fs/ceph: __ceph_setxattr() reads mdsmap->m_max_xattr_size " 徐晗翔
2026-11-17 12:51   ` fs/ceph: MDS reconnect paths read mdsc->mdsmap " 徐晗翔
2026-11-17 12:52   ` fs/ceph: caps renew paths read mdsmap->m_session_timeout " 徐晗翔
2026-11-24 14:53     ` Krzysztof Kozlowski
2026-11-17 12:53   ` fs/ceph: MDS connections can deliver CEPH_MSG_MDS_MAP and re-enter ceph_mdsc_handle_mdsmap() (UAF) 徐晗翔
2026-11-22  7:37   ` mm/hugetlb: a min_size-only hugetlbfs subpool is kfree()d before its last pinned page is released, so free_huge_folio() takes a spinlock on freed memory (UAF) 徐晗翔
2026-11-22 15:58     ` David Hildenbrand (Arm)
2026-11-25 12:05     ` David Hildenbrand (Arm)
2026-11-26  5:52       ` Ackerley Tng
2026-11-26  6:39         ` David Hildenbrand (Arm)
2026-11-22  7:39   ` io_uring/zcrx: copy statistics lose updates when one ifq is shared by multiple rings (Data race) 徐晗翔
2026-11-23 13:50     ` Pavel Begunkov
2026-11-24 17:17       ` Clément Léger
2026-11-22  7:43   ` sound: core: compress offload fd does not pin card or module, so card removal leaves a live fd pointing at freed snd_compr (KASAN UAF) 徐晗翔
2026-11-22  8:07     ` Takashi Iwai
2026-11-25 12:44       ` [PATCH] Re: " 徐晗翔
2026-11-25 14:21         ` Takashi Iwai [this message]
2026-11-22  7:48   ` sound: core: jack kcontrol is published before jack_kctl allocation, and the failure path frees it without removing it from card->controls (null-ptr-deref) 徐晗翔
2026-11-24  9:39     ` Sreeraj S Kurup
2026-11-25 12:43       ` 徐晗翔
2026-11-22  7:50   ` sound: core: rawmidi input close can re-queue event_work after cancel_work_sync() (UAF) 徐晗翔
2026-11-24 14:52     ` Krzysztof Kozlowski
2026-11-25 12:45       ` [PATCH] Re: " 徐晗翔
2026-11-25 14:37         ` Takashi Iwai
2026-11-22  7:52   ` sound: core: hwdep DSP_LOAD check-then-act is unlocked, allowing concurrent DSP_LOAD callbacks (UAF) 徐晗翔
2026-11-25 12:46     ` [PATCH] " 徐晗翔
2026-11-25 14:14       ` Takashi Iwai
2026-11-22  7:55   ` sound: core: get_available_index() calls snd_ctl_find_id() without controls_rwsem (UAF risk) 徐晗翔
2026-11-25 12:46     ` [PATCH] " 徐晗翔
2026-11-25 12:51       ` sashiko-bot
2026-11-25 14:18       ` Takashi Iwai
2026-11-22  7:56   ` sound: core: OSS mixer notify callback is invoked without module pin or mutex, racing with rmmod 徐晗翔
2026-11-25 12:47     ` [PATCH] " 徐晗翔
2026-11-25 14:16       ` Takashi Iwai
2026-11-22  7:57   ` sound: timer: snd_utimer_fops lacks .owner, so an open user timer fd does not pin snd-timer 徐晗翔
2026-11-25 12:48     ` [PATCH] " 徐晗翔
2026-11-25 14:17       ` Takashi Iwai
2026-11-26 12:49   ` SUNRPC: rpc_new_client() kfree()s a fully published client on the auth-creation failure path -- use-after-free via concurrent rpc_pipefs mount notifications and via open debugfs/pipefs files (UAF) 徐晗翔
2026-11-26 12:52   ` SUNRPC: cache_read() serialises readers with a per-open inode lock, but every open() gets a fresh inode: concurrent formatting of the shared upcall buffer and unsynchronised rq->len (Data Race KCSAN-confirmed) 徐晗翔
2026-11-26 12:55   ` SUNRPC: rpc_switch_client_transport() removes the client pipedir without pipefs_sb_lock, racing the RPC_PIPEFS_UMOUNT notification chain into a double removal (UAF) 徐晗翔
2026-12-01  3:22   ` [PATCH 0/2] ALSA: emux: fix use-after-free of soundfont zones/samples between snd_emux_note_on() and soundfont removal paths (UAF) 徐晗翔
2026-12-01  6:37     ` Takashi Iwai
2026-12-01 11:56     ` 徐晗翔
2026-12-01 12:15       ` Takashi Iwai
2026-12-01  3:23   ` [PATCH] ALSA: emux: drain open hwdep users before freeing the emux structures(UAF) 徐晗翔
2026-12-01 11:57     ` 徐晗翔
2026-12-01 12:58       ` Takashi Iwai
2026-12-01  3:25   ` [PATCH] ALSA: emux: expose the hwdep device only after ports are initialized (probe-window NULL deref via MISC_MODE ioctl) 徐晗翔
2026-12-01 11:56     ` 徐晗翔
2026-12-01  3:27   ` [PATCH] ALSA: core: protect card->devices against concurrent disconnect/free -- snd_device UAF with split sub-driver removal (UAF) 徐晗翔
2026-12-01 11:56     ` 徐晗翔
2026-12-01  4:28   ` ALSA: jack: snd_jack_kctl_new() frees a published snd_kcontrol when the jack private-part allocation fails (UAF/double-free) 徐晗翔
2026-12-01 12:00     ` 徐晗翔
2026-12-01  4:31   ` ALSA: hwdep: struct snd_hwdep is kfree()d while open files, an in-flight ioctl and delayed close() still use it (UAF) 徐晗翔
2026-12-01  4:42     ` sashiko-bot
2026-12-01 12:00     ` 徐晗翔
2026-12-01  4:32   ` ALSA: rawmidi: struct snd_rawmidi and its substreams are kfree()d while open files, delayed close() and a queued highpri work item still use them (UAF) 徐晗翔
2026-12-01 12:01     ` 徐晗翔
2026-12-01  4:33   ` ALSA: pcm: struct snd_pcm and its substreams are kfree()d while open fds and in-flight ioctls " 徐晗翔
2026-12-01 12:01     ` 徐晗翔
2026-12-01  4:36   ` ALSA: emu8000: the self-rearming emu8k_pcm timer survives trigger-stop and fires on freed memory after close (UAF) 徐晗翔
2026-12-01 12:01     ` 徐晗翔
2026-12-01  4:39   ` ALSA: control: find_id()/find_numid() kerneldoc claims they take controls_rwlock internally; the FAST_LOOKUP implementation is a lockless, unreferenced xa_load and several in-tree callers use it unlocked (UAF) 徐晗翔
2026-12-01 12:01     ` 徐晗翔
2026-12-01  4:42   ` ALSA: aoa/i2sbus: unlocked codec_list / dev->pcm check-and-free in i2sbus_detach_codec() can double-free the pcm under concurrent codec detaches (Double free) 徐晗翔
2026-12-01 12:02     ` 徐晗翔
2026-12-01 12:12   ` ASoC: intel: atom: SST: synchronize the DSP threaded IRQ against the PCM close path (UAF) 徐晗翔
2026-12-01 12:15   ` 徐晗翔
2026-12-01 12:19   ` ASoC: intel: atom: SST: clear the compress drain callbacks on close and gate them on the stream status (UAF) 徐晗翔
2026-12-01 12:22   ` ASoC: intel: atom: SST: log the byte-stream message header before handing it to the dispatch queue (UAF) 徐晗翔
2026-12-01 12:25   ` ALSA: emu8000: pin the module while an emu8k PCM runtime exists (UAF) 徐晗翔
2026-12-01 13:13     ` Takashi Iwai
2026-12-01 12:28   ` ALSA: emu8000: sync the PCM emulation timer before freeing snd_emu8k_pcm and gate the callback re-arm on timer_running (UAF) 徐晗翔
2026-12-01 12:37   ` ALSA: opl3: patch_table lookup/clear/load run lock-free against the voice_lock readers (UAF) 徐晗翔
2026-12-01 12:39   ` ALSA: core: card->devices list is managed lock-free -- struct snd_device UAF and LIST_POISON2 crash between card disconnect and independent sub-driver removal (UAF) 徐晗翔
2026-12-01 12:43   ` ALSA: hwdep: single-device teardown kfrees snd_hwdep while user space still holds the node open (UAF) 徐晗翔
2026-12-01 12:45   ` ALSA: rawmidi: snd_rawmidi_free() tears down substreams and the private data while fds are still open and the virmidi output work is queued (UAF) 徐晗翔
2026-12-01 12:47   ` ALSA: pcm: snd_emu8000_remove() frees a pcm with open fds and an armed period timer (UAF) 徐晗翔
2026-12-01 12:48   ` ALSA: vx: vx_free_pipe() kfrees pipes with no lock common to the threaded IRQ pipe walker (UAF) 徐晗翔
2026-12-01 12:51   ` ALSA: sb: emu8k frees the pcm private data without syncing the self-rearming period timer (UAF) 徐晗翔
2026-12-01 13:12   ` ALSA: core: serialize card disconnect/free and quiesce codecs before device release (UAF) 徐晗翔
2026-12-01 13:14   ` ALSA: core: pin and serialize snd_card_register() against disconnect/free (UAF) 徐晗翔
2026-12-01 13:16   ` ALSA: hda/intel: serialize IRQ (de)registration against card teardown (UAF) 徐晗翔
2026-12-01 13:29     ` sashiko-bot
2026-12-01 13:18   ` ALSA: hda/hdmi: hold pcm_lock for the unlocked hdmi_present_sense() callers (Data race) 徐晗翔
2026-12-01 13:30     ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ik1l6lgl.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    --cc=xuhx@hust.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.