From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796164044; b=amtWG4ak/y7KTy5bKg5ZhcPrflrPhpz0jzT3gU9+NK8Ru8+LZ9/la1hAbWL/v+5j2mPc ATbaUhkTczlf/iRBjMqY1OU1IqPMUDwys1usM4xFE50KkTmFNjqq/U4vcskxaOTqH80F5 Oi73gNTrNK3iRQDj8R4MC7bZatVGPX/xXQc3HWWVw07YdKkGP7dfhwqnqqsIGgb6IX/Mh L5/wTZcYgaZUD1x75vywvhClx0YsgpCwjwSrSRsXQjU92tG2b5nMWFGHWRhsQT080GOP2 cHOTvLyv6ORiJwCWy7vsSEQMFeLKPDOK17KPQCV0MyKBNUxFPqZot7DzncwhIVhpXXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796164044; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; bh=h+VbPS7ECE2TfI6nd+2wimYhC0LSXQy4auyTFoi2OhI=; b=dPlZqfSreOFFlnCeKQHv/YdS88ao/MkJETefc93561d7QIpk1X4ovC72pjSngJhOpDIt PjCJEGV/8Qk9E6twzLIIcLTupeelq+G6MrADCwrZd/MXh0q/Hz4lLenZ47mzg525UVYG6 DU3SFbDGQCHpnjq/svpJ4fJY8BXDoSGqG09V842+sWck3QragvsY11L23HaZNS8uA5eHc HE5C5/nCyK01w523d/KVu5etnhXgygPug9d0zp9oQZCFrlcX3ThJUGS1gXpT0zFDWTkJ0 8YQ2CJ6K+nxtPmE0zVlN04rUNIchCsUeEq1PMyGsuk/f9vmU3o39CCG2Jd9iKADr9tg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=sigma-star.at; spf=pass smtp.mailfrom=sigma-star.at; dkim=pass header.d=sigma-star.at header.i=@sigma-star.at header.a=rsa-sha256 header.s=google header.b=Ziw99j2r; arc=none smtp.remote-ip=209.85.128.43 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB2CB606A31A for ; Tue, 1 Dec 2026 22:27:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BB2CB606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sigma-star.at Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sigma-star.at Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=sigma-star.at header.i=@sigma-star.at header.a=rsa-sha256 header.s=google header.b=Ziw99j2r Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso151727755e9.1 for ; Tue, 01 Dec 2026 14:27:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sigma-star.at; s=google; t=1796164042; x=1796768842; darn=vger.kernel.org; h=content-type:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=h+VbPS7ECE2TfI6nd+2wimYhC0LSXQy4auyTFoi2OhI=; b=Ziw99j2r8M5Amt0Qyoyc/JkRYwc+AXP2F1fcrlTdlLwunnhISubqGKraMIXJcI5Mb0 iZzi59rhicQfsYGcgC6rIfk7H0eLVehIWTvtB0PFACTGuj9gKTwt/9485+LT8XBMHgZ0 2X9PCDX/afOul0Jw2cD33tgFgy7T+zLH2BouoWeexou4nDDZrNXGROYqdWreTk3w/Fn7 GdZdn3hGbUeywFusIQMXvaMMmTfYd1KL4lpvKDeRj5t6/ko126XOS1cHVDcnTpIObP6q eQ0Kj3/nSYaAV1KyUb81MAcQU4o6pBMaFVV8pkRerLeIwWBLfmp5ItMr/Th8s4txm2m+ 0+fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796164042; x=1796768842; h=content-type:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=h+VbPS7ECE2TfI6nd+2wimYhC0LSXQy4auyTFoi2OhI=; b=mBIpJ4hVhpVrMWDMoNTdgkVdggrYQjE3lCnVQnllI1JeyzQ7kTEkttdtuRLYRh6veL QInfdjrfKybc+NEj1UrT7ihPvWVF77AUEeNfDog+zOnMNUNEMttLwLivVGRnW99qGC9O R/On3o9YUG8eNSh+69b2DbTlUlbklCPjaEIkHae1qNM/Ch9nnVXXGIRDKfaUV9DfdoC5 0tNdvVDY+FpNRl0DbUGGPIN5CTC+Cq/7W6p0KTcXez3p381PEfHme8+eOeQd72flM+xc Qv4hX2rtopnqt20M/KvisMKeOl1unH3dUpkqZvVtplT6kMFjjtestdhr1UgGlywc5dPZ l2qQ== X-Forwarded-Encrypted: i=1; AL+hErEOLxdkzSlQaZ73LJ2bugGPyASfRTv910s7oDjhynYQRUkE21XCTooHm1JVJzfT5f54ofkwoFsrQICm7Hk=@vger.kernel.org X-Gm-Message-State: APuU4Z+axfjjIWDdjhO15PvpB93bKvwMMJsRYkPPzwmhBZozYJG7FmxT O6v6seQGJqmTIBkKwQc4lOZY+hBN6+RhEu6gpgJKPGqFKnsPY59G/9nJpiCsZ9Zy9AE= X-Gm-Gg: AZFdTZdO4R7KSbexaxndnnX+lve34hXwwFlorTVX0MBjcf0IcJPk2TmLN0b/I+NCIdh 6NYT71Gpso13b72ui+671oueu5NPPV6DjTUQJM3TXYAJr7I020PkjgzIfsOC5xz/HklXPRb/XA5 fzDI7sxMOiZrWX4Vl5S+uiE6UaqfF4hpIh3TMiI/FUQ9ER3pDhS1BoVrVewC8E4usgwPWyLeCB0 pV9+JSE3Gea1vo7PbYYeHX4Z4JFVZBsGS+AUPVWsJyutXvjc1Si1og2KP43sNjHSDvd8gLRFCyv mSm9xMm/pHg3y35iSSZPa1/lqtyhyVENItlDqyCWacczFMIDNuDk4LlgJJ19+UYYupPHPw216OD L4JNXGw8jzDTb8vT7UtzJR2yrmjqlaXkIrK4muH05VFa8q/LixWYETC4YmigWjwwm4sYhfFNOQv Nw0CV8IZWTQckwbmFv7EqcMqcDs1ae1gYzVwISJUGt4VzypFBEaPC5ckHmOeWMslIYCp8AHwtuR B+rH6Np5xScCWPVQeS7tGlvGXuxj8eJrduqi6gLbKsdJQVHe7uh8QbriSLvGRAQDhmxi+5ylLX3 aYH1ssovNe1+JDVo4oQi7CktLilwDVt7vRhzZPIuPjACY+gau3VxJjY/m4uJ5uxcI4rp6Q== X-Received: by 2002:a05:600c:154c:b0:4a2:1364:252a with SMTP id 5b1f17b1804b1-4bb887c28a8mr754245135e9.3.1796164041395; Tue, 01 Dec 2026 14:27:21 -0800 (PST) Received: from somecomputer (85-127-104-29.dsl.dynamic.surfer.at. [85.127.104.29]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf61e8sm75913097f8f.11.2026.12.01.14.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 14:27:21 -0800 (PST) From: Richard Weinberger To: linux-mtd@lists.infradead.org, David Woodhouse , Richard Weinberger Cc: Zhihao Cheng , Artem Sadovnikov , Kees Cook , linux-kernel@vger.kernel.org, Michael Bommarito Subject: Re: [PATCH 2/2] jffs2: bound summary entry walks against the payload Date: Tue, 01 Dec 2026 23:27:20 +0100 Message-ID: In-Reply-To: <20260415124813.246588-3-michael.bommarito@gmail.com> References: <20260415124813.246588-1-michael.bommarito@gmail.com> <20260415124813.246588-3-michael.bommarito@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Mittwoch, 15. April 2026 14:48 Michael Bommarito wrote: > jffs2_sum_process_sum_data() iterates summary->sum_num times, reading > the next entry's nodetype from the current sp and dispatching into > type-specific handlers that advance sp by a fixed or nsize-dependent > amount. There is no upper bound on sum_num from the writer side, and > on read the scanner trusts the on-flash value unchecked. >=20 > A crafted flash image can therefore set sum_num > (actual entries > that fit in the payload). Once sp runs off the end of the summary > buffer the nodetype read at summary.c:407 lands on adjacent slab > memory. If those bytes happen to decode as one of the known types > (JFFS2_NODETYPE_INODE / _DIRENT / _XATTR / _XREF) the handler calls > sum_link_node_ref() with offset / totlen pulled from whatever slab > neighbor is next to the scan buffer. >=20 > Reproduced on v7.0-rc7 under UML + CONFIG_KASAN=3Dy with a crafted > image carrying one real INODE entry and sum_num=3D2: >=20 > BUG: KASAN: slab-out-of-bounds in jffs2_sum_scan_sumnode+0x6bd > Read of size 2 at addr 00000000621fb000 by task mount/31 > Located 0 bytes to the right of allocated 4096-byte region >=20 > The matching sum_num=3D1 image (same bytes, honest sum_num) mounts > without a KASAN report, so the OOB is sum_num-specific. >=20 > Pass sumsize into jffs2_sum_process_sum_data() and bound sp against > summary + sumsize - sizeof(struct jffs2_sum_marker) before every > nodetype read and before every type-specific field access. If the > advance would leave the payload, warn and fall back to a full scan > via -ENOTRECOVERABLE. I fear this is not correct. If you return -ENOTRECOVERABLE you have to undo first everything what the summary code did before. See the existing -ENOTRECOVERABLE case, it resets the counters and calls jffs2_free_jeb_node_refs(). Thanks, //richard =2D-=20 =E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8Bsigma star gmbh | Eduard-Bodem= =2DGasse 6, 6020 Innsbruck, AUT UID/VAT Nr: ATU 66964118 | FN: 374287y