public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Leesoo Ahn <dev@ooseel.net>
Cc: linux-kernel@vger.kernel.org, Leesoo Ahn <lsahn@ooseel.net>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Jens Axboe <axboe@kernel.dk>,
	Peter Collingbourne <pcc@google.com>,
	Zhiqiang Liu <liuzhiqiang26@huawei.com>
Subject: Re: [PATCH] signal: Don't init struct kernel_siginfo fields to zero again
Date: Sun, 20 Dec 2020 15:21:35 +0100	[thread overview]
Message-ID: <20201220142134.GB16470@redhat.com> (raw)
In-Reply-To: <20201220074555.12655-1-lsahn@ooseel.net>

On 12/20, Leesoo Ahn wrote:
>
> clear_siginfo() is responsible for clearing struct kernel_siginfo object.
> It's obvious that manually initializing those fields is needless as
> a commit[1] explains why the function introduced and its guarantee that
> all bits in the struct are cleared after it.
>
> [1]: commit 8c5dbf2ae00b ("signal: Introduce clear_siginfo")
>
> Signed-off-by: Leesoo Ahn <lsahn@ooseel.net>

Acked-by: Oleg Nesterov <oleg@redhat.com>


> ---
>  kernel/signal.c | 21 ---------------------
>  1 file changed, 21 deletions(-)
> 
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 5736c55aaa1a..8f49fa3ade33 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -603,10 +603,7 @@ static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *i
>  		 */
>  		clear_siginfo(info);
>  		info->si_signo = sig;
> -		info->si_errno = 0;
>  		info->si_code = SI_USER;
> -		info->si_pid = 0;
> -		info->si_uid = 0;
>  	}
>  }
>  
> @@ -1120,7 +1117,6 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struc
>  		case (unsigned long) SEND_SIG_NOINFO:
>  			clear_siginfo(&q->info);
>  			q->info.si_signo = sig;
> -			q->info.si_errno = 0;
>  			q->info.si_code = SI_USER;
>  			q->info.si_pid = task_tgid_nr_ns(current,
>  							task_active_pid_ns(t));
> @@ -1133,10 +1129,7 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struc
>  		case (unsigned long) SEND_SIG_PRIV:
>  			clear_siginfo(&q->info);
>  			q->info.si_signo = sig;
> -			q->info.si_errno = 0;
>  			q->info.si_code = SI_KERNEL;
> -			q->info.si_pid = 0;
> -			q->info.si_uid = 0;
>  			break;
>  		default:
>  			copy_siginfo(&q->info, info);
> @@ -1623,10 +1616,7 @@ void force_sig(int sig)
>  
>  	clear_siginfo(&info);
>  	info.si_signo = sig;
> -	info.si_errno = 0;
>  	info.si_code = SI_KERNEL;
> -	info.si_pid = 0;
> -	info.si_uid = 0;
>  	force_sig_info(&info);
>  }
>  EXPORT_SYMBOL(force_sig);
> @@ -1659,7 +1649,6 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr
>  
>  	clear_siginfo(&info);
>  	info.si_signo = sig;
> -	info.si_errno = 0;
>  	info.si_code  = code;
>  	info.si_addr  = addr;
>  #ifdef __ARCH_SI_TRAPNO
> @@ -1691,7 +1680,6 @@ int send_sig_fault(int sig, int code, void __user *addr
>  
>  	clear_siginfo(&info);
>  	info.si_signo = sig;
> -	info.si_errno = 0;
>  	info.si_code  = code;
>  	info.si_addr  = addr;
>  #ifdef __ARCH_SI_TRAPNO
> @@ -1712,7 +1700,6 @@ int force_sig_mceerr(int code, void __user *addr, short lsb)
>  	WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
>  	clear_siginfo(&info);
>  	info.si_signo = SIGBUS;
> -	info.si_errno = 0;
>  	info.si_code = code;
>  	info.si_addr = addr;
>  	info.si_addr_lsb = lsb;
> @@ -1726,7 +1713,6 @@ int send_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *
>  	WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
>  	clear_siginfo(&info);
>  	info.si_signo = SIGBUS;
> -	info.si_errno = 0;
>  	info.si_code = code;
>  	info.si_addr = addr;
>  	info.si_addr_lsb = lsb;
> @@ -1740,7 +1726,6 @@ int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper)
>  
>  	clear_siginfo(&info);
>  	info.si_signo = SIGSEGV;
> -	info.si_errno = 0;
>  	info.si_code  = SEGV_BNDERR;
>  	info.si_addr  = addr;
>  	info.si_lower = lower;
> @@ -1755,7 +1740,6 @@ int force_sig_pkuerr(void __user *addr, u32 pkey)
>  
>  	clear_siginfo(&info);
>  	info.si_signo = SIGSEGV;
> -	info.si_errno = 0;
>  	info.si_code  = SEGV_PKUERR;
>  	info.si_addr  = addr;
>  	info.si_pkey  = pkey;
> @@ -1934,7 +1918,6 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
>  
>  	clear_siginfo(&info);
>  	info.si_signo = sig;
> -	info.si_errno = 0;
>  	/*
>  	 * We are under tasklist_lock here so our parent is tied to
>  	 * us and cannot change.
> @@ -2033,7 +2016,6 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
>  
>  	clear_siginfo(&info);
>  	info.si_signo = SIGCHLD;
> -	info.si_errno = 0;
>  	/*
>  	 * see comment in do_notify_parent() about the following 4 lines
>  	 */
> @@ -2506,7 +2488,6 @@ static int ptrace_signal(int signr, kernel_siginfo_t *info)
>  	if (signr != info->si_signo) {
>  		clear_siginfo(info);
>  		info->si_signo = signr;
> -		info->si_errno = 0;
>  		info->si_code = SI_USER;
>  		rcu_read_lock();
>  		info->si_pid = task_pid_vnr(current->parent);
> @@ -3660,7 +3641,6 @@ static inline void prepare_kill_siginfo(int sig, struct kernel_siginfo *info)
>  {
>  	clear_siginfo(info);
>  	info->si_signo = sig;
> -	info->si_errno = 0;
>  	info->si_code = SI_USER;
>  	info->si_pid = task_tgid_vnr(current);
>  	info->si_uid = from_kuid_munged(current_user_ns(), current_uid());
> @@ -3833,7 +3813,6 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig)
>  
>  	clear_siginfo(&info);
>  	info.si_signo = sig;
> -	info.si_errno = 0;
>  	info.si_code = SI_TKILL;
>  	info.si_pid = task_tgid_vnr(current);
>  	info.si_uid = from_kuid_munged(current_user_ns(), current_uid());
> -- 
> 2.26.2
> 


  reply	other threads:[~2020-12-20 14:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20  7:45 [PATCH] signal: Don't init struct kernel_siginfo fields to zero again Leesoo Ahn
2020-12-20 14:21 ` Oleg Nesterov [this message]
2020-12-20 15:43   ` Rae Kim
2020-12-20 16:03     ` Christian Brauner
2020-12-21 11:38     ` Leesoo Ahn
2020-12-20 15:25 ` Christian Brauner
2020-12-21 18:36 ` Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201220142134.GB16470@redhat.com \
    --to=oleg@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=christian.brauner@ubuntu.com \
    --cc=dev@ooseel.net \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=lsahn@ooseel.net \
    --cc=pcc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox