From: Richard Weinberger <richard@nod.at>
To: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Cc: David Woodhouse <dwmw2@infradead.org>,
linux-mtd <linux-mtd@lists.infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] fs/jffs2: Fix NULL deref in jffs2_scan_dirty_space
Date: Sun, 12 May 2024 22:39:07 +0200 (CEST) [thread overview]
Message-ID: <1371873614.97879.1715546347299.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <20240329121629.316171-1-artem.chernyshev@red-soft.ru>
----- Ursprüngliche Mail -----
> Von: "Artem Chernyshev" <artem.chernyshev@red-soft.ru>
> An: "David Woodhouse" <dwmw2@infradead.org>, "richard" <richard@nod.at>
> CC: "Artem Chernyshev" <artem.chernyshev@red-soft.ru>, "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-kernel"
> <linux-kernel@vger.kernel.org>, lvc-project@linuxtesting.org
> Gesendet: Freitag, 29. März 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
>
> 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.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
> ---
> fs/jffs2/nodelist.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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
> size, jeb->free_size, jeb->wasted_size);
> BUG();
> }
> + if (!jeb->last_node) {
> + return -EINVAL;
> + }
Did you test this change? I'm not so sure whether returning -EINVAL is
correct.
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Richard Weinberger <richard@nod.at>
To: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Cc: David Woodhouse <dwmw2@infradead.org>,
linux-mtd <linux-mtd@lists.infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] fs/jffs2: Fix NULL deref in jffs2_scan_dirty_space
Date: Sun, 12 May 2024 22:39:07 +0200 (CEST) [thread overview]
Message-ID: <1371873614.97879.1715546347299.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <20240329121629.316171-1-artem.chernyshev@red-soft.ru>
----- Ursprüngliche Mail -----
> Von: "Artem Chernyshev" <artem.chernyshev@red-soft.ru>
> An: "David Woodhouse" <dwmw2@infradead.org>, "richard" <richard@nod.at>
> CC: "Artem Chernyshev" <artem.chernyshev@red-soft.ru>, "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-kernel"
> <linux-kernel@vger.kernel.org>, lvc-project@linuxtesting.org
> Gesendet: Freitag, 29. März 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
>
> 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.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
> ---
> fs/jffs2/nodelist.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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
> size, jeb->free_size, jeb->wasted_size);
> BUG();
> }
> + if (!jeb->last_node) {
> + return -EINVAL;
> + }
Did you test this change? I'm not so sure whether returning -EINVAL is
correct.
Thanks,
//richard
next prev parent reply other threads:[~2024-05-12 20:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 12:16 [PATCH] fs/jffs2: Fix NULL deref in jffs2_scan_dirty_space Artem Chernyshev
2024-03-29 12:16 ` Artem Chernyshev
2024-05-12 20:39 ` Richard Weinberger [this message]
2024-05-12 20:39 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371873614.97879.1715546347299.JavaMail.zimbra@nod.at \
--to=richard@nod.at \
--cc=artem.chernyshev@red-soft.ru \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lvc-project@linuxtesting.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.