mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>, Richard Weinberger <richard@nod.at>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Wang Yong <wang.yong12@zte.com.cn>,
	Lu Zhongjun <lu.zhongjun@zte.com.cn>,
	Yang Tao <yang.tao172@zte.com.cn>,
	Al Viro <viro@zeniv.linux.org.uk>,
	<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<lvc-project@linuxtesting.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH 2/2] jffs2: initialize inocache earlier
Date: Mon, 18 Nov 2024 13:24:43 +0800	[thread overview]
Message-ID: <b4865aaf-8253-b44e-55fe-d1fab1f5f092@huawei.com> (raw)
In-Reply-To: <20241117184412.366672-3-pchelkin@ispras.ru>

在 2024/11/18 2:44, Fedor Pchelkin 写道:
> Inside jffs2_new_inode() there is a small gap when jffs2_init_acl_pre() or
> jffs2_do_new_inode() may fail e.g. due to a memory allocation error while
> uninit inocache field is touched upon subsequent inode eviction.
> 
> general protection fault, probably for non-canonical address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN NOPTI
> KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]
> CPU: 0 PID: 10592 Comm: syz-executor.1 Not tainted 5.10.209-syzkaller #0
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
> RIP: 0010:jffs2_xattr_delete_inode+0x35/0x130 fs/jffs2/xattr.c:602
> Call Trace:
>   jffs2_do_clear_inode+0x4c/0x570 fs/jffs2/readinode.c:1418
>   evict+0x281/0x6b0 fs/inode.c:577
>   iput_final fs/inode.c:1697 [inline]
>   iput.part.0+0x4df/0x6d0 fs/inode.c:1723
>   iput+0x58/0x80 fs/inode.c:1713
>   jffs2_new_inode+0xb12/0xdb0 fs/jffs2/fs.c:469
>   jffs2_create+0x90/0x400 fs/jffs2/dir.c:177
>   lookup_open.isra.0+0xead/0x1260 fs/namei.c:3169
>   open_last_lookups fs/namei.c:3239 [inline]
>   path_openat+0x96c/0x2670 fs/namei.c:3428
>   do_filp_open+0x1a4/0x3f0 fs/namei.c:3458
>   do_sys_openat2+0x171/0x420 fs/open.c:1186
>   do_sys_open fs/open.c:1202 [inline]
>   __do_sys_openat fs/open.c:1218 [inline]
>   __se_sys_openat fs/open.c:1213 [inline]
>   __x64_sys_openat+0x13c/0x1f0 fs/open.c:1213
>   do_syscall_64+0x30/0x40 arch/x86/entry/common.c:46
> 
> Initialize the inocache pointer to a NULL value while preparing an inode
> in jffs2_init_inode_info(). jffs2_xattr_delete_inode() will handle it
> later just fine.
> 
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
> ---
>   fs/jffs2/os-linux.h | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
> index 86ab014a349c..39b6565f10c9 100644
> --- a/fs/jffs2/os-linux.h
> +++ b/fs/jffs2/os-linux.h
> @@ -55,6 +55,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
>   	f->metadata = NULL;
>   	f->dents = NULL;
>   	f->target = NULL;
> +	f->inocache = NULL;
>   	f->flags = 0;
>   	f->usercompr = 0;
>   }
> 


      reply	other threads:[~2024-11-18  5:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-17 18:44 [PATCH 0/2] jffs2: fix a couple of uninit value errors Fedor Pchelkin
2024-11-17 18:44 ` [PATCH 1/2] jffs2: initialize filesystem-private inode info in ->alloc_inode callback Fedor Pchelkin
2024-11-18  5:22   ` Zhihao Cheng
2025-01-09 10:12   ` Joakim Tjernlund
2025-02-19 15:18   ` Joakim Tjernlund
2024-11-17 18:44 ` [PATCH 2/2] jffs2: initialize inocache earlier Fedor Pchelkin
2024-11-18  5:24   ` Zhihao Cheng [this message]

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=b4865aaf-8253-b44e-55fe-d1fab1f5f092@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=lu.zhongjun@zte.com.cn \
    --cc=lvc-project@linuxtesting.org \
    --cc=pchelkin@ispras.ru \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wang.yong12@zte.com.cn \
    --cc=yang.tao172@zte.com.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®