2024-01-05 13:47:49

by Salvatore Bonaccorso

[permalink] [raw]
Subject: Information on use-after-free in smb2_is_status_io_timeout()?

Hi,

There is a Red Hat bugzilla report in
https://bugzilla.redhat.com/show_bug.cgi?id=2154178 about a
use-after-free in smb2_is_status_io_timeout() . While the commit noted
initially there seems not correct, Ben Hutchings raised a question on
more information in
https://bugzilla.redhat.com/show_bug.cgi?id=2154178#c24 .

(there is a CVE assigned for it, CVE-2023-1192)

To quote the initial message in RHBZ#2154178:

> A use after free flaw was found in smb2_is_status_io_timeout() in CIFS
> in the Linux Kernel. After CIFS transfers response data to system
> call, there is still a local variable points to the memory region, and
> if system call frees it faster than CIFS uses it, CIFS will access a
> free memory region leading to a denial of service.

Ben asked:

> smb2_is_status_io_timeout() is only ever called from cifs_demultiplex_thread().
> That happens after it conditionally decrypts the original receive buffer (buf) into
> one or more new buffers (bufs[...]), or otherwise sets bufs[0] = buf. The
> decryption process looks like it can free the original buffer, resulting in the
> reported UAF.
>
> If the error code is part of the encrypted payload, then I think the check for an
> I/O timeout should use bufs[0] like other code further down the function:
>
> --- a/fs/smb/client/connect.c
> +++ b/fs/smb/client/connect.c
> @@ -1236,7 +1236,7 @@ cifs_demultiplex_thread(void *p)
> }
>
> if (server->ops->is_status_io_timeout &&
> - server->ops->is_status_io_timeout(buf)) {
> + server->ops->is_status_io_timeout(bufs[0])) {
> num_io_timeout++;
> if (num_io_timeout > MAX_STATUS_IO_TIMEOUT) {
> cifs_server_dbg(VFS,
> --- END ---
>
> If the error code does not get encrypted, then the timeout check needs to be done
> further up the function.
>
> Does anyone have a reproducer for this?

Does anyone knows more on this issue?

Regards,
Salvatore


2024-01-05 14:05:14

by Paulo Alcantara

[permalink] [raw]
Subject: Re: Information on use-after-free in smb2_is_status_io_timeout()?

Salvatore Bonaccorso <[email protected]> writes:

> There is a Red Hat bugzilla report in
> https://bugzilla.redhat.com/show_bug.cgi?id=2154178 about a
> use-after-free in smb2_is_status_io_timeout() . While the commit noted
> initially there seems not correct, Ben Hutchings raised a question on
> more information in
> https://bugzilla.redhat.com/show_bug.cgi?id=2154178#c24 .
>
> (there is a CVE assigned for it, CVE-2023-1192)

That is supposed to be fixed by

d527f51331ca ("cifs: Fix UAF in cifs_demultiplex_thread()")

While the commit refers to an UAF in ->is_network_name_deleted(), this
should also work for smb2_is_status_io_timeout(), AFAICT.

2024-01-05 18:15:30

by Ben Hutchings

[permalink] [raw]
Subject: Re: Information on use-after-free in smb2_is_status_io_timeout()?

On Fri, 2024-01-05 at 11:04 -0300, Paulo Alcantara wrote:
> Salvatore Bonaccorso <[email protected]> writes:
>
> > There is a Red Hat bugzilla report in
> > https://bugzilla.redhat.com/show_bug.cgi?id=2154178 about a
> > use-after-free in smb2_is_status_io_timeout() . While the commit noted
> > initially there seems not correct, Ben Hutchings raised a question on
> > more information in
> > https://bugzilla.redhat.com/show_bug.cgi?id=2154178#c24 .
> >
> > (there is a CVE assigned for it, CVE-2023-1192)
>
> That is supposed to be fixed by
>
> d527f51331ca ("cifs: Fix UAF in cifs_demultiplex_thread()")
>
> While the commit refers to an UAF in ->is_network_name_deleted(), this
> should also work for smb2_is_status_io_timeout(), AFAICT.

I think that's a different UAF bug that happens to affect the same
function.

Ben.

--
Ben Hutchings - Debian developer, member of kernel, installer and LTS
teams


Attachments:
signature.asc (849.00 B)
This is a digitally signed message part