lkml.org 
[lkml]   [2023]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] FS: JFS: Fix null-ptr-deref Read in txBegin
From
On 6/23/23 8:44AM, mirimmad@outlook.com wrote:
> From: Immad Mir <mirimmad17@gmail.com>
>
> Syzkaller reported an issue where txBegin may be called
> on a superblock in a read-only mounted filesystem which leads
> to NULL pointer deref. This could be solved by checking if
> the filesystem is read-only before calling txBegin, and returning
> with appropiate error code.

Looks good. I'm going to change it to just an if clause without the else
and push it to jfs-next.

Thanks,
>
> Reported-By: syzbot+f1faa20eec55e0c8644c@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?id=be7e52c50c5182cc09a09ea6fc456446b2039de3
>
> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
> ---
> fs/jfs/namei.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index b29d68b5e..12e95431c 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -798,8 +798,13 @@ static int jfs_link(struct dentry *old_dentry,
> rc = dquot_initialize(dir);
> if (rc)
> goto out;
> -
> - tid = txBegin(ip->i_sb, 0);
> + if (!isReadOnly(ip)) {
> + tid = txBegin(ip->i_sb, 0);
> + } else {
> + jfs_error(ip->i_sb, "read-only filesystem\n");
> + rc = -EROFS;
> + goto out;
> + }
>
> mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT);
> mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD);
> --
> 2.40.0
>

\
 
 \ /
  Last update: 2023-06-23 15:52    [W:0.452 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site