kernel/time/posix-timers.c:554:17: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot

Date: Sun Jun 14 2026 - 18:38:00 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6
commit: f16a802d402d735a55731f8c94952b3bbb5ddfe8 locking/rwlock, spinlock: Support Clang's context analysis
date: 5 months ago
config: x86_64-randconfig-r121-20260614 (https://download.01.org/0day-ci/archive/20260615/202606150642.uF81VHfj-lkp@xxxxxxxxx/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260615/202606150642.uF81VHfj-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
| Fixes: f16a802d402d ("locking/rwlock, spinlock: Support Clang's context analysis")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202606150642.uF81VHfj-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
kernel/time/posix-timers.c:345:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/time/posix-timers.c:345:29: sparse: expected struct spinlock [usertype] *lock
kernel/time/posix-timers.c:345:29: sparse: got struct spinlock [noderef] __rcu *
kernel/time/posix-timers.c:352:27: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *lock @@ got struct spinlock [noderef] __rcu * @@
kernel/time/posix-timers.c:352:27: sparse: expected struct spinlock [usertype] *lock
kernel/time/posix-timers.c:352:27: sparse: got struct spinlock [noderef] __rcu *
>> kernel/time/posix-timers.c:554:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *_T @@ got struct spinlock [noderef] __rcu * @@
kernel/time/posix-timers.c:554:17: sparse: expected struct spinlock [usertype] *_T
kernel/time/posix-timers.c:554:17: sparse: got struct spinlock [noderef] __rcu *
kernel/time/posix-timers.c:1042:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *_T @@ got struct spinlock [noderef] __rcu * @@
kernel/time/posix-timers.c:1042:9: sparse: expected struct spinlock [usertype] *_T
kernel/time/posix-timers.c:1042:9: sparse: got struct spinlock [noderef] __rcu *
kernel/time/posix-timers.c:1090:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct spinlock [usertype] *_T @@ got struct spinlock [noderef] __rcu * @@
kernel/time/posix-timers.c:1090:9: sparse: expected struct spinlock [usertype] *_T
kernel/time/posix-timers.c:1090:9: sparse: got struct spinlock [noderef] __rcu *
kernel/time/posix-timers.c:134:13: sparse: sparse: context imbalance in 'posix_timer_add_at' - wrong count at exit
kernel/time/posix-timers.c:306:13: sparse: sparse: context imbalance in '__posixtimer_deliver_signal' - wrong count at exit
kernel/time/posix-timers.c:336:6: sparse: sparse: context imbalance in 'posixtimer_deliver_signal' - unexpected unlock
kernel/time/posix-timers.c:374:29: sparse: sparse: context imbalance in 'posix_timer_fn' - wrong count at exit
kernel/time/posix-timers.c:449:13: sparse: sparse: context imbalance in 'posix_timer_unhash_and_free' - wrong count at exit
kernel/time/posix-timers.c:465:12: sparse: sparse: context imbalance in 'do_timer_create' - different lock contexts for basic block
kernel/time/posix-timers.c:603:24: sparse: sparse: context imbalance in '__lock_timer' - different lock contexts for basic block
kernel/time/posix-timers.c:1050:9: sparse: sparse: context imbalance in 'posix_timer_delete' - wrong count at exit
kernel/time/posix-timers.c:1094:9: sparse: sparse: context imbalance in 'exit_itimers' - different lock contexts for basic block

vim +554 kernel/time/posix-timers.c

838394fbf98997 kernel/posix-timers.c Thomas Gleixner 2011-02-01 463
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 464 /* Create a POSIX.1b interval timer. */
2482097c6c0f01 kernel/time/posix-timers.c Al Viro 2017-06-07 465 static int do_timer_create(clockid_t which_clock, struct sigevent *event,
2482097c6c0f01 kernel/time/posix-timers.c Al Viro 2017-06-07 466 timer_t __user *created_timer_id)
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 467 {
d3ba5a9a345b12 kernel/time/posix-timers.c Christoph Hellwig 2017-05-26 468 const struct k_clock *kc = clockid_to_kclock(which_clock);
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 469 timer_t req_id = TIMER_ANY_ID;
2cd499e38ec241 kernel/posix-timers.c Oleg Nesterov 2008-09-22 470 struct k_itimer *new_timer;
ef864c95880176 kernel/posix-timers.c Oleg Nesterov 2008-09-22 471 int error, new_timer_id;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 472
838394fbf98997 kernel/posix-timers.c Thomas Gleixner 2011-02-01 473 if (!kc)
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 474 return -EINVAL;
838394fbf98997 kernel/posix-timers.c Thomas Gleixner 2011-02-01 475 if (!kc->timer_create)
838394fbf98997 kernel/posix-timers.c Thomas Gleixner 2011-02-01 476 return -EOPNOTSUPP;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 477
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 478 /* Special case for CRIU to restore timers with a given timer ID. */
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 479 if (unlikely(current->signal->timer_create_restore_ids)) {
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 480 if (copy_from_user(&req_id, created_timer_id, sizeof(req_id)))
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 481 return -EFAULT;
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 482 /* Valid IDs are 0..INT_MAX */
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 483 if ((unsigned int)req_id > INT_MAX)
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 484 return -EINVAL;
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 485 }
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 486
e0fd4d42e27f76 kernel/time/posix-timers.c Eslam Khafagy 2025-11-14 487 new_timer = alloc_posix_timer();
e0fd4d42e27f76 kernel/time/posix-timers.c Eslam Khafagy 2025-11-14 488 if (unlikely(!new_timer))
e0fd4d42e27f76 kernel/time/posix-timers.c Eslam Khafagy 2025-11-14 489 return -EAGAIN;
e0fd4d42e27f76 kernel/time/posix-timers.c Eslam Khafagy 2025-11-14 490
e0fd4d42e27f76 kernel/time/posix-timers.c Eslam Khafagy 2025-11-14 491 spin_lock_init(&new_timer->it_lock);
e0fd4d42e27f76 kernel/time/posix-timers.c Eslam Khafagy 2025-11-14 492
ae88967d71f1b4 kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 493 /*
ae88967d71f1b4 kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 494 * Add the timer to the hash table. The timer is not yet valid
45ece9933d4a8e kernel/time/posix-timers.c Eric Dumazet 2025-03-08 495 * after insertion, but has a unique ID allocated.
ae88967d71f1b4 kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 496 */
ec2d0c04624b3c kernel/time/posix-timers.c Thomas Gleixner 2025-03-11 497 new_timer_id = posix_timer_add(new_timer, req_id);
5ed67f05f66c41 kernel/posix-timers.c Pavel Emelyanov 2013-03-11 498 if (new_timer_id < 0) {
5d916a0988eed5 kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 499 posixtimer_free_timer(new_timer);
8cc96ca2c75f6d kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 500 return new_timer_id;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 501 }
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 502
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 503 new_timer->it_clock = which_clock;
d97bb75ddd2f38 kernel/time/posix-timers.c Thomas Gleixner 2017-05-30 504 new_timer->kclock = kc;
78c9c4dfbf8c04 kernel/time/posix-timers.c Thomas Gleixner 2018-06-26 505 new_timer->it_overrun = -1LL;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 506
2482097c6c0f01 kernel/time/posix-timers.c Al Viro 2017-06-07 507 if (event) {
a31a300c4daba8 kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 508 scoped_guard (rcu)
2482097c6c0f01 kernel/time/posix-timers.c Al Viro 2017-06-07 509 new_timer->it_pid = get_pid(good_sigevent(event));
899921025b406a kernel/posix-timers.c Oleg Nesterov 2008-12-01 510 if (!new_timer->it_pid) {
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 511 error = -EINVAL;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 512 goto out;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 513 }
2482097c6c0f01 kernel/time/posix-timers.c Al Viro 2017-06-07 514 new_timer->it_sigev_notify = event->sigev_notify;
6017a158beb13b kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 515 new_timer->sigq.info.si_signo = event->sigev_signo;
6017a158beb13b kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 516 new_timer->sigq.info.si_value = event->sigev_value;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 517 } else {
2482097c6c0f01 kernel/time/posix-timers.c Al Viro 2017-06-07 518 new_timer->it_sigev_notify = SIGEV_SIGNAL;
6017a158beb13b kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 519 new_timer->sigq.info.si_signo = SIGALRM;
6017a158beb13b kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 520 new_timer->sigq.info.si_value.sival_int = new_timer->it_id;
899921025b406a kernel/posix-timers.c Oleg Nesterov 2008-12-01 521 new_timer->it_pid = get_pid(task_tgid(current));
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 522 }
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 523
ef1c5bcd6daa67 kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 524 if (new_timer->it_sigev_notify & SIGEV_THREAD_ID)
ef1c5bcd6daa67 kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 525 new_timer->it_pid_type = PIDTYPE_PID;
ef1c5bcd6daa67 kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 526 else
ef1c5bcd6daa67 kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 527 new_timer->it_pid_type = PIDTYPE_TGID;
ef1c5bcd6daa67 kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 528
6017a158beb13b kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 529 new_timer->sigq.info.si_tid = new_timer->it_id;
6017a158beb13b kernel/time/posix-timers.c Thomas Gleixner 2024-11-05 530 new_timer->sigq.info.si_code = SI_TIMER;
717835d94d3e3d kernel/posix-timers.c Oleg Nesterov 2008-09-22 531
52f090b164b59c kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 532 if (copy_to_user(created_timer_id, &new_timer_id, sizeof (new_timer_id))) {
2b08de0073a569 kernel/posix-timers.c Andrey Vagin 2010-07-20 533 error = -EFAULT;
2b08de0073a569 kernel/posix-timers.c Andrey Vagin 2010-07-20 534 goto out;
2b08de0073a569 kernel/posix-timers.c Andrey Vagin 2010-07-20 535 }
52f090b164b59c kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 536 /*
391253b25f078d kernel/time/posix-timers.c Haofeng Li 2025-09-10 537 * After successful copy out, the timer ID is visible to user space
45ece9933d4a8e kernel/time/posix-timers.c Eric Dumazet 2025-03-08 538 * now but not yet valid because new_timer::signal low order bit is 1.
52f090b164b59c kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 539 *
52f090b164b59c kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 540 * Complete the initialization with the clock specific create
52f090b164b59c kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 541 * callback.
52f090b164b59c kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 542 */
838394fbf98997 kernel/posix-timers.c Thomas Gleixner 2011-02-01 543 error = kc->timer_create(new_timer);
45e0fffc8a7778 kernel/posix-timers.c Andrey Vagin 2010-05-24 544 if (error)
45e0fffc8a7778 kernel/posix-timers.c Andrey Vagin 2010-05-24 545 goto out;
45e0fffc8a7778 kernel/posix-timers.c Andrey Vagin 2010-05-24 546
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 547 /*
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 548 * timer::it_lock ensures that __lock_timer() observes a fully
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 549 * initialized timer when it observes a valid timer::it_signal.
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 550 *
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 551 * sighand::siglock is required to protect signal::posix_timers.
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 552 */
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 553 scoped_guard (spinlock_irq, &new_timer->it_lock) {
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 @554 guard(spinlock)(&current->sighand->siglock);
45ece9933d4a8e kernel/time/posix-timers.c Eric Dumazet 2025-03-08 555 /*
45ece9933d4a8e kernel/time/posix-timers.c Eric Dumazet 2025-03-08 556 * new_timer::it_signal contains the signal pointer with
45ece9933d4a8e kernel/time/posix-timers.c Eric Dumazet 2025-03-08 557 * bit 0 set, which makes it invalid for syscall operations.
45ece9933d4a8e kernel/time/posix-timers.c Eric Dumazet 2025-03-08 558 * Store the unmodified signal pointer to make it valid.
45ece9933d4a8e kernel/time/posix-timers.c Eric Dumazet 2025-03-08 559 */
028cf5eaa12846 kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 560 WRITE_ONCE(new_timer->it_signal, current->signal);
451898ea422b58 kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 561 hlist_add_head_rcu(&new_timer->list, &current->signal->posix_timers);
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 562 }
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 563 /*
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 564 * After unlocking @new_timer is subject to concurrent removal and
2389c6efd3ad8e kernel/time/posix-timers.c Thomas Gleixner 2025-03-08 565 * cannot be touched anymore
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 566 */
52f090b164b59c kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 567 return 0;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 568 out:
8cc96ca2c75f6d kernel/time/posix-timers.c Thomas Gleixner 2023-04-25 569 posix_timer_unhash_and_free(new_timer);
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 570 return error;
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 571 }
^1da177e4c3f41 kernel/posix-timers.c Linus Torvalds 2005-04-16 572

:::::: The code at line 554 was first introduced by commit
:::::: 2389c6efd3ad8edb3bcce0019b4edcc7d9c7de19 posix-timers: Ensure that timer initialization is fully visible

:::::: TO: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
:::::: CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

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