Skip to content

Commit 522f6e6

Browse files
amir73ilMiklos Szeredi
authored andcommitted
ovl: fix out of bounds access warning in ovl_check_fb_len()
syzbot reported out of bounds memory access from open_by_handle_at() with a crafted file handle that looks like this: { .handle_bytes = 2, .handle_type = OVL_FILEID_V1 } handle_bytes gets rounded down to 0 and we end up calling: ovl_check_fh_len(fh, 0) => ovl_check_fb_len(fh + 3, -3) But fh buffer is only 2 bytes long, so accessing struct ovl_fb at fh + 3 is illegal. Fixes: cbe7fba ("ovl: make sure that real fid is 32bit aligned in memory") Reported-and-tested-by: [email protected] Cc: <[email protected]> # v5.5 Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 144da23 commit 522f6e6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/overlayfs/overlayfs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ int ovl_check_fb_len(struct ovl_fb *fb, int fb_len);
355355

356356
static inline int ovl_check_fh_len(struct ovl_fh *fh, int fh_len)
357357
{
358+
if (fh_len < sizeof(struct ovl_fh))
359+
return -EINVAL;
360+
358361
return ovl_check_fb_len(&fh->fb, fh_len - OVL_FH_WIRE_OFFSET);
359362
}
360363

0 commit comments

Comments
 (0)