Skip to contentSkip to conversation

btrfs: fix 64bit compat send ioctl arguments not initializing version member

PATCH In review David Sterba 3 participants 3 messages Nov 24, 2023

Subsystems (2)
lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

PATCH 1/1 btrfs: fix 64bit compat send ioctl arguments not initializing version member

When the send protocol versioning was added in 5.16 e77fbf990316 ("btrfs: send: prepare for v2 protocol"), the 32/64bit compat code was not updated (added by 2351f431f727 ("btrfs: fix send ioctl on 32bit with 64bit kernel")), missing the version struct member. The compat code is probably rarely used, nobody reported any bugs.

Found by tool https://github.com/jirislaby/clang-struct .

Fixes 2351f431f727 ("btrfs: fix send ioctl on 32bit with 64bit kernel")
---
 fs/btrfs/ioctl.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/ioctl.c +1 -0
index dfe257e1845b..4e50b62db2a8 100644
@@ -4356,6 +4356,7 @@ static int _btrfs_ioctl_send(struct inode *inode, void __user *argp, bool compat
 		arg->clone_sources = compat_ptr(args32.clone_sources);
 		arg->parent_root = args32.parent_root;
 		arg->flags = args32.flags;
+		arg->version = args32.version;
 		memcpy(arg->reserved, args32.reserved,
 		       sizeof(args32.reserved));
 #else
Signature · 1 line
2.42.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · David Sterba

When the send protocol versioning was added in 5.16 e77fbf990316 ("btrfs: send: prepare for v2 protocol"), the 32/64bit compat code was not updated (added by 2351f431f727 ("btrfs: fix send ioctl on 32bit with 64bit kernel")), missing the version struct member. The compat code is probably rarely used, nobody reported any bugs.

Found by tool https://github.com/jirislaby/clang-struct .

Fixes 2351f431f727 ("btrfs: fix send ioctl on 32bit with 64bit kernel")

So this is not the correct commit, you copy-pasted the wrong one from the change log above, it should be:

e77fbf990316 ("btrfs: send: prepare for v2 protocol")

With that fixed:

Thanks.

Quoted 22 lines
---
 fs/btrfs/ioctl.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/ioctl.c +1 -1
index dfe257e1845b..4e50b62db2a8 100644
@@ -4356,6 +4356,7 @@ static int _btrfs_ioctl_send(struct inode *inode, void __user *argp, bool compat
                arg->clone_sources = compat_ptr(args32.clone_sources);
                arg->parent_root = args32.parent_root;
                arg->flags = args32.flags;
+               arg->version = args32.version;
                memcpy(arg->reserved, args32.reserved,
                       sizeof(args32.reserved));
 #else
--

2.42.1

#2 lore raw
Quoted 8 lines · Filipe Manana
Quoted 7 lines · David Sterba

When the send protocol versioning was added in 5.16 e77fbf990316 ("btrfs: send: prepare for v2 protocol"), the 32/64bit compat code was not updated (added by 2351f431f727 ("btrfs: fix send ioctl on 32bit with 64bit kernel")), missing the version struct member. The compat code is probably rarely used, nobody reported any bugs.

Quoted 8 lines
Quoted 3 lines

Found by tool https://github.com/jirislaby/clang-struct .

Fixes 2351f431f727 ("btrfs: fix send ioctl on 32bit with 64bit kernel")

So this is not the correct commit, you copy-pasted the wrong one from the change log above, it should be:

e77fbf990316 ("btrfs: send: prepare for v2 protocol")

Of course, fixed, thanks.