Re: [PATCH] coredump: Split pipe command whitespace before expanding template

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Paul,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.2-rc1 next-20190520]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Paul-Wise/coredump-Split-pipe-command-whitespace-before-expanding-template/20190520-212130
config: riscv-defconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=riscv 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

   fs/coredump.c: In function 'format_corename':
>> fs/coredump.c:210:4: error: invalid type argument of unary '*' (have 'int')
      (*argvs) = kmalloc_array(argvs, sizeof(**argv), GFP_KERNEL);
       ^~~~~~

vim +210 fs/coredump.c

   186	
   187	/* format_corename will inspect the pattern parameter, and output a
   188	 * name into corename, which must have space for at least
   189	 * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
   190	 */
   191	static int format_corename(struct core_name *cn, struct coredump_params *cprm,
   192				   size_t **argv, int *argc)
   193	{
   194		const struct cred *cred = current_cred();
   195		const char *pat_ptr = core_pattern;
   196		int ispipe = (*pat_ptr == '|');
   197		bool was_space = false;
   198		int pid_in_pattern = 0;
   199		int err = 0;
   200	
   201		cn->used = 0;
   202		cn->corename = NULL;
   203		if (expand_corename(cn, core_name_size))
   204			return -ENOMEM;
   205		cn->corename[0] = '\0';
   206	
   207		if (ispipe) {
   208			/* sizeof(core_pattern) / 2 is the maximum number of args. */
   209			int argvs = sizeof(core_pattern) / 2;
 > 210			(*argvs) = kmalloc_array(argvs, sizeof(**argv), GFP_KERNEL);
   211			if (!(*argv))
   212				return -ENOMEM;
   213			(*argv)[(*argc)++] = 0;
   214			++pat_ptr;
   215		}
   216	
   217		/* Repeat as long as we have more pattern to process and more output
   218		   space */
   219		while (*pat_ptr) {
   220			/*
   221			 * Split on spaces before doing template expansion so that
   222			 * %e and %E don't get split if they have spaces in them
   223			 */
   224			if (ispipe) {
   225				if (isspace(*pat_ptr)) {
   226					was_space = true;
   227					pat_ptr++;
   228					continue;
   229				} else if (was_space) {
   230					was_space = false;
   231					err = cn_printf(cn, "%c", '\0');
   232					if (err)
   233						return err;
   234					(*argv)[(*argc)++] = cn->used;
   235				}
   236			}
   237			if (*pat_ptr != '%') {
   238				err = cn_printf(cn, "%c", *pat_ptr++);
   239			} else {
   240				switch (*++pat_ptr) {
   241				/* single % at the end, drop that */
   242				case 0:
   243					goto out;
   244				/* Double percent, output one percent */
   245				case '%':
   246					err = cn_printf(cn, "%c", '%');
   247					break;
   248				/* pid */
   249				case 'p':
   250					pid_in_pattern = 1;
   251					err = cn_printf(cn, "%d",
   252						      task_tgid_vnr(current));
   253					break;
   254				/* global pid */
   255				case 'P':
   256					err = cn_printf(cn, "%d",
   257						      task_tgid_nr(current));
   258					break;
   259				case 'i':
   260					err = cn_printf(cn, "%d",
   261						      task_pid_vnr(current));
   262					break;
   263				case 'I':
   264					err = cn_printf(cn, "%d",
   265						      task_pid_nr(current));
   266					break;
   267				/* uid */
   268				case 'u':
   269					err = cn_printf(cn, "%u",
   270							from_kuid(&init_user_ns,
   271								  cred->uid));
   272					break;
   273				/* gid */
   274				case 'g':
   275					err = cn_printf(cn, "%u",
   276							from_kgid(&init_user_ns,
   277								  cred->gid));
   278					break;
   279				case 'd':
   280					err = cn_printf(cn, "%d",
   281						__get_dumpable(cprm->mm_flags));
   282					break;
   283				/* signal that caused the coredump */
   284				case 's':
   285					err = cn_printf(cn, "%d",
   286							cprm->siginfo->si_signo);
   287					break;
   288				/* UNIX time of coredump */
   289				case 't': {
   290					time64_t time;
   291	
   292					time = ktime_get_real_seconds();
   293					err = cn_printf(cn, "%lld", time);
   294					break;
   295				}
   296				/* hostname */
   297				case 'h':
   298					down_read(&uts_sem);
   299					err = cn_esc_printf(cn, "%s",
   300						      utsname()->nodename);
   301					up_read(&uts_sem);
   302					break;
   303				/* executable */
   304				case 'e':
   305					err = cn_esc_printf(cn, "%s", current->comm);
   306					break;
   307				case 'E':
   308					err = cn_print_exe_file(cn);
   309					break;
   310				/* core limit size */
   311				case 'c':
   312					err = cn_printf(cn, "%lu",
   313						      rlimit(RLIMIT_CORE));
   314					break;
   315				default:
   316					break;
   317				}
   318				++pat_ptr;
   319			}
   320	
   321			if (err)
   322				return err;
   323		}
   324	
   325	out:
   326		/* Backward compatibility with core_uses_pid:
   327		 *
   328		 * If core_pattern does not include a %p (as is the default)
   329		 * and core_uses_pid is set, then .%pid will be appended to
   330		 * the filename. Do not do this for piped commands. */
   331		if (!ispipe && !pid_in_pattern && core_uses_pid) {
   332			err = cn_printf(cn, ".%d", task_tgid_vnr(current));
   333			if (err)
   334				return err;
   335		}
   336		return ispipe;
   337	}
   338	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux