Hi Waiman, I love your patch! Perhaps something to improve: [auto build test WARNING on tip/sched/core] [also build test WARNING 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: m68k-allmodconfig compiler: m68k-linux-gcc (GCC) 12.1.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/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=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash kernel/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All warnings (new ones prefixed by >>): kernel/sched/core.c: In function 'sched_setaffinity': kernel/sched/core.c:8289:21: error: implicit declaration of function 'alloc_user_cpus_ptr'; did you mean 'dup_user_cpus_ptr'? [-Werror=implicit-function-declaration] 8289 | user_mask = alloc_user_cpus_ptr(NUMA_NO_NODE); | ^~~~~~~~~~~~~~~~~~~ | dup_user_cpus_ptr >> kernel/sched/core.c:8289:19: warning: assignment to 'struct cpumask *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 8289 | user_mask = alloc_user_cpus_ptr(NUMA_NO_NODE); | ^ cc1: some warnings being treated as errors vim +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