Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4898233ybh; Tue, 6 Aug 2019 20:31:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwko41vHM3SGL+ibaJkudkJxaqAXQ+uSijk3pjVhG3Ji08zG0Ev1zBeBZYvGFSBkmEQ1pJE X-Received: by 2002:a17:90a:2008:: with SMTP id n8mr6267951pjc.4.1565148674731; Tue, 06 Aug 2019 20:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565148674; cv=none; d=google.com; s=arc-20160816; b=WMsUQIMQuRVh+1B3X0BbSurNhN26uaaiKxcjdJ6HsNzmcJT7orhHfnD9OxLn90ecgz of+3j+KA1ecg5zpdBsfMNvvHqX5mXr3Y2yCjBmz5/oZSg6Iip6VWXvDBloWYpv/LdJ7j vWjW3FvgOLMQ9yPkXggd48CGywS1Ar0pCGaWFZkgUNPxPBkCqpBRNxlEfJ7mnSa83Pjp JpmWcfVGW3v2N0sGDNn71OnHYt27iczLFSjdGeCgNhx4xr2DRjfjlgFZlQc+6d4WeylA fzKa9Rzul1pxmWQH22DhSLZUPN1mvnT9cBYgVrvBGOBk3TZn9giBCm++9NNMTswqmzLu 9rtQ== 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; bh=zkbaYYFqtHt5akl9BmU52TRWjLxdL6uqGtS77H/iFuU=; b=Z6AWXWspmOWCHO11qctO4YoVWrIz/mQsdJXSldkvn77u1ahGgkaXNY95qYU0bm4eSZ +4aS8bqs05QBR0Qo0AlgGFeMy4X1dI2ybG603eQS/I9tRkAUAQQOpYfYl08QBCm54BKP YAG98SmM85tPl2bGEp3h3+KdbdQ7dRUfmMap0Oe2hYRMmC5bXcj3aC7wDn0/PwgN15jW NNzyAnJsPbi5ux4Zc21ME51vePA+xVU/BolZv7jj59Lmid+lldB0U7EQglU3WMBb0ek8 mdYllaEU7aHn8fAkSv9dJ0XBKdz6PTaua4p5fmB3SIpBM5khUQ216KXQzFJoLKnySKsd OF7w== ARC-Authentication-Results: i=1; mx.google.com; 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 v24si10311496pgn.64.2019.08.06.20.30.57; Tue, 06 Aug 2019 20:31:14 -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; 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 S1728150AbfHGDWa (ORCPT + 99 others); Tue, 6 Aug 2019 23:22:30 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:42358 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726334AbfHGDWa (ORCPT ); Tue, 6 Aug 2019 23:22:30 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E7D4756A99E4D96D9800; Wed, 7 Aug 2019 11:22:24 +0800 (CST) Received: from [127.0.0.1] (10.177.96.203) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Wed, 7 Aug 2019 11:22:16 +0800 Subject: Re: [PATCH v4 09/10] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter To: Christophe Leroy , , , , , , , , CC: , , , , , , References: <20190805064335.19156-1-yanaijie@huawei.com> <20190805064335.19156-10-yanaijie@huawei.com> From: Jason Yan Message-ID: <3a83c812-ac14-3e89-241e-eeade105d23e@huawei.com> Date: Wed, 7 Aug 2019 11:22:14 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.96.203] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/8/6 15:59, Christophe Leroy wrote: > > > 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' > Agree. >> + >> +    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); >> > > . >