Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1688008lqo; Sun, 12 May 2024 13:48:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHc7xKuQ7oiFfUuMrLoJSKrgVF0YR0k7OqGnY9HKR+n0ZLKaw7g7lsGE845bvWi26E5GreAbvZxBAsDxEUdd3dyDzwf43CxCEBFSLJfA== X-Google-Smtp-Source: AGHT+IEBkqTyiFbtib8swS3RNQ0dJVIRHaAQ/fBdzDeJXyMeLL7Ndz1V4oCRCwbTw28JIiBnB+Iq X-Received: by 2002:a05:6e02:1567:b0:36c:45bf:a8f0 with SMTP id e9e14a558f8ab-36cc14e79famr111778615ab.25.1715546938081; Sun, 12 May 2024 13:48:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715546938; cv=pass; d=google.com; s=arc-20160816; b=E55jWxZw49sIpEcghaE1jD2k6i0s2yg434BbS4A2iXHvhrGhlxZcqFdM/2N3ONuF9W vKN40qBiknOEhC0VmdAZj0NuVFiyVyJBqytDxrtVs2FNdvTf1iS3OGFRQz9YhMi0Bwm7 QUFczimcvnDr5GKDcyNMNxkvg/psGl9DCa6hQG0UhqCizcS/flZlyX2oc2N1uir4c4DO hqOb7h+cYVIn9ds3VIL0ZUdW6PmtVeOBomgND1vBubdkmqG7MGaX8jtTZVvI+gak9zc9 aKwtpZSPDv0JxWqdOTqjUUDMxYj/GytN/XUrPMrLBL+MiRDZkE99Nmmnzzp5fgrS8/02 v+IA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=thread-index:thread-topic:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject :references:in-reply-to:message-id:cc:to:from:date; bh=mQz2PVpow/m3oWLabdk1T8VjND6NQfy9quPq/5IXeUo=; fh=M1JpiYBOpFGxkJMtJT6cgqTP7kTb+TWknogNaIsqONA=; b=K8IsXpwHhuAX3cw/OD6hbxB4w0ugiuIC9VMyyqqjTILPbvkoI0J14zzWNANBDpIqOB jNHF7qyJhE7S4ubHdHrHno2aEe3x4vXJBwmB0J5uqFfEVO7D2S0xSCKLwJ2BugDt6NqE Pj4+cCtBxyFR+Xnkv5lSa8Z0u4311V9n33LgC4urdcjvqvzDSpNhfHP2x2MhurOf/ONs VuDNqaoraiMXSYfuJ6kNMY17LYObwwTXwy3LKGTXFs/I55ja/GGpr1wOd3fypcvpyxLW KeUOiJ5ahYxrQGYYH2Wk38AgAaxcCnF/DKeU8/vPjviegjiuk7pu2rFTep7PaHQWSONN vKnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-177004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177004-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63413d72d2dsi8048277a12.862.2024.05.12.13.48.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 13:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-177004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177004-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B45EC281B1B for ; Sun, 12 May 2024 20:48:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB1F72E3F2; Sun, 12 May 2024 20:48:51 +0000 (UTC) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) (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 D41001E502 for ; Sun, 12 May 2024 20:48:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.201.40.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715546931; cv=none; b=FuuIIacsM18ev3U1B5IrCTaAEqBbSYHH3fK0EAfwydutowTxP0Z6JAPLOaPRz/RFn9kR3RYnrUPILUPBWgwjFByMNKIFbCpH1lqnb2J6L2kmiaZx9YkKO8PIWmB6ho549GUSb6JFRxYyGUR61KzlLGLsjMpBqylQIkzF5Obxm6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715546931; c=relaxed/simple; bh=mQz2PVpow/m3oWLabdk1T8VjND6NQfy9quPq/5IXeUo=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=mbCENxJGl4WgRw1tTLPKAM2W0gLy1EyNGm7SH/Ik/WnUFoVTZAGpo2CmHU7uJ0dxjjRXGMoZk+cUL/ww96SzxN/c+rkuzQ/Gp4XIR6UyvI1MnqdRdVWX1SMf74+0STT1IdHXqJG17Wdm07tiG1oA2e8DJ+waXVPeO8tZN0CJajU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at; spf=fail smtp.mailfrom=nod.at; arc=none smtp.client-ip=195.201.40.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nod.at Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 216D6647A81E; Sun, 12 May 2024 22:39:08 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id K9RyJ2jP0xmW; Sun, 12 May 2024 22:39:07 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 893EE626FAF9; Sun, 12 May 2024 22:39:07 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zTe9dMvffljG; Sun, 12 May 2024 22:39:07 +0200 (CEST) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id 69F4C647A81E; Sun, 12 May 2024 22:39:07 +0200 (CEST) Date: Sun, 12 May 2024 22:39:07 +0200 (CEST) From: Richard Weinberger To: Artem Chernyshev Cc: David Woodhouse , linux-mtd , linux-kernel , lvc-project@linuxtesting.org Message-ID: <1371873614.97879.1715546347299.JavaMail.zimbra@nod.at> In-Reply-To: <20240329121629.316171-1-artem.chernyshev@red-soft.ru> References: <20240329121629.316171-1-artem.chernyshev@red-soft.ru> Subject: Re: [PATCH] fs/jffs2: Fix NULL deref in jffs2_scan_dirty_space Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF97 (Linux)/8.8.12_GA_3809) Thread-Topic: fs/jffs2: Fix NULL deref in jffs2_scan_dirty_space Thread-Index: y5ad11duY8iSWWYoNLafHLQXdw07tQ== ----- Urspr=C3=BCngliche Mail ----- > Von: "Artem Chernyshev" > An: "David Woodhouse" , "richard" > CC: "Artem Chernyshev" , "linux-mtd" , "linux-kernel" > , lvc-project@linuxtesting.org > Gesendet: Freitag, 29. M=C3=A4rz 2024 13:16:29 > Betreff: [PATCH] fs/jffs2: Fix NULL deref in jffs2_scan_dirty_space > As was mentioned in 2ebf09c2, it is possible to get oops, > when marking space dirty in scan, but no previous node exists >=20 > It still can be in jffs2_link_node_ref() via deref jeb->last_node. > Since all jffs2_scan_dirty_space() callers check value of a > function, we can return error code safely. >=20 > Found by Linux Verification Center (linuxtesting.org) with SVACE. >=20 > Signed-off-by: Artem Chernyshev > --- > fs/jffs2/nodelist.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c > index b86c78d178c6..6bebf1d64000 100644 > --- a/fs/jffs2/nodelist.c > +++ b/fs/jffs2/nodelist.c > @@ -669,8 +669,11 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, = struct > jffs2_eraseblock *jeb > =09=09=09size, jeb->free_size, jeb->wasted_size); > =09=09BUG(); > =09} > +=09if (!jeb->last_node) { > +=09=09return -EINVAL; > +=09} Did you test this change? I'm not so sure whether returning -EINVAL is correct. Thanks, //richard