On 2020/1/31 上午10:08, Zygo Blaxell wrote:
> LOGICAL_INO v1 ignored the reserved fields, so they could be filled
> with random stack garbage and have no effect. LOGICAL_INO_V2 requires
> all unused reserved bits to be set to zero, and returns EINVAL if they
> are not, to guard against future kernel versions which may interpret
> non-zero bit values.
>
> Sometimes when 'btrfs ins log' runs, the stack garbage is zeros, so the
> -o (ignore offsets) option for logical-resolve works. Sometimes the
> stack garbage is something else, and 'btrfs ins log -o' fails with
> invalid argument. This depends mostly on compiler version and build
> environment details, so a binary typically either always works or never
> works.
>
> Fix by initializing logical-resolve's argument structure with a C99
> compound literal zero.
>
> Signed-off-by: Zygo Blaxell <ce3g8jdj@xxxxxxxxxxxxxxxxxxxxx>
Reviewed-by: Qu Wenruo <wqu@xxxxxxxx>
Thanks,
Qu
> ---
> cmds/inspect.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cmds/inspect.c b/cmds/inspect.c
> index 9ca78611..5b946da0 100644
> --- a/cmds/inspect.c
> +++ b/cmds/inspect.c
> @@ -149,7 +149,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
> int verbose = 0;
> int getpath = 1;
> int bytes_left;
> - struct btrfs_ioctl_logical_ino_args loi;
> + struct btrfs_ioctl_logical_ino_args loi = { 0 };
> struct btrfs_data_container *inodes;
> u64 size = SZ_64K;
> char full_path[PATH_MAX];
>
Attachment:
signature.asc
Description: OpenPGP digital signature
