Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932791AbeALBCb (ORCPT + 1 other); Thu, 11 Jan 2018 20:02:31 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:35564 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933784AbeALBBk (ORCPT ); Thu, 11 Jan 2018 20:01:40 -0500 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: Al Viro , Oleg Nesterov , linux-arch@vger.kernel.org, "Eric W. Biederman" Date: Thu, 11 Jan 2018 18:59:38 -0600 Message-Id: <20180112005940.23279-9-ebiederm@xmission.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <87373b6ghs.fsf@xmission.com> References: <87373b6ghs.fsf@xmission.com> X-XM-SPF: eid=1eZnj1-00053y-8Q;;;mid=<20180112005940.23279-9-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.121.73.102;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/6gb9/7mMGug/9dJK4FqIK98pDC5T+Up0= X-SA-Exim-Connect-IP: 97.121.73.102 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [PATCH 09/11] signal: Reduce copy_siginfo to just a memcpy X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: The savings for copying just part of struct siginfo appears to be in the noise on modern machines. So remove this ``optimization'' and simplify the code. At the same time mark the second parameter as constant so there is no confusion as to which direction the copy will go. This ensures that a fully initialized siginfo that is sent ends up as a fully initialized siginfo on the signal queue. This full initialization ensures even confused code won't copy unitialized data to userspace, and it prepares for turning copy_siginfo_to_user into a simple copy_to_user. Signed-off-by: "Eric W. Biederman" --- include/linux/signal.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/linux/signal.h b/include/linux/signal.h index 042968dd98f0..8037b503ce91 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -11,13 +11,9 @@ struct task_struct; /* for sysctl */ extern int print_fatal_signals; -static inline void copy_siginfo(struct siginfo *to, struct siginfo *from) +static inline void copy_siginfo(struct siginfo *to, const struct siginfo *from) { - if (from->si_code < 0) - memcpy(to, from, sizeof(*to)); - else - /* _sigchld is currently the largest know union member */ - memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld)); + memcpy(to, from, sizeof(*to)); } int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from); -- 2.14.1