kernel/fork.c:1610:9: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Wed Dec 13 2023 - 22:56:42 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5bd7ef53ffe5ca580e93e74eb8c81ed191ddc4bd
commit: 913292c97d750fe4188b4f5aa770e5e0ca1e5a91 sched.h: Annotate sighand_struct with __rcu
date: 3 years, 11 months ago
config: parisc-randconfig-r133-20231118 (https://download.01.org/0day-ci/archive/20231214/202312141146.rGQV1JEY-lkp@xxxxxxxxx/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231214/202312141146.rGQV1JEY-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312141146.rGQV1JEY-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
kernel/fork.c: note: in included file (through arch/parisc/include/uapi/asm/unistd.h, arch/parisc/include/asm/unistd.h, include/uapi/linux/unistd.h, ...):
./arch/parisc/include/generated/uapi/asm/unistd_32.h:381:41: sparse: sparse: no newline at end of file
kernel/fork.c:995:19: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct task_struct [noderef] __rcu *owner @@ got struct task_struct *p @@
kernel/fork.c:995:19: sparse: expected struct task_struct [noderef] __rcu *owner
kernel/fork.c:995:19: sparse: got struct task_struct *p
kernel/fork.c:1507:38: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct refcount_struct [usertype] *r @@ got struct refcount_struct [noderef] __rcu * @@
kernel/fork.c:1507:38: sparse: expected struct refcount_struct [usertype] *r
kernel/fork.c:1507:38: sparse: got struct refcount_struct [noderef] __rcu *
kernel/fork.c:1516:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:1516:31: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:1516:31: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:1517:36: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const *src @@ got struct k_sigaction [noderef] __rcu * @@
kernel/fork.c:1517:36: sparse: expected void const *src
kernel/fork.c:1517:36: sparse: got struct k_sigaction [noderef] __rcu *
kernel/fork.c:1518:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:1518:33: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:1518:33: sparse: got struct spinlock [noderef] __rcu *
>> kernel/fork.c:1610:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/fork.c:1610:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/fork.c:1610:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
kernel/fork.c:1901:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:1901:31: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:1901:31: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:1905:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:1905:33: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:1905:33: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:2201:32: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct task_struct [noderef] __rcu *real_parent @@ got struct task_struct *task @@
kernel/fork.c:2201:32: sparse: expected struct task_struct [noderef] __rcu *real_parent
kernel/fork.c:2201:32: sparse: got struct task_struct *task
kernel/fork.c:2207:27: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:2207:27: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:2207:27: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:2256:54: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct list_head *head @@ got struct list_head [noderef] __rcu * @@
kernel/fork.c:2256:54: sparse: expected struct list_head *head
kernel/fork.c:2256:54: sparse: got struct list_head [noderef] __rcu *
kernel/fork.c:2277:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:2277:29: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:2277:29: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:2292:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:2292:29: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:2292:29: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:2321:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sighand_struct *sighand @@ got struct sighand_struct [noderef] __rcu *sighand @@
kernel/fork.c:2321:28: sparse: expected struct sighand_struct *sighand
kernel/fork.c:2321:28: sparse: got struct sighand_struct [noderef] __rcu *sighand
kernel/fork.c:2349:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:2349:31: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:2349:31: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:2351:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/fork.c:2351:33: sparse: expected struct spinlock [usertype] *lock
kernel/fork.c:2351:33: sparse: got struct spinlock [noderef] __rcu *
kernel/fork.c:2747:24: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct task_struct *[assigned] parent @@ got struct task_struct [noderef] __rcu *real_parent @@
kernel/fork.c:2747:24: sparse: expected struct task_struct *[assigned] parent
kernel/fork.c:2747:24: sparse: got struct task_struct [noderef] __rcu *real_parent
kernel/fork.c:2827:43: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct refcount_struct const [usertype] *r @@ got struct refcount_struct [noderef] __rcu * @@
kernel/fork.c:2827:43: sparse: expected struct refcount_struct const [usertype] *r
kernel/fork.c:2827:43: sparse: got struct refcount_struct [noderef] __rcu *
kernel/fork.c:1936:27: sparse: sparse: dereference of noderef expression
kernel/fork.c:1936:27: sparse: sparse: dereference of noderef expression
kernel/fork.c:1938:22: sparse: sparse: dereference of noderef expression
kernel/fork.c: note: in included file (through include/uapi/asm-generic/bpf_perf_event.h, arch/parisc/include/generated/uapi/asm/bpf_perf_event.h, ...):
include/linux/ptrace.h:218:45: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct task_struct *new_parent @@ got struct task_struct [noderef] __rcu *parent @@
include/linux/ptrace.h:218:45: sparse: expected struct task_struct *new_parent
include/linux/ptrace.h:218:45: sparse: got struct task_struct [noderef] __rcu *parent
include/linux/ptrace.h:218:62: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected struct cred const *ptracer_cred @@ got struct cred const [noderef] __rcu *ptracer_cred @@
include/linux/ptrace.h:218:62: sparse: expected struct cred const *ptracer_cred
include/linux/ptrace.h:218:62: sparse: got struct cred const [noderef] __rcu *ptracer_cred
kernel/fork.c:2254:59: sparse: sparse: dereference of noderef expression
kernel/fork.c:2255:59: sparse: sparse: dereference of noderef expression
kernel/fork.c:987:23: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/fork.c:987:23: sparse: struct task_struct [noderef] __rcu *
kernel/fork.c:987:23: sparse: struct task_struct *
--
kernel/seccomp.c: note: in included file (through arch/parisc/include/uapi/asm/unistd.h, arch/parisc/include/asm/unistd.h, include/uapi/linux/unistd.h, ...):
./arch/parisc/include/generated/uapi/asm/unistd_32.h:381:41: sparse: sparse: no newline at end of file
>> kernel/seccomp.c:517:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:517:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:517:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
kernel/seccomp.c:972:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/seccomp.c:972:31: sparse: expected struct spinlock [usertype] *lock
kernel/seccomp.c:972:31: sparse: got struct spinlock [noderef] __rcu *
kernel/seccomp.c:984:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/seccomp.c:984:33: sparse: expected struct spinlock [usertype] *lock
kernel/seccomp.c:984:33: sparse: got struct spinlock [noderef] __rcu *
kernel/seccomp.c:1325:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/seccomp.c:1325:31: sparse: expected struct spinlock [usertype] *lock
kernel/seccomp.c:1325:31: sparse: got struct spinlock [noderef] __rcu *
kernel/seccomp.c:1338:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/seccomp.c:1338:33: sparse: expected struct spinlock [usertype] *lock
kernel/seccomp.c:1338:33: sparse: got struct spinlock [noderef] __rcu *
kernel/seccomp.c: note: in included file (through include/linux/sched/task.h, include/linux/sched/signal.h, include/linux/ptrace.h, ...):
include/linux/uaccess.h:111:13: sparse: sparse: self-comparison always evaluates to true
kernel/seccomp.c:343:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:343:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:343:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
kernel/seccomp.c:384:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:384:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:384:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
kernel/seccomp.c:301:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:301:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:301:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
kernel/seccomp.c:287:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:287:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:287:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
kernel/seccomp.c:301:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:301:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:301:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
include/linux/uaccess.h:129:13: sparse: sparse: self-comparison always evaluates to true
include/linux/uaccess.h:111:13: sparse: sparse: self-comparison always evaluates to true
include/linux/uaccess.h:111:13: sparse: sparse: self-comparison always evaluates to true
kernel/seccomp.c:287:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:287:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:287:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
kernel/seccomp.c:301:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct arch_spinlock_t [usertype] *x @@ got struct arch_spinlock_t [noderef] __rcu * @@
kernel/seccomp.c:301:9: sparse: expected struct arch_spinlock_t [usertype] *x
kernel/seccomp.c:301:9: sparse: got struct arch_spinlock_t [noderef] __rcu *
include/linux/uaccess.h:111:13: sparse: sparse: self-comparison always evaluates to true
include/linux/uaccess.h:129:13: sparse: sparse: self-comparison always evaluates to true

vim +1610 kernel/fork.c

^1da177e4c3f41 Linus Torvalds 2005-04-16 1600
dbd952127d11bb Kees Cook 2014-06-27 1601 static void copy_seccomp(struct task_struct *p)
dbd952127d11bb Kees Cook 2014-06-27 1602 {
dbd952127d11bb Kees Cook 2014-06-27 1603 #ifdef CONFIG_SECCOMP
dbd952127d11bb Kees Cook 2014-06-27 1604 /*
dbd952127d11bb Kees Cook 2014-06-27 1605 * Must be called with sighand->lock held, which is common to
dbd952127d11bb Kees Cook 2014-06-27 1606 * all threads in the group. Holding cred_guard_mutex is not
dbd952127d11bb Kees Cook 2014-06-27 1607 * needed because this new task is not yet running and cannot
dbd952127d11bb Kees Cook 2014-06-27 1608 * be racing exec.
dbd952127d11bb Kees Cook 2014-06-27 1609 */
69f6a34bdeea4f Guenter Roeck 2014-08-10 @1610 assert_spin_locked(&current->sighand->siglock);
dbd952127d11bb Kees Cook 2014-06-27 1611
dbd952127d11bb Kees Cook 2014-06-27 1612 /* Ref-count the new filter user, and assign it. */
dbd952127d11bb Kees Cook 2014-06-27 1613 get_seccomp_filter(current);
dbd952127d11bb Kees Cook 2014-06-27 1614 p->seccomp = current->seccomp;
dbd952127d11bb Kees Cook 2014-06-27 1615
dbd952127d11bb Kees Cook 2014-06-27 1616 /*
dbd952127d11bb Kees Cook 2014-06-27 1617 * Explicitly enable no_new_privs here in case it got set
dbd952127d11bb Kees Cook 2014-06-27 1618 * between the task_struct being duplicated and holding the
dbd952127d11bb Kees Cook 2014-06-27 1619 * sighand lock. The seccomp state and nnp must be in sync.
dbd952127d11bb Kees Cook 2014-06-27 1620 */
dbd952127d11bb Kees Cook 2014-06-27 1621 if (task_no_new_privs(current))
dbd952127d11bb Kees Cook 2014-06-27 1622 task_set_no_new_privs(p);
dbd952127d11bb Kees Cook 2014-06-27 1623
dbd952127d11bb Kees Cook 2014-06-27 1624 /*
dbd952127d11bb Kees Cook 2014-06-27 1625 * If the parent gained a seccomp mode after copying thread
dbd952127d11bb Kees Cook 2014-06-27 1626 * flags and between before we held the sighand lock, we have
dbd952127d11bb Kees Cook 2014-06-27 1627 * to manually enable the seccomp thread flag here.
dbd952127d11bb Kees Cook 2014-06-27 1628 */
dbd952127d11bb Kees Cook 2014-06-27 1629 if (p->seccomp.mode != SECCOMP_MODE_DISABLED)
dbd952127d11bb Kees Cook 2014-06-27 1630 set_tsk_thread_flag(p, TIF_SECCOMP);
dbd952127d11bb Kees Cook 2014-06-27 1631 #endif
dbd952127d11bb Kees Cook 2014-06-27 1632 }
dbd952127d11bb Kees Cook 2014-06-27 1633

:::::: The code at line 1610 was first introduced by commit
:::::: 69f6a34bdeea4fec50bb90619bc9602973119572 seccomp: Replace BUG(!spin_is_locked()) with assert_spin_lock

:::::: TO: Guenter Roeck <linux@xxxxxxxxxxxx>
:::::: CC: Kees Cook <keescook@xxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki