On Sun, Oct 10, 2021 at 8:52 PM kernel test robot wrote: > > Hi Yafang, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on linus/master] > [also build test WARNING on kees/for-next/pstore v5.15-rc4 next-20211008] > [cannot apply to tip/sched/core] > [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] > > url: https://github.com/0day-ci/linux/commits/Yafang-Shao/task_struct-extend-task-comm-from-16-to-24-for-CONFIG_BASE_FULL/20211010-182548 > base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 7fd2bf83d59a2d32e0d596c5d3e623b9a0e7e2d5 > config: ia64-defconfig (attached as .config) > compiler: ia64-linux-gcc (GCC) 11.2.0 > 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/0day-ci/linux/commit/317419b91ef4eff4e2f046088201e4dc4065caa0 > git remote add linux-review https://github.com/0day-ci/linux > git fetch --no-tags linux-review Yafang-Shao/task_struct-extend-task-comm-from-16-to-24-for-CONFIG_BASE_FULL/20211010-182548 > git checkout 317419b91ef4eff4e2f046088201e4dc4065caa0 > # save the attached .config to linux build tree > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > Thanks for the report! > All warnings (new ones prefixed by >>): > > fs/binfmt_elf.c: In function 'fill_psinfo.isra': > >> fs/binfmt_elf.c:1575:9: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 23 [-Wstringop-truncation] > 1575 | strncpy(psinfo->pr_fname, p->comm, sizeof(psinfo->pr_fname)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > It seems that we'd better make below change, --- a/include/linux/elfcore.h +++ b/include/linux/elfcore.h @@ -65,7 +65,7 @@ struct elf_prpsinfo __kernel_gid_t pr_gid; pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; /* Lots missing */ - char pr_fname[16]; /* filename of executable */ + char pr_fname[TASK_COMM_LEN]; /* filename of executable */ char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ }; I will analyze it in depth whether we can safely make this change. > > vim +/strncpy +1575 fs/binfmt_elf.c > > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1534 > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1535 static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1536 struct mm_struct *mm) > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1537 { > c69e8d9c01db2a David Howells 2008-11-14 1538 const struct cred *cred; > a84a505956f5c7 Greg Kroah-Hartman 2005-05-11 1539 unsigned int i, len; > 2f064a59a11ff9 Peter Zijlstra 2021-06-11 1540 unsigned int state; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1541 > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1542 /* first copy the parameters from user space */ > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1543 memset(psinfo, 0, sizeof(struct elf_prpsinfo)); > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1544 > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1545 len = mm->arg_end - mm->arg_start; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1546 if (len >= ELF_PRARGSZ) > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1547 len = ELF_PRARGSZ-1; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1548 if (copy_from_user(&psinfo->pr_psargs, > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1549 (const char __user *)mm->arg_start, len)) > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1550 return -EFAULT; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1551 for(i = 0; i < len; i++) > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1552 if (psinfo->pr_psargs[i] == 0) > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1553 psinfo->pr_psargs[i] = ' '; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1554 psinfo->pr_psargs[len] = 0; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1555 > 3b34fc5880a2dc Oleg Nesterov 2009-06-17 1556 rcu_read_lock(); > 3b34fc5880a2dc Oleg Nesterov 2009-06-17 1557 psinfo->pr_ppid = task_pid_vnr(rcu_dereference(p->real_parent)); > 3b34fc5880a2dc Oleg Nesterov 2009-06-17 1558 rcu_read_unlock(); > b488893a390edf Pavel Emelyanov 2007-10-18 1559 psinfo->pr_pid = task_pid_vnr(p); > b488893a390edf Pavel Emelyanov 2007-10-18 1560 psinfo->pr_pgrp = task_pgrp_vnr(p); > b488893a390edf Pavel Emelyanov 2007-10-18 1561 psinfo->pr_sid = task_session_vnr(p); > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1562 > 2f064a59a11ff9 Peter Zijlstra 2021-06-11 1563 state = READ_ONCE(p->__state); > 2f064a59a11ff9 Peter Zijlstra 2021-06-11 1564 i = state ? ffz(~state) + 1 : 0; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1565 psinfo->pr_state = i; > 55148548124e3e Carsten Otte 2006-03-25 1566 psinfo->pr_sname = (i > 5) ? '.' : "RSDTZW"[i]; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1567 psinfo->pr_zomb = psinfo->pr_sname == 'Z'; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1568 psinfo->pr_nice = task_nice(p); > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1569 psinfo->pr_flag = p->flags; > c69e8d9c01db2a David Howells 2008-11-14 1570 rcu_read_lock(); > c69e8d9c01db2a David Howells 2008-11-14 1571 cred = __task_cred(p); > ebc887b278944f Eric W. Biederman 2012-02-07 1572 SET_UID(psinfo->pr_uid, from_kuid_munged(cred->user_ns, cred->uid)); > ebc887b278944f Eric W. Biederman 2012-02-07 1573 SET_GID(psinfo->pr_gid, from_kgid_munged(cred->user_ns, cred->gid)); > c69e8d9c01db2a David Howells 2008-11-14 1574 rcu_read_unlock(); > ^1da177e4c3f41 Linus Torvalds 2005-04-16 @1575 strncpy(psinfo->pr_fname, p->comm, sizeof(psinfo->pr_fname)); > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1576 > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1577 return 0; > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1578 } > ^1da177e4c3f41 Linus Torvalds 2005-04-16 1579 > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org -- Thanks Yafang