From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 02D0C284881 for ; Fri, 20 Mar 2026 17:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774028009; cv=none; b=lNrMlXWLcD3yiK1wU4tets1puzr/AHGhKJzV903gA+puYZPVtZb7HNwFaToEBd0GJbpPj3r8GgI2F/ZorXIb6DR6JK//LfYXZzX5xV70Do4rjnt0pGNJg55HW4esyl0Al0D7xCaPKmFgffV6qYjWKNVbZ/hfQ7GXXP9Q55z/lXE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774028009; c=relaxed/simple; bh=2o8JHk2dXgmyRebq9yM8lzBID1ydapDmt3IZsBSbkQA=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=CU+CuahsS0l4ESCTBOPWn90LVHVnCIveyhffXHUUDRg6K/hd+iosAt5TkMjBw3V5slohDCdwP72McCN5+MEFx7JwNZu3MiNlBQP2vN7vda5vdQKF9VkNeoITC3sBtOYuR9ZdQC3sLekERiqOQ79er1XiftlXlvw+8MG4SQ9mI0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kCHU81zl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kCHU81zl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 345B2C4CEF7; Fri, 20 Mar 2026 17:33:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774028008; bh=2o8JHk2dXgmyRebq9yM8lzBID1ydapDmt3IZsBSbkQA=; h=Subject:To:Cc:From:Date:From; b=kCHU81zl+pVGnVUSgB9YPT7gRvYqTvgaKBZpYzKuuF6FFieCEpWcbuXa2qH+C7mXO U64NFBObqcZKtbulxfuXYzA9nsRpXkMqSDkUA0XHw6fw19NezMbMGUaw7u+CQ2R5mr pTLGuUtzXWTM9kXoeelsdOctmDufrAmtmE0jv3xc= Subject: FAILED: patch "[PATCH] mtd: Avoid boot crash in RedBoot partition table parser" failed to apply to 5.10-stable tree To: fthain@linux-m68k.org,kees@kernel.org,miquel.raynal@bootlin.com Cc: From: Date: Fri, 20 Mar 2026 18:33:25 +0100 Message-ID: <2026032025-scanning-frying-8ead@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 5.10-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-5.10.y git checkout FETCH_HEAD git cherry-pick -x 8e2f8020270af7777d49c2e7132260983e4fc566 # git commit -s git send-email --to '' --in-reply-to '2026032025-scanning-frying-8ead@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 8e2f8020270af7777d49c2e7132260983e4fc566 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Mon, 16 Feb 2026 18:01:30 +1100 Subject: [PATCH] mtd: Avoid boot crash in RedBoot partition table parser Given CONFIG_FORTIFY_SOURCE=y and a recent compiler, commit 439a1bcac648 ("fortify: Use __builtin_dynamic_object_size() when available") produces the warning below and an oops. Searching for RedBoot partition table in 50000000.flash at offset 0x7e0000 ------------[ cut here ]------------ WARNING: lib/string_helpers.c:1035 at 0xc029e04c, CPU#0: swapper/0/1 memcmp: detected buffer overflow: 15 byte read of buffer size 14 Modules linked in: CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.19.0 #1 NONE As Kees said, "'names' is pointing to the final 'namelen' many bytes of the allocation ... 'namelen' could be basically any length at all. This fortify warning looks legit to me -- this code used to be reading beyond the end of the allocation." Since the size of the dynamic allocation is calculated with strlen() we can use strcmp() instead of memcmp() and remain within bounds. Cc: Kees Cook Cc: stable@vger.kernel.org Cc: linux-hardening@vger.kernel.org Link: https://lore.kernel.org/all/202602151911.AD092DFFCD@keescook/ Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Suggested-by: Kees Cook Signed-off-by: Finn Thain Signed-off-by: Miquel Raynal diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c index 558905160ddb..bf162c44eafe 100644 --- a/drivers/mtd/parsers/redboot.c +++ b/drivers/mtd/parsers/redboot.c @@ -270,9 +270,9 @@ nogood: strcpy(names, fl->img->name); #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY - if (!memcmp(names, "RedBoot", 8) || - !memcmp(names, "RedBoot config", 15) || - !memcmp(names, "FIS directory", 14)) { + if (!strcmp(names, "RedBoot") || + !strcmp(names, "RedBoot config") || + !strcmp(names, "FIS directory")) { parts[i].mask_flags = MTD_WRITEABLE; } #endif