Hide Forgot
In Function `smb2_ioctl_query_info`, it incorrectly verify the return from the `memdup_user` function. `qi.output_buffer_length` is grab from copy_from_user which is user control value. If qi.output_buffer_length is equal to zero, the `memdup_user` function returns `0x10` which is not a valid ptr but can pass the check. Later this evil `buffer` is pass to function `SMB2_set_info_init` if qi.flags is equal to `PASSTHRU_SET_INFO`. In function `SMB2_set_info_init`, there is a straight memcpy which `*data` is previous evil buffer and `*size` is 8.
The candidate patch is: /* There is a patch also suggested by the researcher (Billy Jheng Bing Jhong of STAR Labs) */ diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index c5b1dea54ebc..3d656f7c907f 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1643,7 +1643,7 @@ smb2_ioctl_query_info(const unsigned int xid, if (copy_from_user(&qi, arg, sizeof(struct smb_query_info))) goto e_fault; - if (qi.output_buffer_length > 1024) { + if (qi.output_buffer_length > 1024 || qi.output_buffer_length == 0) { kfree(vars); return -EINVAL; }
Created kernel tracking bugs for this issue: Affects: fedora-all [bug 2067080]
https://git.kernel.org/linus/d6f5e358452479fa8a773b5c6ccc9e4ec5a20880 seem the related fix for this issue?
This was fixed for Fedora witht he 5.16.9 stable kernel update.
This issue has been addressed in the following products: Red Hat Enterprise Linux 8 Via RHSA-2022:7444 https://access.redhat.com/errata/RHSA-2022:7444
This issue has been addressed in the following products: Red Hat Enterprise Linux 8 Via RHSA-2022:7683 https://access.redhat.com/errata/RHSA-2022:7683
This issue has been addressed in the following products: Red Hat Enterprise Linux 9 Via RHSA-2022:7933 https://access.redhat.com/errata/RHSA-2022:7933
This issue has been addressed in the following products: Red Hat Enterprise Linux 9 Via RHSA-2022:8267 https://access.redhat.com/errata/RHSA-2022:8267
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s): https://access.redhat.com/security/cve/cve-2022-0168