From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Prince Kumar Maurya <princekumarmaurya06@gmail.com>,
syzbot+aad58150cbc64ba41bdc@syzkaller.appspotmail.com,
Christian Brauner <brauner@kernel.org>,
Sasha Levin <sashal@kernel.org>,
viro@zeniv.linux.org.uk, chenzhongjin@huawei.com,
dchinner@redhat.com
Subject: [PATCH AUTOSEL 6.4 05/16] fs/sysv: Null check to prevent null-ptr-deref bug
Date: Sun, 2 Jul 2023 15:38:04 -0400 [thread overview]
Message-ID: <20230702193815.1775684-5-sashal@kernel.org> (raw)
In-Reply-To: <20230702193815.1775684-1-sashal@kernel.org>
From: Prince Kumar Maurya <princekumarmaurya06@gmail.com>
[ Upstream commit ea2b62f305893992156a798f665847e0663c9f41 ]
sb_getblk(inode->i_sb, parent) return a null ptr and taking lock on
that leads to the null-ptr-deref bug.
Reported-by: syzbot+aad58150cbc64ba41bdc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=aad58150cbc64ba41bdc
Signed-off-by: Prince Kumar Maurya <princekumarmaurya06@gmail.com>
Message-Id: <20230531013141.19487-1-princekumarmaurya06@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/sysv/itree.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index b22764fe669c8..58d7f43a13712 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -145,6 +145,10 @@ static int alloc_branch(struct inode *inode,
*/
parent = block_to_cpu(SYSV_SB(inode->i_sb), branch[n-1].key);
bh = sb_getblk(inode->i_sb, parent);
+ if (!bh) {
+ sysv_free_block(inode->i_sb, branch[n].key);
+ break;
+ }
lock_buffer(bh);
memset(bh->b_data, 0, blocksize);
branch[n].bh = bh;
--
2.39.2
next prev parent reply other threads:[~2023-07-02 19:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-02 19:38 [PATCH AUTOSEL 6.4 01/16] vfs: Replace all non-returning strlcpy with strscpy Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 02/16] coredump: require O_WRONLY instead of O_RDWR Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 03/16] fs: use UB-safe check for signed addition overflow in remap_verify_area Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 04/16] ntfs: do not dereference a null ctx on error Sasha Levin
2023-07-02 19:38 ` Sasha Levin [this message]
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 06/16] jfs: Use unsigned variable for length calculations Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 07/16] fs: Protect reconfiguration of sb read-write from racing writes Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 08/16] s390/kasan: avoid short by one page shadow memory Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 09/16] s390/crash: use the correct type for memory allocation Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 10/16] s390/boot: fix physmem_info virtual vs physical address confusion Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 11/16] fs: use correct __poll_t type Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 12/16] fs.h: Optimize file struct to prevent false sharing Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 13/16] fs: unexport buffer_check_dirty_writeback Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 14/16] eventfd: show the EFD_SEMAPHORE flag in fdinfo Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 15/16] autofs: set ctime as well when mtime changes on a dir Sasha Levin
2023-07-02 19:38 ` [PATCH AUTOSEL 6.4 16/16] fs: Provide helpers for manipulating sb->s_readonly_remount Sasha Levin
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=20230702193815.1775684-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=brauner@kernel.org \
--cc=chenzhongjin@huawei.com \
--cc=dchinner@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=princekumarmaurya06@gmail.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+aad58150cbc64ba41bdc@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
/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