Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1333218pxb; Fri, 13 Nov 2020 09:54:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqoyTtOKjyLI11d4KBBPFnG6WR5a236ZkBTW4TKzld6NxCRO7JPILa26YrO/YEFje9Tnjw X-Received: by 2002:a50:ef03:: with SMTP id m3mr3658607eds.212.1605290083278; Fri, 13 Nov 2020 09:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605290083; cv=none; d=google.com; s=arc-20160816; b=GQ+Z9QtN6xXA4mbR9hcXqtxOVhIVgtSWr5gf4mDwgcXrhXjSXdlmZXtL0ZfafOKKgS gnGVLVPDZjA/9yH8xBgFpz4Z7DtpO0rpA752UrLpTdtJbmxJHI6qUVzyeJ7UP3H8ZDdi k7NSpxyYqIBiAp8xwj9vYpm+ljXthttfMAnjhv3+1BtHynXLms1UVM+eToO9ua/H7puH PkoxnwO5B+w/McK2v0ekqh0bpB7llWahu9fmFcNUFwrUu8CuUnTzm8OYfq1Of4BIu0RU QX2WiK4015bGjz7bS4q4V/LBMDUhH2SZl0CuW24pTzcFuDC3uMWdSW+/XeS5FIPxRKxV 7T7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zuo3X1dUSZS5dZ8jl01PZiwsfvErikn3kiTlWYen878=; b=NgBpDYtKnDK4p44WGJRQafIoD3RWHJ/T2IxdAwxBSUH70FbaPJouz28Bad6tJL5iPX KnldkAMtMO99HrFA9j0iIT1Ky17fMkuNGXzvT9orhUVhT7QHa4bwbQbP/CKbZw+4hMEh pKXg+sUozbutwQiHAF/uo5KcDp4iH76QjFt4PB2PU072m3Lt0nLE54+owOUDaaLHcu+2 J0JBbAYZtlmzs0BMaXmwkeFEcJ+00vmzIPC8qzAbfN3SgO8HxMcb0EVmfls+Y43U8bZv 6eb5aHB2PVzV8SHVbgSRvdRiedNnpuZedz0RPQ8y/hXbUEkDL/b8kyeegM/e3sWSD37C hDbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PDEdUPWc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si6240910ejf.460.2020.11.13.09.54.20; Fri, 13 Nov 2020 09:54:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PDEdUPWc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726196AbgKMRxE (ORCPT + 99 others); Fri, 13 Nov 2020 12:53:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgKMRxE (ORCPT ); Fri, 13 Nov 2020 12:53:04 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B574EC0613D1 for ; Fri, 13 Nov 2020 09:53:03 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id l1so10841107wrb.9 for ; Fri, 13 Nov 2020 09:53:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zuo3X1dUSZS5dZ8jl01PZiwsfvErikn3kiTlWYen878=; b=PDEdUPWc7YyVIg3Th+DIE6NoE2WAMuqAu9fM45HMRdj0lXPDGNKLcCyrkkeH6nW1oV bkyC+jfadDn+VRAA+1YMjmozcPoMKNyuyuFo58Rbe1Fm95uHf+OObYzsUueI87+2GTy1 mX7oAZmLT6dT8cN5G4dMLEpjh1bVhCUH/qvYCs1cxqhvBQot6qH1yFjxkdDUmDI5a9V4 yASHI1ag0Gd2ZJHgxGtCPX4o2uXbjFaXLXFeLB4mrYa+kB74GUSbEf30OSpRhP45fXHm NQ7sz7TIz+O/61FIG4IFAdyokMshSG8AoLRxztH3Q6V8GjbfKrnL757YAzYJTSJexrX8 DEWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zuo3X1dUSZS5dZ8jl01PZiwsfvErikn3kiTlWYen878=; b=nPkbgTqoco++8tUidD2O0qvs01QdcH40C3jxlXuZeiKg/EJY61flrJVMfFJ4BJKkyV 9wfg3bN5a1JhQRVzfzDMcNSgw+TSpFaEgTWhMZWgoCIiGt4kfQ9p3FBhdSW7PYitg0hC AcWXtWYEFUKC8kyXDypoZdgckyimJ/pfz2qsYLzSGjsFZPZTSIVqA4ZIuTsbJw+I/wMt lKRN1GCx5IcGfykn21jz2bnaaLH2BLnGW6y3ib8PebUbSX/AGrOxhIPZNtoCs5j49Eol BMAeXBRb4vRRfJtk4Pmx3cUTw6T5sU+BjP3g0TP1nObdpKDSPDQjIPJM+fac1CuVq5ff NYHw== X-Gm-Message-State: AOAM533JsJP2wtNIGWBNE5j1lrAlI5yExq0sX4tBFiVtpT//9SkpoRYH fjF7K8RXkMJYzy0iV40eTST6cw== X-Received: by 2002:a5d:488f:: with SMTP id g15mr4844283wrq.151.1605289981187; Fri, 13 Nov 2020 09:53:01 -0800 (PST) Received: from elver.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) by smtp.gmail.com with ESMTPSA id c6sm12676849wrh.74.2020.11.13.09.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 09:53:00 -0800 (PST) Date: Fri, 13 Nov 2020 18:52:54 +0100 From: Marco Elver To: Andrey Konovalov Cc: Dmitry Vyukov , Alexander Potapenko , Catalin Marinas , Will Deacon , Vincenzo Frascino , Evgenii Stepanov , Andrey Ryabinin , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 11/20] kasan: add and integrate kasan boot parameters Message-ID: <20201113175254.GA3175464@elver.google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.14.6 (2020-07-11) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 10, 2020 at 11:20PM +0100, 'Andrey Konovalov' via kasan-dev wrote: [...] > +/* kasan.mode=off/prod/full */ > +static int __init early_kasan_mode(char *arg) > +{ > + if (!arg) > + return -EINVAL; > + > + if (!strcmp(arg, "off")) > + kasan_arg_mode = KASAN_ARG_MODE_OFF; > + else if (!strcmp(arg, "prod")) > + kasan_arg_mode = KASAN_ARG_MODE_PROD; > + else if (!strcmp(arg, "full")) > + kasan_arg_mode = KASAN_ARG_MODE_FULL; > + else > + return -EINVAL; > + > + return 0; > +} > +early_param("kasan.mode", early_kasan_mode); > + > +/* kasan.stack=off/on */ > +static int __init early_kasan_flag_stacktrace(char *arg) > +{ > + if (!arg) > + return -EINVAL; > + > + if (!strcmp(arg, "off")) > + kasan_arg_stacktrace = KASAN_ARG_STACKTRACE_OFF; > + else if (!strcmp(arg, "on")) > + kasan_arg_stacktrace = KASAN_ARG_STACKTRACE_ON; > + else > + return -EINVAL; > + > + return 0; > +} > +early_param("kasan.stacktrace", early_kasan_flag_stacktrace); > + > +/* kasan.fault=report/panic */ > +static int __init early_kasan_fault(char *arg) > +{ > + if (!arg) > + return -EINVAL; > + > + if (!strcmp(arg, "report")) > + kasan_arg_fault = KASAN_ARG_FAULT_REPORT; > + else if (!strcmp(arg, "panic")) > + kasan_arg_fault = KASAN_ARG_FAULT_PANIC; > + else > + return -EINVAL; > + > + return 0; > +} [...] The above could be simplified, see suggestion below. Thanks, -- Marco ------ >8 ------ diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c index c91f2c06ecb5..71fc481ad21d 100644 --- a/mm/kasan/hw_tags.c +++ b/mm/kasan/hw_tags.c @@ -64,10 +64,8 @@ static int __init early_kasan_mode(char *arg) kasan_arg_mode = KASAN_ARG_MODE_PROD; else if (!strcmp(arg, "full")) kasan_arg_mode = KASAN_ARG_MODE_FULL; - else - return -EINVAL; - return 0; + return -EINVAL; } early_param("kasan.mode", early_kasan_mode); @@ -81,10 +79,8 @@ static int __init early_kasan_flag_stacktrace(char *arg) kasan_arg_stacktrace = KASAN_ARG_STACKTRACE_OFF; else if (!strcmp(arg, "on")) kasan_arg_stacktrace = KASAN_ARG_STACKTRACE_ON; - else - return -EINVAL; - return 0; + return -EINVAL; } early_param("kasan.stacktrace", early_kasan_flag_stacktrace); @@ -98,10 +94,8 @@ static int __init early_kasan_fault(char *arg) kasan_arg_fault = KASAN_ARG_FAULT_REPORT; else if (!strcmp(arg, "panic")) kasan_arg_fault = KASAN_ARG_FAULT_PANIC; - else - return -EINVAL; - return 0; + return -EINVAL; } early_param("kasan.fault", early_kasan_fault);