Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7322452ybp; Wed, 16 Oct 2019 07:09:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvtHBcLzz4U3tVQ07/0Ubmb4vfr/z/psX+QmLnP7q+2Fgw2Q/J3xoEzbqqWtGVF2lvKWuX X-Received: by 2002:aa7:d753:: with SMTP id a19mr40367510eds.80.1571234965657; Wed, 16 Oct 2019 07:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571234965; cv=none; d=google.com; s=arc-20160816; b=oObh+4syFh/cQ2PPKhvRQavdkGkPaKJ0yrlT2fNna1qxqoAGqf4fu85dbijSt0SLnG gLd2Bkax3ydY/bStkNKHm97VzBDo3lnXv5T2ku/TazMh6eQ4UyqCd2U7xTA8A90Z7tTg uhITQTPGk5/s6r6H1ac+FlXNO5CuiThvdDhV6nsMssw8FiQrt5Doukg9i9ylyjPBmzcK eGmsu/7BWdNPzOX8+cvgmJkD+4QX9ojMRcEwk6uhqJnwdr+W9XIXvJYcNW468jiVZ8Qt oSXQeUACqf4ofm2u2i0cOks7aWd4As2p+8DW1ujGJO/GAfITWd4hySjDFhEv6Saw1Lk9 5z6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fIAc7kYct8VpQ13hbYyhIsPB/WrvUenHD8qPKsYEDRE=; b=g9ogasfZpiBPFBj44B6yu43ws40dQaEJAfeTSWaA6vf8Jh8tGbgJzzNL5Hm1DYcRnS YktNVBGULWcMrA78b3GzCBTtk+NubgxB82u2lkOR/4TUGPSlK/EEjmmK7PQuF7O/HFJM OhUyMpO3+V+J33/alwvh2rlQo/61vQfB5azEKjdG6TSSGUHzneh7bo6wPQmsn372nFQb dOx23OkI4nU0rNGAwHLttzQCJxrlDoFREBB304bkaBzM/Nb9Sq67mw3XvsucYBgA3wjy jzfbStv8/KPQvZUzNRAeQWgVUDdgDz/FpsBxdHBEYmMt5EY/gKkLeBZEFgIPbWfsYDsu F8HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oXbT4hNK; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si17309083edb.425.2019.10.16.07.09.01; Wed, 16 Oct 2019 07:09:25 -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=@gmail.com header.s=20161025 header.b=oXbT4hNK; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404509AbfJPKMA (ORCPT + 99 others); Wed, 16 Oct 2019 06:12:00 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:35520 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727235AbfJPKMA (ORCPT ); Wed, 16 Oct 2019 06:12:00 -0400 Received: by mail-oi1-f194.google.com with SMTP id x3so19554064oig.2 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=NTpvLcGMNgYwXqu/21FWj+JTh9+M0tLu247yqDaaSbVCRoLA115RIjUgtullvnDVtS lVbu+YbleSaCgfx95N4L8UZqo5RcI3HqQwEw8di7n3+fAtUZv0O3xqZZcE5RLw/+TzMa slf3Si3spp8Vrq/UDEzMUSuUj9LNRUl48DkH8Ob7RW9wsGYkvBKxbPILNpo0+64XHxSd PvqfeqMpMrRpVpCvMWg2JqzOiYHJzBFLboYW0F2DYnTIFfa8Z9ce3WoOt6SZ6ddWxD51 eCcaNmX67wIJTVMlW8IMffCegleZeF4DBU8BfrXBAXqEk0rwtQAbcaMslTIDaNNP7W6K H0Aw== X-Gm-Message-State: APjAAAXctlHzW1BRQIUJkyRh3Rb6zV8aQLtHy8TGeH2pzjQwFFm7s4Re J4ZioBdPmlToCerWQCXJPOK/yzHEEG6hdSv2064= 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.