From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03C314D98FB for ; Tue, 8 Sep 2026 12:24:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788870247; cv=none; b=UifPP9MqDBFxmjbw4QvymuVtI0MhihCEaQ/oE2DcFRdcbn841kzQWEVMmZag0WUTXeGhcZlDZNohZEDAL85LlmbhyHhoOqxBgrMOlrnCRFdQZgrQUyWsa/lsOUZAfYGYBYCkjVhER0ciJZ2s9dtdjHrB3txFcShOHD+PoUdOEGQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788870247; c=relaxed/simple; bh=vf95O901ZOCYO6NdGBcwbcNIOvnEOzJ+TcoAU9xBTSg=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=lovdtZOZWbNpN+QLPIIWbDSvz6GNSypXksHWPuXWOLG4Byx1LyRVjoThRG7vR1HANUw44pBqRdSC8RrzdLbYjsNvFMq6jzcgJ+60ORBfS4FXtBDehfl+6PvqBSfUE8fwJfN3KmEXESbKRw1eSpwzrjXm7rTUDQ+UnZ8l/TzAAPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=v9x2w2JV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="v9x2w2JV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53EF01F00A3A; Tue, 8 Sep 2026 12:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788870245; bh=4/+IMpnq/A8ogQssx5gk+p3GDV8+S7m6KxmKQUdrQdg=; h=Subject:To:Cc:From:Date; b=v9x2w2JV4crkWQPzxiDeozb7kOeOU981W0B+EtkC8P4w1QhKMHRKYsfiPhqykKmqW d/zy4/rLsarf1OXOXSPCDWrJ332pgQodNknIawTYLWWgkLDLT77pH+D48DL4mnu9t6 bmfHOhsKmnV/oQEhDBS0wTLzEMMqJJEptDznXz1I= Subject: FAILED: patch "[PATCH] usb: gadget: f_mass_storage: fix null pointer dereference in" failed to apply to 6.12-stable tree To: jeffinphilip14@gmail.com,gregkh@linuxfoundation.org,stable@kernel.org,stern@rowland.harvard.edu Cc: From: Date: Tue, 08 Sep 2026 14:23:50 +0200 Message-ID: <2026090850-exonerate-dumpster-494a@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x 2c0f5ca48674a5b5f9fa4a9c3325aa48053af0bc # git commit -s git send-email --to '' --in-reply-to '2026090850-exonerate-dumpster-494a@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 2c0f5ca48674a5b5f9fa4a9c3325aa48053af0bc Mon Sep 17 00:00:00 2001 From: Jeffin Philip Date: Tue, 18 Aug 2026 09:29:04 +0530 Subject: [PATCH] usb: gadget: f_mass_storage: fix null pointer dereference in fsg_common_set_num_buffers() Previously fsg_num_buffers_validate() was removed as it was not necessary due to Kconfig setting the limits for n from 2 to 256 with default as 2. However, setting the page content in such a way that kstrtou8() reflects n value as either 0 or 1 bypasses these restrictions leading to a null pointer dereference if n is 0. Fix this by adding a check for n < 2 and returning -EINVAL if n is either 0 or 1 consistent with Kconfig logic. Reported-by: syzbot+791be35f1fbcc85d06d7@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=791be35f1fbcc85d06d7 Fixes: fe5a6c48fd95 ("usb: gadget: storage: get rid of fsg_num_buffers_validate()") Cc: stable Signed-off-by: Jeffin Philip Acked-by: Alan Stern Link: https://patch.msgid.link/20260818035904.10324-1-jeffinphilip14@gmail.com Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 1a0fbc808ee2..fc4818fb2a8b 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2747,6 +2747,9 @@ int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n) struct fsg_buffhd *bh, *buffhds; int i; + if (n < 2) + return -EINVAL; + buffhds = kzalloc_objs(*buffhds, n); if (!buffhds) return -ENOMEM;