lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <885129e4-d6d6-57d3-21d3-a83bd98c3994@suse.com>
Date:   Sun, 5 Jul 2020 17:48:17 +0300
From:   Nikolay Borisov <nborisov@...e.com>
To:     trix@...hat.com, clm@...com, josef@...icpanda.com, dsterba@...e.com
Cc:     linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btfrs: initialize return of btrfs_extent_same



On 5.07.20 г. 17:20 ч., trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.com>
> 
> clang static analysis flags a garbage return
> 
> fs/btrfs/reflink.c:611:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
>         return ret;
>         ^~~~~~~~~~
> ret will not be set when olen is 0
> When olen is 0, this function does no work.
> 
> So initialize ret to 0
> 
> Signed-off-by: Tom Rix <trix@...hat.com>

Patch itself is good however, the bug cannot currently be triggered, due
to the following code in the sole caller (btrfs_remap_file_range):



   15         if (ret < 0 || len == 0)

   14                 goto out_unlock;

   13

   12         if (remap_flags & REMAP_FILE_DEDUP)

   11                 ret = btrfs_extent_same(src_inode, off, len,
dst_inode, destoff);
   10         else

    9                 ret = btrfs_clone_files(dst_file, src_file, off,
len, destoff);



i.e len is guaranteed to be non-zero

> ---
>  fs/btrfs/reflink.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
> index 040009d1cc31..200a80fcbecb 100644
> --- a/fs/btrfs/reflink.c
> +++ b/fs/btrfs/reflink.c
> @@ -572,7 +572,7 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,
>  static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
>  			     struct inode *dst, u64 dst_loff)
>  {
> -	int ret;
> +	int ret = 0;
>  	u64 i, tail_len, chunk_count;
>  	struct btrfs_root *root_dst = BTRFS_I(dst)->root;
>  
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ