From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E475C4360C for ; Wed, 16 Oct 2019 10:12:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D6A8320650 for ; Wed, 16 Oct 2019 10:12:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oXbT4hNK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6A8320650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8266F8E000B; Wed, 16 Oct 2019 06:12:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D51A8E0001; Wed, 16 Oct 2019 06:12:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C3D38E000B; Wed, 16 Oct 2019 06:12:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 4B6CE8E0001 for ; Wed, 16 Oct 2019 06:12:01 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id D22D7180025C5 for ; Wed, 16 Oct 2019 10:12:00 +0000 (UTC) X-FDA: 76049232000.06.women81_68d2fe3bb822a X-HE-Tag: women81_68d2fe3bb822a X-Filterd-Recvd-Size: 6255 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Oct 2019 10:12:00 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id i16so19559165oie.4 for ; Wed, 16 Oct 2019 03:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fIAc7kYct8VpQ13hbYyhIsPB/WrvUenHD8qPKsYEDRE=; b=oXbT4hNKhD2uIHDdhfwvtPdiz9aqjjELCUA3i1w6gPw4XwKjzXNwIigRbIWeWKfmtp 9qdDj2ni9pzSrplpKkx6aKJJH5BVecMXKEjfRmExaUQkbwL6Dcg7EvK1RR+mqTWacUYW afiIQ1D+Zlqg++/0laoXe2Ar+6NnZo12uopWOpdTgCHSz/6ivR0s4meXhFjXftUJnn5E u99AwkDRQkUgDT8393Wwhx2I27Lqxuw4M8b1GclfRCON2hDd079wooQGxrYr/N6VM1o7 IGBUyL45BfGQHihicMGzaYaw8u+pWwx2np1kLJ+F05A8Q1PHCL/cTaM4Mc7EM/5Ao3v8 pcig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fIAc7kYct8VpQ13hbYyhIsPB/WrvUenHD8qPKsYEDRE=; b=rzKr9LU0YRki6G68e3RfyHCRIKm1jY/1lCR5uYuc+GrdxCiErVisRYf05uDAvWF7cC IAAM+1wXl7rBurK85XlXv47TdD6UM1fqwKfBWa9i1hIgHO2pguXHrfP7DY6Xq+40ijxM pG6TmEruu6ieC5gNKKeuNKObp/ydDuGJHdj7TXREFNC4XxwxyjLjIR/PeQFBA2Gbl9FD bg1MUSH7mWSyg7F1tZZRz7KiownM5jCa/pohTm8HE8uWmhDhFlsK+zlqrgSH7JpHA+AJ lt7Z25f1Tj30acGOrzS+AFs1qVY1MP+/KT32jvd8QC4b49jdu4SYaKMGmVfRVXhmmMNT 8Sgw== X-Gm-Message-State: APjAAAVnIrzeBCSw+ftB68a7U1rfVSEASl2mHvy1zbaqykfckNWl85LO k1YaGuNCvA33abwa/UFa0qAuKf2w0FSC9dqv1AWVGZ8u X-Google-Smtp-Source: APXvYqzFzZuHz7bFYr0F46QP6TS5NUe9LqN11QyJ2UWcNxcs1w4oo6ZYum/5vBnHKrmP1nIOu2j9iO3oDTxaRC/J2Xg= X-Received: by 2002:aca:dad6:: with SMTP id r205mr2642336oig.6.1571220719443; Wed, 16 Oct 2019 03:11:59 -0700 (PDT) MIME-Version: 1.0 References: <20191012122918.8066-1-mayhs11saini@gmail.com> <20191014022543.GA2674@ubuntu-m2-xlarge-x86> In-Reply-To: <20191014022543.GA2674@ubuntu-m2-xlarge-x86> From: Shyam Saini Date: Wed, 16 Oct 2019 15:41:39 +0530 Message-ID: Subject: Re: [PATCH] kernel: dma: Make CMA boot parameters __ro_after_init To: Nathan Chancellor Cc: Kernel Hardening , iommu@lists.linux-foundation.org, linux-kernel , linux-mm , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Matthew Wilcox , Christopher Lameter , Kees Cook , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Nathan, On Mon, Oct 14, 2019 at 7:55 AM Nathan Chancellor wrote: > > On Sat, Oct 12, 2019 at 05:59:18PM +0530, Shyam Saini wrote: > > This parameters are not changed after early boot. > > By making them __ro_after_init will reduce any attack surface in the > > kernel. > > > > Link: https://lwn.net/Articles/676145/ > > Cc: Christoph Hellwig > > Cc: Marek Szyprowski > > Cc: Robin Murphy > > Cc: Matthew Wilcox > > Cc: Christopher Lameter > > Cc: Kees Cook > > Signed-off-by: Shyam Saini > > --- > > kernel/dma/contiguous.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c > > index 69cfb4345388..1b689b1303cd 100644 > > --- a/kernel/dma/contiguous.c > > +++ b/kernel/dma/contiguous.c > > @@ -42,10 +42,10 @@ struct cma *dma_contiguous_default_area; > > * Users, who want to set the size of global CMA area for their system > > * should use cma= kernel parameter. > > */ > > -static const phys_addr_t size_bytes = (phys_addr_t)CMA_SIZE_MBYTES * SZ_1M; > > -static phys_addr_t size_cmdline = -1; > > -static phys_addr_t base_cmdline; > > -static phys_addr_t limit_cmdline; > > +static const phys_addr_t __ro_after_init size_bytes = (phys_addr_t)CMA_SIZE_MBYTES * SZ_1M; > > The 0day bot reported an issue with this change with clang: > > https://groups.google.com/d/msgid/clang-built-linux/201910140334.nhultlt8%25lkp%40intel.com > > kernel/dma/contiguous.c:46:36: error: 'size_cmdline' causes a section type conflict with 'size_bytes' > static phys_addr_t __ro_after_init size_cmdline = -1; > ^ > kernel/dma/contiguous.c:45:42: note: declared here > static const phys_addr_t __ro_after_init size_bytes = (phys_addr_t)CMA_SIZE_MBYTES * SZ_1M; > ^ > kernel/dma/contiguous.c:47:36: error: 'base_cmdline' causes a section type conflict with 'size_bytes' > static phys_addr_t __ro_after_init base_cmdline; > ^ > kernel/dma/contiguous.c:45:42: note: declared here > static const phys_addr_t __ro_after_init size_bytes = (phys_addr_t)CMA_SIZE_MBYTES * SZ_1M; > ^ > kernel/dma/contiguous.c:48:36: error: 'limit_cmdline' causes a section type conflict with 'size_bytes' > static phys_addr_t __ro_after_init limit_cmdline; > ^ > kernel/dma/contiguous.c:45:42: note: declared here > static const phys_addr_t __ro_after_init size_bytes = (phys_addr_t)CMA_SIZE_MBYTES * SZ_1M; > ^ > 3 errors generated. Thanks for your feedback and reporting this error. > The errors seem kind of cryptic at first but something that is const > should automatically be in the read only section, this part of the > commit seems unnecessary. Removing that part of the change fixes the error. I have overlooked size_bytes variable It shouldn't be const if it is declared as __ro_after_init. I will fix and resend it.