Skip to content

Commit 3014168

Browse files
KatherineLiu-holdongregkh
authored andcommitted
usb: gadget: configfs: Fix OOB read on empty string write
When writing an empty string to either 'qw_sign' or 'landingPage' sysfs attributes, the store functions attempt to access page[l - 1] before validating that the length 'l' is greater than zero. This patch fixes the vulnerability by adding a check at the beginning of os_desc_qw_sign_store() and webusb_landingPage_store() to handle the zero-length input case gracefully by returning immediately. Signed-off-by: Xinyu Liu <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 67a59f8 commit 3014168

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/usb/gadget/configfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,8 @@ static ssize_t webusb_landingPage_store(struct config_item *item, const char *pa
10651065
unsigned int bytes_to_strip = 0;
10661066
int l = len;
10671067

1068+
if (!len)
1069+
return len;
10681070
if (page[l - 1] == '\n') {
10691071
--l;
10701072
++bytes_to_strip;
@@ -1188,6 +1190,8 @@ static ssize_t os_desc_qw_sign_store(struct config_item *item, const char *page,
11881190
struct gadget_info *gi = os_desc_item_to_gadget_info(item);
11891191
int res, l;
11901192

1193+
if (!len)
1194+
return len;
11911195
l = min_t(int, len, OS_STRING_QW_SIGN_LEN >> 1);
11921196
if (page[l - 1] == '\n')
11931197
--l;

0 commit comments

Comments
 (0)