From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753089AbdKIRa2 (ORCPT ); Thu, 9 Nov 2017 12:30:28 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33756 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdKIRa0 (ORCPT ); Thu, 9 Nov 2017 12:30:26 -0500 Date: Thu, 9 Nov 2017 23:00:12 +0530 From: Ananth N Mavinakayanahalli To: David Howells Cc: alexei.starovoitov@gmail.com, Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH] Lock down kprobes Reply-To: ananth@linux.vnet.ibm.com References: <11786.1510246325@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11786.1510246325@warthog.procyon.org.uk> User-Agent: Mutt/1.9.1 (2017-09-22) X-TM-AS-GCONF: 00 x-cbid: 17110917-0056-0000-0000-000003E6FF99 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008039; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00943472; UDB=6.00476021; IPR=6.00723756; BA=6.00005682; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017937; XFM=3.00000015; UTC=2017-11-09 17:30:24 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110917-0057-0000-0000-0000081E1975 Message-Id: <20171109173012.GA23619@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-09_06:,, 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-1707230000 definitions=main-1711090236 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 09, 2017 at 04:52:05PM +0000, David Howells wrote: > Hi, > > I need to lock down kprobes under secure boot conditions as part of the patch > series that can be found here: > > https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down > > Can you tell me that if the attached patch is sufficient to the cause? Yes, this patch will prevent any kprobe registration. Ananth > > Thanks, > David > --- > commit ffb3484d6e0f1d625f8e84a6a19c139a28a52499 > Author: David Howells > Date: Wed Nov 8 16:14:12 2017 +0000 > > Lock down kprobes > > Disallow the creation of kprobes when the kernel is locked down by > preventing their registration. This prevents kprobes from being used to > access kernel memory, either to make modifications or to steal crypto data. > > Reported-by: Alexei Starovoitov > Signed-off-by: David Howells > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index a1606a4224e1..f06023b0936c 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -1530,6 +1530,9 @@ int register_kprobe(struct kprobe *p) > struct module *probed_mod; > kprobe_opcode_t *addr; > > + if (kernel_is_locked_down("Use of kprobes")) > + return -EPERM; > + > /* Adjust probe address from symbol */ > addr = kprobe_addr(p); > if (IS_ERR(addr))