Skip to content

Commit cfd4a53

Browse files
committed
Btrfs: limit the path size in send to PATH_MAX
fs_path_ensure_buf is used to make sure our path buffers for send are big enough for the path names as we construct them. The buffer size is limited to 32K by the length field in the struct. But bugs in the path construction can end up trying to build a huge buffer, and we'll do invalid memmmoves when the buffer length field wraps. This patch is step one, preventing the overflows. Signed-off-by: Chris Mason <[email protected]>
1 parent f8213bd commit cfd4a53

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/btrfs/send.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
349349
if (p->buf_len >= len)
350350
return 0;
351351

352+
if (len > PATH_MAX) {
353+
WARN_ON(1);
354+
return -ENOMEM;
355+
}
356+
352357
path_len = p->end - p->start;
353358
old_buf_len = p->buf_len;
354359

0 commit comments

Comments
 (0)