[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230531013141.19487-1-princekumarmaurya06@gmail.com>
Date: Tue, 30 May 2023 18:31:41 -0700
From: Prince Kumar Maurya <princekumarmaurya06@...il.com>
To: skhan@...uxfoundation.org, brauner@...nel.org, dchinner@...hat.com,
viro@...iv.linux.org.uk, chenzhongjin@...wei.com
Cc: Prince Kumar Maurya <princekumarmaurya06@...il.com>,
linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
syzkaller-bugs@...glegroups.com, linux-fsdevel@...r.kernel.org,
syzbot+aad58150cbc64ba41bdc@...kaller.appspotmail.com
Subject: [PATCH v4] fs/sysv: Null check to prevent null-ptr-deref bug
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@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=aad58150cbc64ba41bdc
Signed-off-by: Prince Kumar Maurya <princekumarmaurya06@...il.com>
---
Change since v3: Added cleanup code for the branch[n].key on
failure code path.
fs/sysv/itree.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index b22764fe669c..58d7f43a1371 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.40.1
Powered by blists - more mailing lists