Skip to content

RFC ALSA: Fix UAF with delayed kobj release

Takashi Iwai alsa-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 16 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6ALSA: core: Introduced referenced memory allocatorinclude/sound/core.h sound/core/init.c+63 -00 replies
2/6ALSA: core: Fix race between devres and delayed kobject release for card_devsound/core/init.c+22 -161 reply
2/6ALSA: core: Fix potential UAF by delayed kobject release of card_devsound/core/init.c+22 -160 replies
3/6ALSA: core: Associate memory reference with device initializationinclude/sound/core.h sound/core/compress_offload.c sound/core/control.c +6 more+14 -110 replies
4/6ALSA: pcm: Release memory with referencesound/core/pcm.c+3 -30 replies
5/6ALSA: control: Reference card by ctl_devsound/core/control.c+1 -10 replies
6/6ALSA: compress: Reference card by the devicesound/core/compress_offload.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC 0/6] ALSA: Fix UAF with delayed kobj release

Hi,

this is a test patch set for addressing the UAF problems with delayed kobj releases reported by Curtis:
https://lore.kernel.org/r/[email protected]

The patch introduced a simple helper for allocating memory with a refcount, and converts the card object, control, PCM and compress objects with the new type. With the refcount, the actual memory release is delayed until all referrer are gone.

It's just a RFC and only lightly tested. I myself am not sure whether this is the best way to go. It might be better to take Curtis' approach, just converting the device to its own allocation, too. (But I don't know whether Curtis' patch set covers all cases -- can still be a UAF of card_dev due to devres vs kobj release?)

thanks,

Takashi

===

Takashi Iwai (6):
ALSA: core: Introduced referenced memory allocator
ALSA: core: Fix potential UAF by delayed kobject release of card_dev
ALSA: core: Associate memory reference with device initialization
ALSA: pcm: Release memory with reference
ALSA: control: Reference card by ctl_dev
ALSA: compress: Reference card by the device

 include/sound/core.h           |   7 ++-
 sound/core/compress_offload.c  |   2 +-
 sound/core/control.c           |   2 +-
 sound/core/hwdep.c             |   2 +-
 sound/core/init.c              | 105 +++++++++++++++++++++++++++------
 sound/core/pcm.c               |   6 +-
 sound/core/rawmidi.c           |   2 +-
 sound/core/seq/seq_clientmgr.c |   2 +-
 sound/core/timer.c             |   2 +-
 9 files changed, 101 insertions(+), 29 deletions(-)
Signature · 1 line
2.35.3