All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: fs/exec.c:745 transfer_args_to_stack() error: buffer overflow 'bprm->page' 32 <= 32
Date: Tue, 28 Jul 2026 18:42:07 +0800	[thread overview]
Message-ID: <202607281823.Th3aUv95-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Christian Brauner <brauner@kernel.org>
CC: "David Hildenbrand (Arm)" <david@kernel.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   62cc90241548d5570ee68e01aaba6506964e9811
commit: 16cc4f5c1c4b9e45eca7f7deefa5410a292db599 exec: fix unsigned loop counter wrap in transfer_args_to_stack()
date:   7 days ago
:::::: branch date: 13 hours ago
:::::: commit date: 7 days ago
config: arm-randconfig-r072-20260728 (https://download.01.org/0day-ci/archive/20260728/202607281823.Th3aUv95-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.5.0
smatch: v0.5.0-9187-g5189e3fb

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: 16cc4f5c1c4b ("exec: fix unsigned loop counter wrap in transfer_args_to_stack()")
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202607281823.Th3aUv95-lkp@intel.com/

smatch warnings:
fs/exec.c:745 transfer_args_to_stack() error: buffer overflow 'bprm->page' 32 <= 32

vim +745 fs/exec.c

7e7ec6a934349ef Nicolas Pitre         2016-07-24  729  
7e7ec6a934349ef Nicolas Pitre         2016-07-24  730  /*
7e7ec6a934349ef Nicolas Pitre         2016-07-24  731   * Transfer the program arguments and environment from the holding pages
7e7ec6a934349ef Nicolas Pitre         2016-07-24  732   * onto the stack. The provided stack pointer is adjusted accordingly.
7e7ec6a934349ef Nicolas Pitre         2016-07-24  733   */
7e7ec6a934349ef Nicolas Pitre         2016-07-24  734  int transfer_args_to_stack(struct linux_binprm *bprm,
7e7ec6a934349ef Nicolas Pitre         2016-07-24  735  			   unsigned long *sp_location)
7e7ec6a934349ef Nicolas Pitre         2016-07-24  736  {
7e7ec6a934349ef Nicolas Pitre         2016-07-24  737  	unsigned long index, stop, sp;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  738  	int ret = 0;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  739  
7e7ec6a934349ef Nicolas Pitre         2016-07-24  740  	stop = bprm->p >> PAGE_SHIFT;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  741  	sp = *sp_location;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  742  
16cc4f5c1c4b9e4 Christian Brauner     2026-07-21  743  	for (index = MAX_ARG_PAGES; index-- > stop; ) {
7e7ec6a934349ef Nicolas Pitre         2016-07-24  744  		unsigned int offset = index == stop ? bprm->p & ~PAGE_MASK : 0;
3a608cfee97e99b Fabio M. De Francesco 2022-08-03 @745  		char *src = kmap_local_page(bprm->page[index]) + offset;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  746  		sp -= PAGE_SIZE - offset;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  747  		if (copy_to_user((void *) sp, src, PAGE_SIZE - offset) != 0)
7e7ec6a934349ef Nicolas Pitre         2016-07-24  748  			ret = -EFAULT;
3a608cfee97e99b Fabio M. De Francesco 2022-08-03  749  		kunmap_local(src);
7e7ec6a934349ef Nicolas Pitre         2016-07-24  750  		if (ret)
7e7ec6a934349ef Nicolas Pitre         2016-07-24  751  			goto out;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  752  	}
7e7ec6a934349ef Nicolas Pitre         2016-07-24  753  
2aea94ac14d1e0a Max Filippov          2024-03-20  754  	bprm->exec += *sp_location - MAX_ARG_PAGES * PAGE_SIZE;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  755  	*sp_location = sp;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  756  
7e7ec6a934349ef Nicolas Pitre         2016-07-24  757  out:
7e7ec6a934349ef Nicolas Pitre         2016-07-24  758  	return ret;
7e7ec6a934349ef Nicolas Pitre         2016-07-24  759  }
7e7ec6a934349ef Nicolas Pitre         2016-07-24  760  EXPORT_SYMBOL(transfer_args_to_stack);
7e7ec6a934349ef Nicolas Pitre         2016-07-24  761  

:::::: The code at line 745 was first introduced by commit
:::::: 3a608cfee97e99b3fff9ffe62246a098042e725d exec: Replace kmap{,_atomic}() with kmap_local_page()

:::::: TO: Fabio M. De Francesco <fmdefrancesco@gmail.com>
:::::: CC: Kees Cook <keescook@chromium.org>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2026-07-28 10:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202607281823.Th3aUv95-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.