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] [day] [month] [year] [list]
Message-ID: <1840126.tdWV9SEqCh@suse>
Date:   Wed, 04 Jan 2023 14:02:30 +0100
From:   "Fabio M. De Francesco" <fmdefrancesco@...il.com>
To:     Dan Carpenter <error27@...il.com>
Cc:     oe-kbuild@...ts.linux.dev, Christoph Hellwig <hch@...radead.org>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
        Ira Weiny <ira.weiny@...el.com>,
        Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH 2/4] fs/sysv: Change the signature of dir_get_page()

On mercoledì 4 gennaio 2023 12:59:24 CET Dan Carpenter wrote:
> Hi Fabio,
> 
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:   
> https://github.com/intel-lab-lkp/linux/commits/Fabio-M-De-Francesco/fs-sysv-U
> se-the-offset_in_page-helper/20221231-155850 base:  
> git://git.infradead.org/users/hch/configfs.git for-next
> patch link:   
> https://lore.kernel.org/r/20221231075717.10258-3-fmdefrancesco%40gmail.com
> patch subject: [PATCH 2/4] fs/sysv: Change the signature of dir_get_page()
> config: xtensa-randconfig-m031-20230101
> compiler: xtensa-linux-gcc (GCC) 12.1.0
> 
> If you fix the issue, kindly add following tag where applicable
> 
> | Reported-by: kernel test robot <lkp@...el.com>
> | Reported-by: Dan Carpenter <error27@...il.com>
> 
> smatch warnings:
> fs/sysv/dir.c:190 sysv_add_link() warn: passing zero to 'PTR_ERR'
> 
> vim +/PTR_ERR +190 fs/sysv/dir.c
> 
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  174  int 
sysv_add_link(struct
> dentry *dentry, struct inode *inode) ^1da177e4c3f41 Linus Torvalds       
> 2005-04-16  175  {
> 2b0143b5c986be David Howells         2015-03-17  176  	struct inode *dir 
=
> d_inode(dentry->d_parent); ^1da177e4c3f41 Linus Torvalds        2005-04-16 
> 177  	const char * name = dentry->d_name.name; ^1da177e4c3f41 Linus 
Torvalds 
>       2005-04-16  178  	int namelen = dentry->d_name.len; 
^1da177e4c3f41
> Linus Torvalds        2005-04-16  179  	struct page *page = NULL;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  180  	struct 
sysv_dir_entry
> * de; ^1da177e4c3f41 Linus Torvalds        2005-04-16  181  	
unsigned long
> npages = dir_pages(dir); ^1da177e4c3f41 Linus Torvalds        2005-04-16  
182
>  	unsigned long n; ^1da177e4c3f41 Linus Torvalds        2005-04-16  
183 
> 	char *kaddr;
> 26a6441aadde86 Nicholas Piggin       2007-10-16  184  	loff_t pos;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  185  	int err;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  186
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  187  	/* We take care 
of
> directory expansion in the same loop */ ^1da177e4c3f41 Linus Torvalds       
> 2005-04-16  188  	for (n = 0; n <= npages; n++) { 4b8a9c0afda16b Fabio M. De
> Francesco 2022-12-31  189  		kaddr = dir_get_page(dir, n, &page);
> ^1da177e4c3f41 Linus Torvalds        2005-04-16 @190  		err = 
PTR_ERR(page);
> 
> This "err" assignment is a dead store (pointless/never used).

Hi Dan,

Thanks for catching it.
I'll wait for comments on this series one or two more days and then delete 
that assignment.

Again thanks,

Fabio

> 4b8a9c0afda16b Fabio M. De Francesco 2022-12-31  191  		if 
(IS_ERR(kaddr))
> 4b8a9c0afda16b Fabio M. De Francesco 2022-12-31  192  			
return
> PTR_ERR(kaddr); ^1da177e4c3f41 Linus Torvalds        2005-04-16  193  	
	de =
> (struct sysv_dir_entry *)kaddr; 09cbfeaf1a5a67 Kirill A. Shutemov   
> 2016-04-01  194  		kaddr += PAGE_SIZE - SYSV_DIRSIZE; 
^1da177e4c3f41 Linus
> Torvalds        2005-04-16  195  		while ((char *)de <= kaddr) 
{
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  196  			
if (!de->inode)
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  197  			
	goto got_it;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  198  			
err = -EEXIST;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  199  			
if
> (namecompare(namelen, SYSV_NAMELEN, name, de->name)) ^1da177e4c3f41 Linus
> Torvalds        2005-04-16  200  				goto 
out_page; ^1da177e4c3f41 Linus
> Torvalds        2005-04-16  201  			de++;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  202  		}
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  203  		
dir_put_page(page);
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  204  	}
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  205  	BUG();
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  206  	return -EINVAL;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  207
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  208  got_it:
> 1023904333f9cb Fabio M. De Francesco 2022-12-31  209  	pos = 
page_offset(page)
> + offset_in_page(de); ^1da177e4c3f41 Linus Torvalds        2005-04-16  210 
> 	lock_page(page); f4e420dc423148 Christoph Hellwig     2010-06-04  
211  	err
> = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); ^1da177e4c3f41 Linus Torvalds 
>       2005-04-16  212  	if (err)
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  213  		goto 
out_unlock;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  214  	memcpy (de->name, 
name,
> namelen); ^1da177e4c3f41 Linus Torvalds        2005-04-16  215  	memset
> (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2); ^1da177e4c3f41 Linus
> Torvalds        2005-04-16  216  	de->inode =
> cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); 26a6441aadde86 Nicholas
> Piggin       2007-10-16  217  	err = dir_commit_chunk(page, pos,
> SYSV_DIRSIZE); 02027d42c3f747 Deepa Dinamani        2016-09-14  218 
> 	dir->i_mtime = dir->i_ctime = current_time(dir); ^1da177e4c3f41 
Linus
> Torvalds        2005-04-16  219  	mark_inode_dirty(dir); ^1da177e4c3f41 
Linus
> Torvalds        2005-04-16  220  out_page:
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  221  	
dir_put_page(page);
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  222  	return err;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  223  out_unlock:
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  224  	
unlock_page(page);
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  225  	goto out_page;
> ^1da177e4c3f41 Linus Torvalds        2005-04-16  226  }
> 
> --
> 0-DAY CI Kernel Test Service
> https://01.org/lkp




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ