Skip to content

Commit

Permalink
udf: Fix NULL pointer dereference in udf_symlink function
Browse files Browse the repository at this point in the history
In function udf_symlink, epos.bh is assigned with the value returned
by udf_tgetblk. The function udf_tgetblk is defined in udf/misc.c
and returns the value of sb_getblk function that could be NULL.
Then, epos.bh is used without any check, causing a possible
NULL pointer dereference when sb_getblk fails.

This fix adds a check to validate the value of epos.bh.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=213083
Signed-off-by: Arturo Giusti <koredump@protonmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Arturo Giusti authored and Jan Kara committed May 20, 2021
1 parent a149127 commit fa236c2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/udf/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,10 @@ static int udf_symlink(struct user_namespace *mnt_userns, struct inode *dir,
iinfo->i_location.partitionReferenceNum,
0);
epos.bh = udf_tgetblk(sb, block);
if (unlikely(!epos.bh)) {
err = -ENOMEM;
goto out_no_entry;
}
lock_buffer(epos.bh);
memset(epos.bh->b_data, 0x00, bsize);
set_buffer_uptodate(epos.bh);
Expand Down

0 comments on commit fa236c2

Please sign in to comment.