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:   Sat, 12 Nov 2022 02:13:47 +0800
From:   kernel test robot <lkp@...el.com>
To:     Pedro Falcato <pedro.falcato@...il.com>, keescook@...omium.org,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org
Cc:     llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
        dalias@...c.org, ebiederm@...ssion.com, pedro.falcato@...il.com,
        sam@...too.org, viro@...iv.linux.org.uk
Subject: Re: [PATCH v3] fs/binfmt_elf: Fix memsz > filesz handling

Hi Pedro,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kees/for-next/pstore]
[also build test ERROR on kees/for-next/kspp linus/master v6.1-rc4]
[cannot apply to kees/for-next/execve next-20221111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pedro-Falcato/fs-binfmt_elf-Fix-memsz-filesz-handling/20221108-190918
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore
patch link:    https://lore.kernel.org/r/20221108110715.227062-1-pedro.falcato%40gmail.com
patch subject: [PATCH v3] fs/binfmt_elf: Fix memsz > filesz handling
config: x86_64-randconfig-a005
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/95d3dfbe2432d0980b6a71d396b1d2cebcc378b0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Pedro-Falcato/fs-binfmt_elf-Fix-memsz-filesz-handling/20221108-190918
        git checkout 95d3dfbe2432d0980b6a71d396b1d2cebcc378b0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

All errors (new ones prefixed by >>):

>> fs/binfmt_elf.c:1480:21: error: too few arguments to function call, expected 2, have 1
           if (padzero(elf_bss)) {
               ~~~~~~~        ^
   fs/binfmt_elf.c:117:12: note: 'padzero' declared here
   static int padzero(unsigned long elf_bss, unsigned long len)
              ^
   1 error generated.


vim +1480 fs/binfmt_elf.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  1415  
69369a7003735d Josh Triplett     2014-04-03  1416  #ifdef CONFIG_USELIB
^1da177e4c3f41 Linus Torvalds    2005-04-16  1417  /* This is really simpleminded and specialized - we are loading an
^1da177e4c3f41 Linus Torvalds    2005-04-16  1418     a.out library that is given an ELF header. */
^1da177e4c3f41 Linus Torvalds    2005-04-16  1419  static int load_elf_library(struct file *file)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1420  {
^1da177e4c3f41 Linus Torvalds    2005-04-16  1421  	struct elf_phdr *elf_phdata;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1422  	struct elf_phdr *eppnt;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1423  	unsigned long elf_bss, bss, len;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1424  	int retval, error, i, j;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1425  	struct elfhdr elf_ex;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1426  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1427  	error = -ENOEXEC;
658c0335651185 Alexey Dobriyan   2019-12-04  1428  	retval = elf_read(file, &elf_ex, sizeof(elf_ex), 0);
658c0335651185 Alexey Dobriyan   2019-12-04  1429  	if (retval < 0)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1430  		goto out;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1431  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1432  	if (memcmp(elf_ex.e_ident, ELFMAG, SELFMAG) != 0)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1433  		goto out;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1434  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1435  	/* First of all, some simple consistency checks */
^1da177e4c3f41 Linus Torvalds    2005-04-16  1436  	if (elf_ex.e_type != ET_EXEC || elf_ex.e_phnum > 2 ||
72c2d531920048 Al Viro           2013-09-22  1437  	    !elf_check_arch(&elf_ex) || !file->f_op->mmap)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1438  		goto out;
4755200b6b116d Nicolas Pitre     2017-08-16  1439  	if (elf_check_fdpic(&elf_ex))
4755200b6b116d Nicolas Pitre     2017-08-16  1440  		goto out;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1441  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1442  	/* Now read in all of the header information */
^1da177e4c3f41 Linus Torvalds    2005-04-16  1443  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1444  	j = sizeof(struct elf_phdr) * elf_ex.e_phnum;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1445  	/* j < ELF_MIN_ALIGN because elf_ex.e_phnum <= 2 */
^1da177e4c3f41 Linus Torvalds    2005-04-16  1446  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1447  	error = -ENOMEM;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1448  	elf_phdata = kmalloc(j, GFP_KERNEL);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1449  	if (!elf_phdata)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1450  		goto out;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1451  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1452  	eppnt = elf_phdata;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1453  	error = -ENOEXEC;
658c0335651185 Alexey Dobriyan   2019-12-04  1454  	retval = elf_read(file, eppnt, j, elf_ex.e_phoff);
658c0335651185 Alexey Dobriyan   2019-12-04  1455  	if (retval < 0)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1456  		goto out_free_ph;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1457  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1458  	for (j = 0, i = 0; i<elf_ex.e_phnum; i++)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1459  		if ((eppnt + i)->p_type == PT_LOAD)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1460  			j++;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1461  	if (j != 1)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1462  		goto out_free_ph;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1463  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1464  	while (eppnt->p_type != PT_LOAD)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1465  		eppnt++;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1466  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1467  	/* Now use mmap to map the library into memory. */
6be5ceb02e98ea Linus Torvalds    2012-04-20  1468  	error = vm_mmap(file,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1469  			ELF_PAGESTART(eppnt->p_vaddr),
^1da177e4c3f41 Linus Torvalds    2005-04-16  1470  			(eppnt->p_filesz +
^1da177e4c3f41 Linus Torvalds    2005-04-16  1471  			 ELF_PAGEOFFSET(eppnt->p_vaddr)),
^1da177e4c3f41 Linus Torvalds    2005-04-16  1472  			PROT_READ | PROT_WRITE | PROT_EXEC,
42be8b42535183 David Hildenbrand 2021-04-22  1473  			MAP_FIXED_NOREPLACE | MAP_PRIVATE,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1474  			(eppnt->p_offset -
^1da177e4c3f41 Linus Torvalds    2005-04-16  1475  			 ELF_PAGEOFFSET(eppnt->p_vaddr)));
^1da177e4c3f41 Linus Torvalds    2005-04-16  1476  	if (error != ELF_PAGESTART(eppnt->p_vaddr))
^1da177e4c3f41 Linus Torvalds    2005-04-16  1477  		goto out_free_ph;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1478  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1479  	elf_bss = eppnt->p_vaddr + eppnt->p_filesz;
^1da177e4c3f41 Linus Torvalds    2005-04-16 @1480  	if (padzero(elf_bss)) {
^1da177e4c3f41 Linus Torvalds    2005-04-16  1481  		error = -EFAULT;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1482  		goto out_free_ph;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1483  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1484  
24962af7e1041b Oscar Salvador    2018-07-13  1485  	len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr);
24962af7e1041b Oscar Salvador    2018-07-13  1486  	bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr);
ecc2bc8ac03884 Michal Hocko      2016-05-23  1487  	if (bss > len) {
ecc2bc8ac03884 Michal Hocko      2016-05-23  1488  		error = vm_brk(len, bss - len);
5d22fc25d4fc80 Linus Torvalds    2016-05-27  1489  		if (error)
ecc2bc8ac03884 Michal Hocko      2016-05-23  1490  			goto out_free_ph;
ecc2bc8ac03884 Michal Hocko      2016-05-23  1491  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1492  	error = 0;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1493  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1494  out_free_ph:
^1da177e4c3f41 Linus Torvalds    2005-04-16  1495  	kfree(elf_phdata);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1496  out:
^1da177e4c3f41 Linus Torvalds    2005-04-16  1497  	return error;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1498  }
69369a7003735d Josh Triplett     2014-04-03  1499  #endif /* #ifdef CONFIG_USELIB */
^1da177e4c3f41 Linus Torvalds    2005-04-16  1500  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (141180 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ