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] [day] [month] [year] [list]
Date:   Sat, 31 Dec 2022 09:15:59 +0800
From:   kernel test robot <lkp@...el.com>
To:     Waiman Long <longman@...hat.com>, Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Valentin Schneider <vschneid@...hat.com>
Cc:     llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
        Phil Auld <pauld@...hat.com>,
        Wenjie Li <wenjieli@....qualcomm.com>,
        David Wang 王标 <wangbiao3@...omi.com>,
        Quentin Perret <qperret@...gle.com>,
        Will Deacon <will@...nel.org>, linux-kernel@...r.kernel.org,
        Waiman Long <longman@...hat.com>
Subject: Re: [PATCH v5 2/2] sched: Use kfree_rcu() in do_set_cpus_allowed()

Hi Waiman,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on tip/master tip/auto-latest linus/master v6.2-rc1 next-20221226]
[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/Waiman-Long/sched-Fix-use-after-free-bug-in-dup_user_cpus_ptr/20221230-233445
patch link:    https://lore.kernel.org/r/20221230153218.354214-3-longman%40redhat.com
patch subject: [PATCH v5 2/2] sched: Use kfree_rcu() in do_set_cpus_allowed()
config: powerpc-randconfig-r006-20221228
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project f5700e7b69048de958172fb513b336564e7f8709)
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
        # install powerpc cross compiling tool for clang build
        # apt-get install binutils-powerpc-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/1d6a3d1a82b7b8f6265ea5ea340af5b7e9eeb689
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Waiman-Long/sched-Fix-use-after-free-bug-in-dup_user_cpus_ptr/20221230-233445
        git checkout 1d6a3d1a82b7b8f6265ea5ea340af5b7e9eeb689
        # 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=powerpc olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash kernel/sched/

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 >>):

>> kernel/sched/core.c:8289:14: error: call to undeclared function 'alloc_user_cpus_ptr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           user_mask = alloc_user_cpus_ptr(NUMA_NO_NODE);
                       ^
   kernel/sched/core.c:8289:14: note: did you mean 'dup_user_cpus_ptr'?
   include/linux/sched.h:1868:19: note: 'dup_user_cpus_ptr' declared here
   static inline int dup_user_cpus_ptr(struct task_struct *dst, struct task_struct *src, int node)
                     ^
>> kernel/sched/core.c:8289:12: error: incompatible integer to pointer conversion assigning to 'struct cpumask *' from 'int' [-Wint-conversion]
           user_mask = alloc_user_cpus_ptr(NUMA_NO_NODE);
                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   2 errors generated.


vim +/alloc_user_cpus_ptr +8289 kernel/sched/core.c

  8250	
  8251	long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
  8252	{
  8253		struct affinity_context ac;
  8254		struct cpumask *user_mask;
  8255		struct task_struct *p;
  8256		int retval;
  8257	
  8258		rcu_read_lock();
  8259	
  8260		p = find_process_by_pid(pid);
  8261		if (!p) {
  8262			rcu_read_unlock();
  8263			return -ESRCH;
  8264		}
  8265	
  8266		/* Prevent p going away */
  8267		get_task_struct(p);
  8268		rcu_read_unlock();
  8269	
  8270		if (p->flags & PF_NO_SETAFFINITY) {
  8271			retval = -EINVAL;
  8272			goto out_put_task;
  8273		}
  8274	
  8275		if (!check_same_owner(p)) {
  8276			rcu_read_lock();
  8277			if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
  8278				rcu_read_unlock();
  8279				retval = -EPERM;
  8280				goto out_put_task;
  8281			}
  8282			rcu_read_unlock();
  8283		}
  8284	
  8285		retval = security_task_setscheduler(p);
  8286		if (retval)
  8287			goto out_put_task;
  8288	
> 8289		user_mask = alloc_user_cpus_ptr(NUMA_NO_NODE);
  8290		if (!user_mask) {
  8291			retval = -ENOMEM;
  8292			goto out_put_task;
  8293		}
  8294		cpumask_copy(user_mask, in_mask);
  8295		ac = (struct affinity_context){
  8296			.new_mask  = in_mask,
  8297			.user_mask = user_mask,
  8298			.flags     = SCA_USER,
  8299		};
  8300	
  8301		retval = __sched_setaffinity(p, &ac);
  8302		kfree(ac.user_mask);
  8303	
  8304	out_put_task:
  8305		put_task_struct(p);
  8306		return retval;
  8307	}
  8308	

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ