Skip to contentSkip to conversation

signal: propagate __user annotations properly

PATCH In review Lukas Bulwahn 2 participants 3 messages Dec 7, 2020 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 signal: propagate __user annotations properly

Commit 3eb39f47934f ("signal: add pidfd_send_signal() syscall") introduced copy_siginfo_from_user_any(), but missed to add the __user annotation to the user pointer that is passed as second argument.

Hence, when copy_siginfo_from_user_any() calls copy_siginfo_from_user(), sparse warns:

kernel/signal.c:3716:46: warning: incorrect type in argument 2 (different address spaces)
kernel/signal.c:3716:46: expected struct siginfo const [noderef] [usertype] __user *from
kernel/signal.c:3716:46: got struct siginfo [usertype] *info

And when pidfd_send_signal() calls copy_siginfo_from_user_any(), sparse warns as well:

kernel/signal.c:3776:58: warning: incorrect type in argument 2 (different address spaces)
kernel/signal.c:3776:58: expected struct siginfo [usertype] *info
kernel/signal.c:3776:58: got struct siginfo [noderef] [usertype] __user *info

Add the __user annotation to repair this chain of propagating __user annotations.

---
applies cleanly on current master (v5.10-rc7) and next-20201204

Christian, please pick this minor non-urgent clean-up patch.

 kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/signal.c +1 -1
index 5736c55aaa1a..e969b3bc815f 100644
@@ -3701,7 +3701,7 @@ static bool access_pidfd_pidns(struct pid *pid)
 	return true;
 }
 
-static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo, siginfo_t *info)
+static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo, siginfo_t __user *info)
 {
 #ifdef CONFIG_COMPAT
 	/*
Signature · 1 line
2.17.1
#1 lore raw
Quoted 18 lines · Lukas Bulwahn

Commit 3eb39f47934f ("signal: add pidfd_send_signal() syscall") introduced copy_siginfo_from_user_any(), but missed to add the __user annotation to the user pointer that is passed as second argument.

Hence, when copy_siginfo_from_user_any() calls copy_siginfo_from_user(), sparse warns:

kernel/signal.c:3716:46: warning: incorrect type in argument 2 (different address spaces)
kernel/signal.c:3716:46: expected struct siginfo const [noderef] [usertype] __user *from
kernel/signal.c:3716:46: got struct siginfo [usertype] *info

And when pidfd_send_signal() calls copy_siginfo_from_user_any(), sparse warns as well:

kernel/signal.c:3776:58: warning: incorrect type in argument 2 (different address spaces)
kernel/signal.c:3776:58: expected struct siginfo [usertype] *info
kernel/signal.c:3776:58: got struct siginfo [noderef] [usertype] __user *info

Quoted 8 lines

Add the __user annotation to repair this chain of propagating __user annotations.

---
applies cleanly on current master (v5.10-rc7) and next-20201204

Christian, please pick this minor non-urgent clean-up patch.

Thanks for the patch. Unfortunately I already picked up Jann's patch who sent it yesterday or this morning:
https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=pidfd

Thanks!
Christian

#2 lore raw
Quoted 27 lines · Christian Brauner
Quoted 25 lines · Lukas Bulwahn

Commit 3eb39f47934f ("signal: add pidfd_send_signal() syscall") introduced copy_siginfo_from_user_any(), but missed to add the __user annotation to the user pointer that is passed as second argument.

Hence, when copy_siginfo_from_user_any() calls copy_siginfo_from_user(), sparse warns:

kernel/signal.c:3716:46: warning: incorrect type in argument 2 (different address spaces)
kernel/signal.c:3716:46: expected struct siginfo const [noderef] [usertype] __user *from
kernel/signal.c:3716:46: got struct siginfo [usertype] *info

And when pidfd_send_signal() calls copy_siginfo_from_user_any(), sparse warns as well:

kernel/signal.c:3776:58: warning: incorrect type in argument 2 (different address spaces)
kernel/signal.c:3776:58: expected struct siginfo [usertype] *info
kernel/signal.c:3776:58: got struct siginfo [noderef] [usertype] __user *info

Add the __user annotation to repair this chain of propagating __user annotations.

---
applies cleanly on current master (v5.10-rc7) and next-20201204

Quoted 6 lines
Quoted 1 line

Christian, please pick this minor non-urgent clean-up patch.

Thanks for the patch. Unfortunately I already picked up Jann's patch who sent it yesterday or this morning:
https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=pidfd

Thanks for letting me know and good to know that Jann is tracking those sparse warnings as well :)

Lukas