From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932206AbeAXT0p (ORCPT ); Wed, 24 Jan 2018 14:26:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41702 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752450AbeAXT0n (ORCPT ); Wed, 24 Jan 2018 14:26:43 -0500 Date: Wed, 24 Jan 2018 11:26:32 -0800 From: Ram Pai To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Al Viro , Oleg Nesterov , linux-arch@vger.kernel.org Subject: Re: [PATCH 06/10] signal: Helpers for faults with specialized siginfo layouts Reply-To: Ram Pai References: <87607s5lra.fsf_-_@xmission.com> <20180123210719.10456-6-ebiederm@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180123210719.10456-6-ebiederm@xmission.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18012419-0008-0000-0000-000004C57333 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18012419-0009-0000-0000-00001E58F7F6 Message-Id: <20180124192632.GA6671@ram.oc3035372033.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-24_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801240256 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 23, 2018 at 03:07:15PM -0600, Eric W. Biederman wrote: > The helpers added are: > send_sig_mceerr > force_sig_mceerr > force_sig_bnderr > force_sig_pkuerr > > Filling out siginfo properly can ge tricky. Especially for these > specialized cases where the temptation is to share code with other > cases which use a different subset of siginfo fields. Unfortunately > that code sharing frequently results in bugs with the wrong siginfo > fields filled in, and makes it harder to verify that the siginfo > structure was properly initialized. > > Provide these helpers instead that get all of the details right, and > guarantee that siginfo is properly initialized. > > send_sig_mceerr and force_sig_mceer are a little special as two si > codes BUS_MCEERR_AO and BUS_MCEER_AR both use the same extended > signinfo layout. nice. i can make use of these helpers in the memory-key implementation. One small nit-pick below though... > > Signed-off-by: "Eric W. Biederman" > --- > include/linux/sched/signal.h | 6 +++++ > kernel/signal.c | 61 ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 67 insertions(+) > > diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h ...snip.. > + > +#ifdef SEGV_PKUERR Should this really be under SEGV_PKUERR ? that macro is defined unconditionally anyway. > +int force_sig_pkuerr(void __user *addr, u32 pkey) > +{ > + struct siginfo info; > + > + clear_siginfo(&info); > + info.si_signo = SIGSEGV; > + info.si_errno = 0; > + info.si_code = SEGV_PKUERR; > + info.si_addr = addr; > + info.si_pkey = pkey; > + return force_sig_info(info.si_signo, &info, current); > +} > +#endif