[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202210010722.eyWoUzQv-lkp@intel.com>
Date: Sat, 1 Oct 2022 07:34:10 +0800
From: kernel test robot <lkp@...el.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: [kas:lam 5/16] kernel/sched/core_sched.c:181:23: sparse: sparse:
incorrect type in assignment (different address spaces)
Hi Kirill,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git lam
head: fd053f88c1b7e1acac9fbaeab44c8f675bb9c287
commit: 2979bb830b677ffdc1a842f9dfb835f313b602f7 [5/16] x86/uaccess: Provide untagged_addr() and remove tags before address check
config: x86_64-randconfig-s022
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git/commit/?id=2979bb830b677ffdc1a842f9dfb835f313b602f7
git remote add kas https://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git
git fetch --no-tags kas lam
git checkout 2979bb830b677ffdc1a842f9dfb835f313b602f7
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/char/ipmi/ fs/notify/fanotify/ fs/orangefs/ kernel/sched/ sound/core/seq/oss/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
kernel/sched/build_utility.c: note: in included file:
kernel/sched/build_utility.c: note: in included file:
kernel/sched/stats.c:148:17: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/stats.c:148:17: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/stats.c:148:17: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/build_utility.c: note: in included file:
kernel/sched/stop_task.c:73:38: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct task_struct *curr @@ got struct task_struct [noderef] __rcu *curr @@
kernel/sched/stop_task.c:73:38: sparse: expected struct task_struct *curr
kernel/sched/stop_task.c:73:38: sparse: got struct task_struct [noderef] __rcu *curr
kernel/sched/build_utility.c: note: in included file:
kernel/sched/topology.c:481:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct perf_domain *pd @@ got struct perf_domain [noderef] __rcu *pd @@
kernel/sched/topology.c:481:19: sparse: expected struct perf_domain *pd
kernel/sched/topology.c:481:19: sparse: got struct perf_domain [noderef] __rcu *pd
kernel/sched/topology.c:643:49: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain *parent @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:643:49: sparse: expected struct sched_domain *parent
kernel/sched/topology.c:643:49: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:714:50: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain *parent @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:714:50: sparse: expected struct sched_domain *parent
kernel/sched/topology.c:714:50: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:721:55: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain [noderef] __rcu *[noderef] __rcu child @@ got struct sched_domain *[assigned] tmp @@
kernel/sched/topology.c:721:55: sparse: expected struct sched_domain [noderef] __rcu *[noderef] __rcu child
kernel/sched/topology.c:721:55: sparse: got struct sched_domain *[assigned] tmp
kernel/sched/topology.c:731:29: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] tmp @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:731:29: sparse: expected struct sched_domain *[assigned] tmp
kernel/sched/topology.c:731:29: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:736:20: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:736:20: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:736:20: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:757:13: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] tmp @@ got struct sched_domain [noderef] __rcu *sd @@
kernel/sched/topology.c:757:13: sparse: expected struct sched_domain *[assigned] tmp
kernel/sched/topology.c:757:13: sparse: got struct sched_domain [noderef] __rcu *sd
kernel/sched/topology.c:919:70: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:919:70: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:919:70: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:948:59: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:948:59: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:948:59: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:994:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:994:57: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:994:57: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:996:25: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *sibling @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:996:25: sparse: expected struct sched_domain *sibling
kernel/sched/topology.c:996:25: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1004:55: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:1004:55: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:1004:55: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1006:25: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *sibling @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:1006:25: sparse: expected struct sched_domain *sibling
kernel/sched/topology.c:1006:25: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1076:62: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:1076:62: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:1076:62: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1180:40: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain *child @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:1180:40: sparse: expected struct sched_domain *child
kernel/sched/topology.c:1180:40: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1589:43: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain [noderef] __rcu *child @@ got struct sched_domain *child @@
kernel/sched/topology.c:1589:43: sparse: expected struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1589:43: sparse: got struct sched_domain *child
kernel/sched/topology.c:2186:31: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain [noderef] __rcu *parent @@ got struct sched_domain *sd @@
kernel/sched/topology.c:2186:31: sparse: expected struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:2186:31: sparse: got struct sched_domain *sd
kernel/sched/topology.c:2289:57: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:2289:57: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/topology.c:2289:57: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:2310:56: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain *child @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:2310:56: sparse: expected struct sched_domain *child
kernel/sched/topology.c:2310:56: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:2309:57: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:2309:57: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/topology.c:2309:57: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:2364:57: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:2364:57: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/topology.c:2364:57: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/build_utility.c: note: in included file:
>> kernel/sched/core_sched.c:181:23: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected unsigned long long [noderef] __user *__ptr_clean @@ got unsigned long long * @@
kernel/sched/core_sched.c:181:23: sparse: expected unsigned long long [noderef] __user *__ptr_clean
kernel/sched/core_sched.c:181:23: sparse: got unsigned long long *
kernel/sched/core_sched.c:276:37: sparse: sparse: incompatible types in conditional expression (different address spaces):
kernel/sched/core_sched.c:276:37: sparse: struct task_struct *
kernel/sched/core_sched.c:276:37: sparse: struct task_struct [noderef] __rcu *
kernel/sched/build_utility.c: note: in included file:
kernel/sched/psi.c:143:1: sparse: sparse: symbol 'psi_cgroups_enabled' was not declared. Should it be static?
kernel/sched/build_utility.c: note: in included file:
kernel/sched/sched.h:1788:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1788:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1788:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/sched.h:1801:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1801:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1801:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/sched.h:1788:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1788:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1788:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/sched.h:1801:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1801:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1801:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/build_utility.c: note: in included file:
kernel/sched/topology.c:949:31: sparse: sparse: dereference of noderef expression
kernel/sched/topology.c:1610:19: sparse: sparse: dereference of noderef expression
kernel/sched/topology.c:2347:51: sparse: sparse: dereference of noderef expression
kernel/sched/topology.c:2348:49: sparse: sparse: dereference of noderef expression
kernel/sched/topology.c:2350:52: sparse: sparse: dereference of noderef expression
kernel/sched/build_utility.c: note: in included file:
kernel/sched/sched.h:1228:30: sparse: sparse: context imbalance in 'sched_core_update_cookie' - wrong count at exit
kernel/sched/build_utility.c: note: in included file:
kernel/sched/psi.c:746:13: sparse: sparse: dereference of noderef expression
kernel/sched/psi.c:770:38: sparse: sparse: dereference of noderef expression
kernel/sched/psi.c:997:6: sparse: sparse: context imbalance in 'cgroup_move_task' - different lock contexts for basic block
--
>> fs/orangefs/devorangefs-req.c:605:26: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected signed int [noderef] __user *__ptr_clean @@ got signed int * @@
fs/orangefs/devorangefs-req.c:605:26: sparse: expected signed int [noderef] __user *__ptr_clean
fs/orangefs/devorangefs-req.c:605:26: sparse: got signed int *
fs/orangefs/devorangefs-req.c:609:26: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected signed int [noderef] __user *__ptr_clean @@ got signed int * @@
fs/orangefs/devorangefs-req.c:609:26: sparse: expected signed int [noderef] __user *__ptr_clean
fs/orangefs/devorangefs-req.c:609:26: sparse: got signed int *
fs/orangefs/devorangefs-req.c:614:26: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected signed int [noderef] __user *__ptr_clean @@ got signed int * @@
fs/orangefs/devorangefs-req.c:614:26: sparse: expected signed int [noderef] __user *__ptr_clean
fs/orangefs/devorangefs-req.c:614:26: sparse: got signed int *
fs/orangefs/devorangefs-req.c:254:28: sparse: sparse: context imbalance in 'orangefs_devreq_read' - different lock contexts for basic block
--
>> fs/notify/fanotify/fanotify_user.c:929:23: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
fs/notify/fanotify/fanotify_user.c:929:23: sparse: expected int [noderef] __user *__ptr_clean
fs/notify/fanotify/fanotify_user.c:929:23: sparse: got int *
--
>> drivers/char/ipmi/ipmi_watchdog.c:768:37: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected char const [noderef] __user *__ptr_clean @@ got char const * @@
drivers/char/ipmi/ipmi_watchdog.c:768:37: sparse: expected char const [noderef] __user *__ptr_clean
drivers/char/ipmi/ipmi_watchdog.c:768:37: sparse: got char const *
--
>> sound/core/seq/oss/seq_oss_ioctl.c:97:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:97:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:97:21: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:104:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:104:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:104:24: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:109:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:109:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:109:24: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:112:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:112:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:112:24: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:115:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:115:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:115:21: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:120:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:120:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:120:24: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:123:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:123:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:123:24: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:126:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:126:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:126:21: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:129:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:129:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:129:24: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:132:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:132:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:132:21: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:150:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:150:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:150:21: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:162:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:162:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:162:21: sparse: got int *
sound/core/seq/oss/seq_oss_ioctl.c:169:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_ioctl.c:169:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_ioctl.c:169:24: sparse: got int *
--
>> sound/core/seq/oss/seq_oss_timer.c:224:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_timer.c:224:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_timer.c:224:21: sparse: got int *
sound/core/seq/oss/seq_oss_timer.c:229:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_timer.c:229:24: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_timer.c:229:24: sparse: got int *
sound/core/seq/oss/seq_oss_timer.c:243:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_timer.c:243:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_timer.c:243:21: sparse: got int *
sound/core/seq/oss/seq_oss_timer.c:247:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected int [noderef] __user *__ptr_clean @@ got int * @@
sound/core/seq/oss/seq_oss_timer.c:247:21: sparse: expected int [noderef] __user *__ptr_clean
sound/core/seq/oss/seq_oss_timer.c:247:21: sparse: got int *
vim +181 kernel/sched/core_sched.c
7ac592aa35a684 Chris Hyser 2021-03-24 127
7ac592aa35a684 Chris Hyser 2021-03-24 128 /* Called from prctl interface: PR_SCHED_CORE */
7ac592aa35a684 Chris Hyser 2021-03-24 129 int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
7ac592aa35a684 Chris Hyser 2021-03-24 130 unsigned long uaddr)
7ac592aa35a684 Chris Hyser 2021-03-24 131 {
7ac592aa35a684 Chris Hyser 2021-03-24 132 unsigned long cookie = 0, id = 0;
7ac592aa35a684 Chris Hyser 2021-03-24 133 struct task_struct *task, *p;
7ac592aa35a684 Chris Hyser 2021-03-24 134 struct pid *grp;
7ac592aa35a684 Chris Hyser 2021-03-24 135 int err = 0;
7ac592aa35a684 Chris Hyser 2021-03-24 136
7ac592aa35a684 Chris Hyser 2021-03-24 137 if (!static_branch_likely(&sched_smt_present))
7ac592aa35a684 Chris Hyser 2021-03-24 138 return -ENODEV;
7ac592aa35a684 Chris Hyser 2021-03-24 139
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25 140 BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD != PIDTYPE_PID);
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25 141 BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD_GROUP != PIDTYPE_TGID);
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25 142 BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_PROCESS_GROUP != PIDTYPE_PGID);
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25 143
7ac592aa35a684 Chris Hyser 2021-03-24 144 if (type > PIDTYPE_PGID || cmd >= PR_SCHED_CORE_MAX || pid < 0 ||
7ac592aa35a684 Chris Hyser 2021-03-24 145 (cmd != PR_SCHED_CORE_GET && uaddr))
7ac592aa35a684 Chris Hyser 2021-03-24 146 return -EINVAL;
7ac592aa35a684 Chris Hyser 2021-03-24 147
7ac592aa35a684 Chris Hyser 2021-03-24 148 rcu_read_lock();
7ac592aa35a684 Chris Hyser 2021-03-24 149 if (pid == 0) {
7ac592aa35a684 Chris Hyser 2021-03-24 150 task = current;
7ac592aa35a684 Chris Hyser 2021-03-24 151 } else {
7ac592aa35a684 Chris Hyser 2021-03-24 152 task = find_task_by_vpid(pid);
7ac592aa35a684 Chris Hyser 2021-03-24 153 if (!task) {
7ac592aa35a684 Chris Hyser 2021-03-24 154 rcu_read_unlock();
7ac592aa35a684 Chris Hyser 2021-03-24 155 return -ESRCH;
7ac592aa35a684 Chris Hyser 2021-03-24 156 }
7ac592aa35a684 Chris Hyser 2021-03-24 157 }
7ac592aa35a684 Chris Hyser 2021-03-24 158 get_task_struct(task);
7ac592aa35a684 Chris Hyser 2021-03-24 159 rcu_read_unlock();
7ac592aa35a684 Chris Hyser 2021-03-24 160
7ac592aa35a684 Chris Hyser 2021-03-24 161 /*
7ac592aa35a684 Chris Hyser 2021-03-24 162 * Check if this process has the right to modify the specified
7ac592aa35a684 Chris Hyser 2021-03-24 163 * process. Use the regular "ptrace_may_access()" checks.
7ac592aa35a684 Chris Hyser 2021-03-24 164 */
7ac592aa35a684 Chris Hyser 2021-03-24 165 if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
7ac592aa35a684 Chris Hyser 2021-03-24 166 err = -EPERM;
7ac592aa35a684 Chris Hyser 2021-03-24 167 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 168 }
7ac592aa35a684 Chris Hyser 2021-03-24 169
7ac592aa35a684 Chris Hyser 2021-03-24 170 switch (cmd) {
7ac592aa35a684 Chris Hyser 2021-03-24 171 case PR_SCHED_CORE_GET:
7ac592aa35a684 Chris Hyser 2021-03-24 172 if (type != PIDTYPE_PID || uaddr & 7) {
7ac592aa35a684 Chris Hyser 2021-03-24 173 err = -EINVAL;
7ac592aa35a684 Chris Hyser 2021-03-24 174 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 175 }
7ac592aa35a684 Chris Hyser 2021-03-24 176 cookie = sched_core_clone_cookie(task);
7ac592aa35a684 Chris Hyser 2021-03-24 177 if (cookie) {
7ac592aa35a684 Chris Hyser 2021-03-24 178 /* XXX improve ? */
7ac592aa35a684 Chris Hyser 2021-03-24 179 ptr_to_hashval((void *)cookie, &id);
7ac592aa35a684 Chris Hyser 2021-03-24 180 }
7ac592aa35a684 Chris Hyser 2021-03-24 @181 err = put_user(id, (u64 __user *)uaddr);
7ac592aa35a684 Chris Hyser 2021-03-24 182 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 183
7ac592aa35a684 Chris Hyser 2021-03-24 184 case PR_SCHED_CORE_CREATE:
7ac592aa35a684 Chris Hyser 2021-03-24 185 cookie = sched_core_alloc_cookie();
7ac592aa35a684 Chris Hyser 2021-03-24 186 if (!cookie) {
7ac592aa35a684 Chris Hyser 2021-03-24 187 err = -ENOMEM;
7ac592aa35a684 Chris Hyser 2021-03-24 188 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 189 }
7ac592aa35a684 Chris Hyser 2021-03-24 190 break;
7ac592aa35a684 Chris Hyser 2021-03-24 191
7ac592aa35a684 Chris Hyser 2021-03-24 192 case PR_SCHED_CORE_SHARE_TO:
7ac592aa35a684 Chris Hyser 2021-03-24 193 cookie = sched_core_clone_cookie(current);
7ac592aa35a684 Chris Hyser 2021-03-24 194 break;
7ac592aa35a684 Chris Hyser 2021-03-24 195
7ac592aa35a684 Chris Hyser 2021-03-24 196 case PR_SCHED_CORE_SHARE_FROM:
7ac592aa35a684 Chris Hyser 2021-03-24 197 if (type != PIDTYPE_PID) {
7ac592aa35a684 Chris Hyser 2021-03-24 198 err = -EINVAL;
7ac592aa35a684 Chris Hyser 2021-03-24 199 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 200 }
7ac592aa35a684 Chris Hyser 2021-03-24 201 cookie = sched_core_clone_cookie(task);
7ac592aa35a684 Chris Hyser 2021-03-24 202 __sched_core_set(current, cookie);
7ac592aa35a684 Chris Hyser 2021-03-24 203 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 204
7ac592aa35a684 Chris Hyser 2021-03-24 205 default:
7ac592aa35a684 Chris Hyser 2021-03-24 206 err = -EINVAL;
7ac592aa35a684 Chris Hyser 2021-03-24 207 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 208 };
7ac592aa35a684 Chris Hyser 2021-03-24 209
7ac592aa35a684 Chris Hyser 2021-03-24 210 if (type == PIDTYPE_PID) {
7ac592aa35a684 Chris Hyser 2021-03-24 211 __sched_core_set(task, cookie);
7ac592aa35a684 Chris Hyser 2021-03-24 212 goto out;
7ac592aa35a684 Chris Hyser 2021-03-24 213 }
7ac592aa35a684 Chris Hyser 2021-03-24 214
7ac592aa35a684 Chris Hyser 2021-03-24 215 read_lock(&tasklist_lock);
7ac592aa35a684 Chris Hyser 2021-03-24 216 grp = task_pid_type(task, type);
7ac592aa35a684 Chris Hyser 2021-03-24 217
7ac592aa35a684 Chris Hyser 2021-03-24 218 do_each_pid_thread(grp, type, p) {
7ac592aa35a684 Chris Hyser 2021-03-24 219 if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS)) {
7ac592aa35a684 Chris Hyser 2021-03-24 220 err = -EPERM;
7ac592aa35a684 Chris Hyser 2021-03-24 221 goto out_tasklist;
7ac592aa35a684 Chris Hyser 2021-03-24 222 }
7ac592aa35a684 Chris Hyser 2021-03-24 223 } while_each_pid_thread(grp, type, p);
7ac592aa35a684 Chris Hyser 2021-03-24 224
7ac592aa35a684 Chris Hyser 2021-03-24 225 do_each_pid_thread(grp, type, p) {
7ac592aa35a684 Chris Hyser 2021-03-24 226 __sched_core_set(p, cookie);
7ac592aa35a684 Chris Hyser 2021-03-24 227 } while_each_pid_thread(grp, type, p);
7ac592aa35a684 Chris Hyser 2021-03-24 228 out_tasklist:
7ac592aa35a684 Chris Hyser 2021-03-24 229 read_unlock(&tasklist_lock);
7ac592aa35a684 Chris Hyser 2021-03-24 230
7ac592aa35a684 Chris Hyser 2021-03-24 231 out:
7ac592aa35a684 Chris Hyser 2021-03-24 232 sched_core_put_cookie(cookie);
7ac592aa35a684 Chris Hyser 2021-03-24 233 put_task_struct(task);
7ac592aa35a684 Chris Hyser 2021-03-24 234 return err;
7ac592aa35a684 Chris Hyser 2021-03-24 235 }
7ac592aa35a684 Chris Hyser 2021-03-24 236
:::::: The code at line 181 was first introduced by commit
:::::: 7ac592aa35a684ff1858fb9ec282886b9e3575ac sched: prctl() core-scheduling interface
:::::: TO: Chris Hyser <chris.hyser@...cle.com>
:::::: CC: Peter Zijlstra <peterz@...radead.org>
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (130953 bytes)
Powered by blists - more mailing lists