Linux USB
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Haofeng Li <lihaofeng@kylinos.cn>
Cc: christophe.jaillet@wanadoo.fr, hataegu0826@gmail.com,
	kees@kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, 13266079573@163.com
Subject: Re: [PATCH] usb: gadget: f_uac1_legacy: fix heap overflow in f_audio_out_ep_complete()
Date: Fri, 20 Nov 2026 12:14:31 +0100	[thread overview]
Message-ID: <2026112008-wildcat-pentagram-2ad6@gregkh> (raw)
In-Reply-To: <20260822194548.4151087-1-lihaofeng@kylinos.cn>

On Sun, Aug 23, 2026 at 03:45:48AM +0800, Haofeng Li wrote:
> f_audio_out_ep_complete() queues the accumulation buffer for playback
> and allocates a fresh, audio_buf_size-byte one whenever an incoming
> request does not fit into the space left in the current buffer.  It then
> unconditionally copies req->actual bytes into copy_buf->buf.
> 
> audio_buf_size and req_buf_size are independent configfs attributes of
> the function and nothing makes the former cover the latter: a request
> buffer is req_buf_size bytes, req->actual is the size of the packet the
> USB host chose to send, and as soon as one packet exceeds audio_buf_size
> the memcpy() writes past the end of a kzalloc(audio_buf_size) object.
> 
> Attack chain (write access to the gadget's configfs attributes before
> the function is bound, plus control of the USB host side; no race
> needed):
> 
>     echo 1   > .../functions/uac1_legacy.0/audio_buf_size
>     echo 200 > .../functions/uac1_legacy.0/req_buf_size
>     bind the gadget, host sets the AS interface to altsetting 1
>       -> f_audio_set_alt(): 1-byte accumulation buffer allocated,
>          200-byte request buffers queued with req->length = 200
>     host sends a single 200-byte OUT audio packet
>       -> f_audio_complete() -> f_audio_out_ep_complete()
>       -> audio_buf_size - actual = 1 - 0 < 200: the empty buffer is
>          queued for playback and a new 1-byte buffer is allocated
>       -> memcpy(copy_buf->buf + 0, req->buf, 200)
>       -> 199-byte out-of-bounds heap write
> 
> The write is silent: FORTIFY cannot derive the size of the destination
> through the runtime offset buf + actual, and because the neighbouring
> slab objects stay addressable, generic KASAN reports nothing either.
> Reproduced on 7.2.0+ with KASAN and slub_debug=Z, where the injected
> 200-byte pattern lands entirely outside the 1-byte kmalloc-8 object and
> reaches the SLUB redzone; the resulting freelist corruption was observed
> to hang the machine (GPF in get_from_partial_node() during later device
> enumeration).

What does this paragraph mean?  Please rewrite this whole changelog in
your own words.

thanks,

greg k-h

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-22 19:45 [PATCH] usb: gadget: f_uac1_legacy: fix heap overflow in f_audio_out_ep_complete() Haofeng Li
2026-11-20 11:14 ` Greg KH [this message]

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=2026112008-wildcat-pentagram-2ad6@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=13266079573@163.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=hataegu0826@gmail.com \
    --cc=kees@kernel.org \
    --cc=lihaofeng@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox