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]
Date:   Tue, 18 May 2021 18:19:24 +0530
From:   Faiyaz Mohammed <faiyazm@...eaurora.org>
To:     Dan Carpenter <dan.carpenter@...cle.com>, kbuild@...ts.01.org,
        cl@...ux.com, penberg@...nel.org, rientjes@...gle.com,
        iamjoonsoo.kim@....com, akpm@...ux-foundation.org, vbabka@...e.cz,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org, glittao@...il.com
Cc:     lkp@...el.com, kbuild-all@...ts.01.org, vinmenon@...eaurora.org
Subject: Re: [PATCH v5] mm: slub: move sysfs slab alloc/free interfaces to
 debugfs

Hi,

Updated in the patch,
https://lore.kernel.org/linux-mm/1621341949-26762-1-git-send-email-faiyazm@codeaurora.org/T/#u

Thanks and regards,
Mohammed Faiyaz

On 5/7/2021 10:51 AM, Dan Carpenter wrote:
> Hi Faiyaz,
> 
> url:    https://github.com/0day-ci/linux/commits/Faiyaz-Mohammed/mm-slub-move-sysfs-slab-alloc-free-interfaces-to-debugfs/20210506-182420
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8404c9fbc84b741f66cff7d4934a25dd2c344452
> config: i386-randconfig-m021-20210506 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@...el.com>
> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
> 
> smatch warnings:
> mm/slub.c:5891 slab_debugfs_start() warn: possible memory leak of 'spos'
> 
> vim +/spos +5891 mm/slub.c
> 
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5877  static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos)
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5878  {
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5879  	struct kmem_cache_node *n;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5880  	struct kmem_cache *s;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5881  	enum track_item alloc;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5882  	int node;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5883  	loff_t *spos = kmalloc(sizeof(loff_t), GFP_KERNEL);
>                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Generally avoid putting functions which can fail in the declaration
> block.  Allocations inside the declaration block are a tiny percent of
> declarations over all but they are an outsize source of static checker
> bugs.
> 
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5884  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5885  	s = seq->file->f_inode->i_private;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5886  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5887  	if (!spos)
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5888  		return NULL;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5889  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5890  	if (!(s->flags & SLAB_STORE_USER))
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06 @5891  		return ERR_PTR(-EOPNOTSUPP);
> 
> "spos" is leaked.
> 
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5892  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5893  	if (*ppos == 0) {
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5894  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5895  		t.count = 0;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5896  		t.max = 0;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5897  		t.loc = NULL;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5898  		if (strcmp(seq->file->f_path.dentry->d_name.name, "alloc_traces") == 0)
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5899  			alloc =  TRACK_ALLOC;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5900  		else
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5901  			alloc =  TRACK_FREE;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5902  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5903  		if (!alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location),
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5904  			     GFP_KERNEL)) {
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5905  			seq_puts(seq, "Out of memory\n");
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5906  			return ERR_PTR(-ENOMEM);
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5907  		}
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5908  		/* Push back cpu slabs */
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5909  		flush_all(s);
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5910  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5911  		for_each_kmem_cache_node(s, node, n) {
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5912  			unsigned long flags;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5913  			struct page *page;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5914  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5915  			if (!atomic_long_read(&n->nr_slabs))
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5916  				continue;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5917  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5918  			spin_lock_irqsave(&n->list_lock, flags);
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5919  			list_for_each_entry(page, &n->partial, slab_list)
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5920  				process_slab(&t, s, page, alloc);
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5921  			list_for_each_entry(page, &n->full, slab_list)
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5922  				process_slab(&t, s, page, alloc);
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5923  			spin_unlock_irqrestore(&n->list_lock, flags);
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5924  		}
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5925  	}
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5926  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5927  	if (*ppos < t.count) {
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5928  		*spos = *ppos;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5929  		return spos;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5930  	}
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5931  
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5932  	kfree(spos);
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5933  	return NULL;
> 88e180b99466c1 Faiyaz Mohammed 2021-05-06  5934  }
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ