From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B94A846F for ; Sat, 20 Jun 2026 16:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781971779; cv=none; b=oXlE2DD3MoqWRMdAkLaxl0NT9tZdu0RbYzpngNVBFboZ7uJtXznUR4lQx7dQlt/Jv47fmKTw61LOxFMW4xz+9ZYxDuHEyuCeeypOWe3va4SNFlm1Nz/Mj2UQvESxlcphhQEM1S4lg/99t9p5kf5oQGf7TS4Zal6MemXrHVwoLeU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781971779; c=relaxed/simple; bh=rQgbRtdM4mwUdaPup+KdgfOYfAQ1M1tAwYXO4N2fTk8=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=IWo0h7YjbZcHjHU7rgZ2x29d6rDhoTU2dth+bm0DkJgcaDYxlmMjaBqxjSf9MRjovWNgumO5L6R5wcz2iMeG9QFtS1UpUHttSVwbuf1CPexT0SCmNu3OiZ2/QIstMwNIsfiyn+bqBkKnk76SxV27cUWOeibfFKZL5HypsLYsAdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.167.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-486055c1c6fso3434566b6e.1 for ; Sat, 20 Jun 2026 09:09:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781971777; x=1782576577; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fs0bv62AVsp0G6FNGuU7vyryZZvG1PncipIn/LAZcK4=; b=lS2BUxr75UTGK9i7U+vr2IrjD/D3EHjo7UX39d1O7eBTwVBc/B5GbHsDpSIxMW5sUw Xv8DD2eHYY4p6vznuiBKlCSKf9ylC32MRZ7g3PlFrP4qqY4SR5MAalPR+7fiMlGt8OFQ XWymVO2DA5Sbj1spqjyNw9icqkFHoGiKlE3twSGv1iaeM4N80YeucrO7/AuKKzfuQpxU 0Oefgmx18CXPz82baqqIUZ3rD48uEzO9qtdIhiz/b4xnj6/Cl/U5RZNnhinh1pLDcqXS 6GH8xBT8qQA6sIJy8Mn2tE02ORHSHbveFU8TRBVqVoihgmSwtICWyb0pH1o2QkLBZqqR pzzQ== X-Gm-Message-State: AOJu0YwoyIusXMwwGQO6HFh0W+vEEA+pLo7Ixcn9ZAvL0Jb9thqpbjVj WENTVb0RIFK7LGzjHpfWyZCNLoTn7l6yYN1zwUxRH41sP7jL3sIDQ2GNIKuLDbxviwwWSMbxeZk IQgWgW8+Dls/0UQPMNgPOPfIVztgMEG0uUn6ZUlGTcsG2PzFUUpfHnqIG92w= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6808:2018:10b0:489:b97d:3f52 with SMTP id 5614622812f47-489b97d40d2mr3267606b6e.37.1781971777472; Sat, 20 Jun 2026 09:09:37 -0700 (PDT) Date: Sat, 20 Jun 2026 09:09:37 -0700 In-Reply-To: <6a364dbc.713c5d62.148f7.0000.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a36bb41.956a836d.179a93.0001.GAE@google.com> Subject: Forwarded: [PATCH] mtd: mtdpart: fix uninitialized erasesize on MTDPART_OFS_RETAIN error path From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] mtd: mtdpart: fix uninitialized erasesize on MTDPART_OFS_RETAIN error path Author: nivchenko.dev@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master When parsing partition layouts, if a partition requested with MTDPART_OFS_RETAIN runs out of space, the allocator jumps directly to 'out_register' to preserve partition numbering. However, this jump bypasses child->erasesize initialization, leaving it at zero. When add_mtd_device() is later called on this child, the registration fails and triggers a WARN_ON() due to the zero ->erasesize. Fix this by zeroing out child->part.offset and child->part.size, and initializing child->erasesize to parent->erasesize. This is the exact same pattern already used just a few lines below in the "out of reach" error check (child->part.offset >= parent_size) to safely register a disabled partition. Reported-by: syzbot+3ae80219c633aca5431c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3ae80219c633aca5431c Signed-off-by: Nikolay Ivchenko --- drivers/mtd/mtdpart.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 795a94e6b482..7f23f8a1b59c 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -118,6 +118,9 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent, part->name, parent_size - child->part.offset, child->part.size); /* register to preserve ordering */ + child->part.offset = 0; + child->part.size = 0; + child->erasesize = parent->erasesize; goto out_register; } } -- 2.43.0