From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.171.202.116 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796292055; b=O0nciM6QDyb9gjczXYzXeBuIwYDIbH8mNxpV93BBKmZTyhAyNQQ0hhMLd+Bl8FFdm9bI KRvqYMpdlLnazVTG7nhms3IPaJrY4EHAhT/KoE2e+iNhlcXVeMV2TyItuZHvOyMJYbV7b Ug0kO1FOuwHt1XXXMj77Z/mS1BvZ1pxlXblwy3fqEbBBaPCVttDc+pA+JqmrroxWs3LlS UCDmPmTRI8iB3XRV1fRDXsI0CEoK6Q1874uQFcYobNYGVdGvjROlH5dgi1557BpV0P1up txK/SP+7PRtUZUBC7/bF+ImyQEsx/y4XRBPak+b3Xgs3qAui9KXkCYdp4sdaMYXbJJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796292055; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:In-Reply-To:References:User-Agent:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding: X-Last-TLS-Session-Version; bh=CQuygVLSsgiFwOF/LWi+X5d4uku9jhtDWm1G/b7OnPY=; b=CLBr5fUP/+CEmf5dPB2Bz/WW997/06MH3YItfqkAfSiZeXnk/oaOOW0KqyN13yWLh9hG Ykhz+t5xGFoOQuxLYe+PXYG3tRggok054XyXXP2bsFX+/Jt6S8XrVR+S6Q5vgcOC+FQsn E0hzbqf8MbrWKy3hODzCnl+cTK6j7+e274hXi6WAIW4KVQE3CwfihtDhIUt/6GxQZsu1v ti27yaxugaVG+8BxleEfXUhdb5OyAyGtq6jIBDpmajyQ8kgeNQMjFiXyol/q320wyzJnB cia+6LOV0/qAiSmBDzF+pmGX6bAwnp+e6lmV+OTsVGQoOyhms4bMDbxtCNZNUApoMug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=NET5A78A; arc=none smtp.remote-ip=185.171.202.116 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2F86606A322; Thu, 3 Dec 2026 10:00:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E2F86606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=NET5A78A Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 59137C2AC55; Thu, 3 Dec 2026 10:01:03 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CFA6E604ED; Thu, 3 Dec 2026 10:00:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7276C11EA1F5F; Thu, 03 Dec 2026 11:00:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796292051; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=CQuygVLSsgiFwOF/LWi+X5d4uku9jhtDWm1G/b7OnPY=; b=NET5A78AxEg5qH0N6f9Rwp+1aS7xdbrnPVCOIlcsGT77vtKbj25Y08nnvIwi5DzxqO1eYO nQq6XquobGYR4Yi6f88cQMkRkbasbeBFON5M34Hyx4Tav6d8h79W+iVlbjnMmPhy7lEfZw x1vmIIdQYDWs+Y9oE6C2RoKQ3hanlB8bO5yHTBCtMnocZbmuspummzyOdxnILKFQ6GUI1q wO+la0y5fSZzkgomO9zWGHbELcJT00XoE8IyVAbGCLzU7+/FgxbAmBD0Vv+SRLuJQLf7qY DrC9vv1ZS1Gv+odiYqyvIVwM1cgesRKCxRGNSuKlztME0ZpxjJBoywLLeIuNJw== From: Miquel Raynal To: Fang Xieyan Cc: richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mtd: mtdpart: fix overflow check for partition offset and size In-Reply-To: <20261203080547.15619-1-fangxy@xiaopeng.com> (Fang Xieyan's message of "Thu, 3 Dec 2026 16:05:47 +0800") References: <20261203080547.15619-1-fangxy@xiaopeng.com> User-Agent: mu4e 1.12.12; emacs 30.2 Date: Thu, 03 Dec 2026 11:00:43 +0100 Message-ID: <87se0ek7jo.fsf@bootlin.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Hi, On 03/12/2026 at 16:05:47 +08, Fang Xieyan wrote: > allocate_partition() checks whether a partition extends beyond its > parent by adding the partition offset and size. Both values are u64, > so the addition can overflow and wrap to a value smaller than the > parent size. The day you see an 8 Zetta bytes flash, you're gonna have many more issues than this one. MTD maintainers, shall we take this kind of over denfensive fix? The diff is minimal, so I'm not bothered by the change besides the fact that I don't think it is in any way useful. Thanks, Miqu=C3=A8l From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC57606A32C for ; Thu, 3 Dec 2026 10:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=iioDvitV; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=NET5A78A DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=ITqbXgI64JVtpdLmMFKMsbmshZMCvjZSxsYaLBjLtJ8=; b=iioDvitVi7XZWFR51NiFCnyxv1 LaHh/20xopqRob9e2ZvkZx4hhOmsZ2f58cgW8BeosrX0pzZIb0wUEXofuKbnC8fzxmOLzfd2t3eyG EPdLqhbvi9oZjThFJHBVB+8VnggjGFMw4JUNUPB6yr0FERGSChARfDS8fSTdbv50J4lOVctgd1f8/ fplUMvWrNfTABHPyOYLOrNzH8Yh+R1eFHLljZFU73qfyPxhrHhEnFP6osktCw5hL256FtHve6LI/R yEeAVIPcHK0G23MeqOjV0RW7a+YibO/pV0vsnCdxNNdfNW8aj7sM0t71An+TvA3IS80jXOQxg24Sl 60QMmG6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ3co-0000000E6oo-3dep; Thu, 03 Dec 2026 10:01:14 +0000 Received: from smtpout-03.galae.net ([185.246.85.4]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ3ca-0000000E6mz-31Iz for linux-mtd@lists.infradead.org; Thu, 03 Dec 2026 10:01:05 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 0CF7F4E4185C; Thu, 3 Dec 2026 10:00:52 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CFA6E604ED; Thu, 3 Dec 2026 10:00:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7276C11EA1F5F; Thu, 03 Dec 2026 11:00:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796292051; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=CQuygVLSsgiFwOF/LWi+X5d4uku9jhtDWm1G/b7OnPY=; b=NET5A78AxEg5qH0N6f9Rwp+1aS7xdbrnPVCOIlcsGT77vtKbj25Y08nnvIwi5DzxqO1eYO nQq6XquobGYR4Yi6f88cQMkRkbasbeBFON5M34Hyx4Tav6d8h79W+iVlbjnMmPhy7lEfZw x1vmIIdQYDWs+Y9oE6C2RoKQ3hanlB8bO5yHTBCtMnocZbmuspummzyOdxnILKFQ6GUI1q wO+la0y5fSZzkgomO9zWGHbELcJT00XoE8IyVAbGCLzU7+/FgxbAmBD0Vv+SRLuJQLf7qY DrC9vv1ZS1Gv+odiYqyvIVwM1cgesRKCxRGNSuKlztME0ZpxjJBoywLLeIuNJw== From: Miquel Raynal To: Fang Xieyan Cc: richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mtd: mtdpart: fix overflow check for partition offset and size In-Reply-To: <20261203080547.15619-1-fangxy@xiaopeng.com> (Fang Xieyan's message of "Thu, 3 Dec 2026 16:05:47 +0800") References: <20261203080547.15619-1-fangxy@xiaopeng.com> User-Agent: mu4e 1.12.12; emacs 30.2 Date: Thu, 03 Dec 2026 11:00:43 +0100 Message-ID: <87se0ek7jo.fsf@bootlin.com> X-Archived-By: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261203_020100_908511_B7011928 X-CRM114-Status: UNSURE ( 7.30 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.1 (--) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-mtd" X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 SGksCgpPbiAwMy8xMi8yMDI2IGF0IDE2OjA1OjQ3ICswOCwgRmFuZyBYaWV5YW4gPGZhbmd4eUB4 aWFvcGVuZy5jb20+IHdyb3RlOgoKPiBhbGxvY2F0ZV9wYXJ0aXRpb24oKSBjaGVja3Mgd2hldGhl ciBhIHBhcnRpdGlvbiBleHRlbmRzIGJleW9uZCBpdHMKPiBwYXJlbnQgYnkgYWRkaW5nIHRoZSBw YXJ0aXRpb24gb2Zmc2V0IGFuZCBzaXplLiAgQm90aCB2YWx1ZXMgYXJlIHU2NCwKPiBzbyB0aGUg YWRkaXRpb24gY2FuIG92ZXJmbG93IGFuZCB3cmFwIHRvIGEgdmFsdWUgc21hbGxlciB0aGFuIHRo ZQo+IHBhcmVudCBzaXplLgoKVGhlIGRheSB5b3Ugc2VlIGFuIDggWmV0dGEgYnl0ZXMgZmxhc2gs IHlvdSdyZSBnb25uYSBoYXZlIG1hbnkgbW9yZQppc3N1ZXMgdGhhbiB0aGlzIG9uZS4KCk1URCBt YWludGFpbmVycywgc2hhbGwgd2UgdGFrZSB0aGlzIGtpbmQgb2Ygb3ZlciBkZW5mZW5zaXZlIGZp eD8gVGhlCmRpZmYgaXMgbWluaW1hbCwgc28gSSdtIG5vdCBib3RoZXJlZCBieSB0aGUgY2hhbmdl IGJlc2lkZXMgdGhlIGZhY3QgdGhhdApJIGRvbid0IHRoaW5rIGl0IGlzIGluIGFueSB3YXkgdXNl ZnVsLgoKVGhhbmtzLApNaXF1w6hsCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX18KTGludXggTVREIGRpc2N1c3Npb24gbWFpbGluZyBsaXN0Cmh0 dHA6Ly9saXN0cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGluZm8vbGludXgtbXRkLwo=