Skip to content

Commit

Permalink
Btrfs: limit the path size in send to PATH_MAX
Browse files Browse the repository at this point in the history
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 <clm@fb.com>
  • Loading branch information
Chris Mason committed Apr 26, 2014
1 parent f8213bd commit cfd4a53
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/btrfs/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
if (p->buf_len >= len)
return 0;

if (len > PATH_MAX) {
WARN_ON(1);
return -ENOMEM;
}

path_len = p->end - p->start;
old_buf_len = p->buf_len;

Expand Down

0 comments on commit cfd4a53

Please sign in to comment.