btrfs-progs: receive: fix parsing of attributes field from the fileattr command

We're trying to get a U32 for the attributes, but the kernel sends a U64
(which is correct as we store attributes in a u64 flags field of the
inode). This makes anyone trying to receive a v2 send stream to fail with:

    ERROR: invalid size for attribute, expected = 4, got = 8

We actually recently got such a report of someone using send stream v2 and
getting such failure. See the Link tag below.

Link: https://lore.kernel.org/linux-btrfs/6cb11fa5-c60d-e65b-0295-301a694e66ad@inbox.ru/
Fixes: 7a6fb356dc ("btrfs-progs: receive: process setflags ioctl commands")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana 2022-11-03 16:53:26 +00:00 committed by David Sterba
parent 4286eb552e
commit 60b920d618

View File

@ -570,7 +570,7 @@ static int read_and_process_cmd(struct btrfs_send_stream *sctx)
break;
case BTRFS_SEND_C_FILEATTR:
TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, &path);
TLV_GET_U32(sctx, BTRFS_SEND_A_FILEATTR, &fileattr);
TLV_GET_U64(sctx, BTRFS_SEND_A_FILEATTR, &fileattr);
ret = sctx->ops->fileattr(path, fileattr, sctx->user);
break;
}