Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3769274ybh; Tue, 6 Aug 2019 01:01:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3sjIZqC/JBoY+CadfGM3rplFYxdK8lnukXJ5GWifHbTw3SCy6jbeTr5akAowkopb+sKtu X-Received: by 2002:aa7:8e18:: with SMTP id c24mr2389976pfr.24.1565078463938; Tue, 06 Aug 2019 01:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565078463; cv=none; d=google.com; s=arc-20160816; b=s+zkY2XFO4lZakd7iUiHnw08/uc2L3smF+Vp5UMhXYLjntPHALJC+dlNLm9jcakFk0 fIrCxcxCXpdINSWZ54P/ARJ3ZSA0KLaTWkk3pbCSobwFIdhBVWL65oWUbtcropkgNB0w kXzYzpePtCCUPNi34dZ5RKrWk95jWaJqZS+tCWlYrmoTLaLeR1E6V312GWd6D0Y7HFnT HdyGDBAOQISPdRvwbqF86ClllPTn/Qr51g1bABIb25Xx4ms0k7Q5RMv8hTrZ6B7YIMKA TgHgJWDJSSSvc03dO73V/wTrcsk30tj6azEInA637eFYx/8f5VSdvaKYabBe6yrEhi3n zFXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=5YDv6dgHqzqllJC8kOdquh3d9tD4kkNE+Dq/5rv/yKs=; b=rw10ayxUHU+w8TZhHu0qFv0KUAWlDnNH+MePccXyJQ9OFugJAGF2IYh2LNK4qBF0yK yXRNeHkugJrjRYhuwksiBYk/XkvZHMgfN8n7lMXmWJ7k3OTB6M2QBmmdFh4qPLmOSHxh DY1iBRWyhMshhZ5nUYg9+EHROxvMHoYyA3jc3Fshj+6jq0uqK57wl3jsT40szTnVf/dx a0lzNV+ue7So2rpk3vNuak2jEBPY3XgGD4mMGBLmvP7PDj018Pc2r5X3Sr1lvtpHSaTA Uvythlad1Qi4Xbm4JCpPcfuzluq4ODfXRFjrzE6D7LgZh/qC7saK536xysV0y8GiPXtX 6QUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=KFxQJm9j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23si14270010pjv.56.2019.08.06.01.00.48; Tue, 06 Aug 2019 01:01:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=KFxQJm9j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732198AbfHFH73 (ORCPT + 99 others); Tue, 6 Aug 2019 03:59:29 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:34372 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728056AbfHFH73 (ORCPT ); Tue, 6 Aug 2019 03:59:29 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 462n8t4vmJz9txY9; Tue, 6 Aug 2019 09:59:26 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=KFxQJm9j; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id eVrhqiZLxRqx; Tue, 6 Aug 2019 09:59:26 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 462n8t3n2Vz9txYC; Tue, 6 Aug 2019 09:59:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1565078366; bh=5YDv6dgHqzqllJC8kOdquh3d9tD4kkNE+Dq/5rv/yKs=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=KFxQJm9jm+lxXqyhh6dliy3lQUqobK1qGDV7RjvFSl3PoKQSYuhWGF/pKMVIMfMdW /pqEOIY6pXA1umTwCLQafvpwujltnxD7WzRA3bC5bWspTt4n4pzeq//6UBzXjt4prz 2MiJS42SMHOtAlHV37pdB+evxeLnlJIC3jFcBrIU= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 821698B75F; Tue, 6 Aug 2019 09:59:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Bv8rgec24Mhz; Tue, 6 Aug 2019 09:59:27 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B58558B7E2; Tue, 6 Aug 2019 09:59:26 +0200 (CEST) Subject: Re: [PATCH v4 09/10] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter To: Jason Yan , mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, diana.craciun@nxp.com, benh@kernel.crashing.org, paulus@samba.org, npiggin@gmail.com, keescook@chromium.org, kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org, wangkefeng.wang@huawei.com, yebin10@huawei.com, thunder.leizhen@huawei.com, jingxiangfeng@huawei.com, fanchengyang@huawei.com, zhaohongjiang@huawei.com References: <20190805064335.19156-1-yanaijie@huawei.com> <20190805064335.19156-10-yanaijie@huawei.com> From: Christophe Leroy Message-ID: Date: Tue, 6 Aug 2019 09:59:26 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190805064335.19156-10-yanaijie@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 05/08/2019 à 08:43, Jason Yan a écrit : > One may want to disable kaslr when boot, so provide a cmdline parameter > 'nokaslr' to support this. > > Signed-off-by: Jason Yan > Cc: Diana Craciun > Cc: Michael Ellerman > Cc: Christophe Leroy > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Nicholas Piggin > Cc: Kees Cook > Reviewed-by: Diana Craciun > Tested-by: Diana Craciun Reviewed-by: Christophe Leroy Tiny comment below. > --- > arch/powerpc/kernel/kaslr_booke.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/arch/powerpc/kernel/kaslr_booke.c b/arch/powerpc/kernel/kaslr_booke.c > index 4b3f19a663fc..7c3cb41e7122 100644 > --- a/arch/powerpc/kernel/kaslr_booke.c > +++ b/arch/powerpc/kernel/kaslr_booke.c > @@ -361,6 +361,18 @@ static unsigned long __init kaslr_choose_location(void *dt_ptr, phys_addr_t size > return kaslr_offset; > } > > +static inline __init bool kaslr_disabled(void) > +{ > + char *str; > + > + str = strstr(boot_command_line, "nokaslr"); > + if ((str == boot_command_line) || > + (str > boot_command_line && *(str - 1) == ' ')) > + return true; I don't think additional () are needed for the left part 'str == boot_command_line' > + > + return false; > +} > + > /* > * To see if we need to relocate the kernel to a random offset > * void *dt_ptr - address of the device tree > @@ -376,6 +388,8 @@ notrace void __init kaslr_early_init(void *dt_ptr, phys_addr_t size) > kernel_sz = (unsigned long)_end - KERNELBASE; > > kaslr_get_cmdline(dt_ptr); > + if (kaslr_disabled()) > + return; > > offset = kaslr_choose_location(dt_ptr, size, kernel_sz); > >