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=-8.3 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,USER_AGENT_SANE_1 autolearn=ham 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 7B2CCC4360C for ; Mon, 14 Oct 2019 02:25:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2877C2082F for ; Mon, 14 Oct 2019 02:25:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IS5BQ/44" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2877C2082F 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 CC2FF8E0005; Sun, 13 Oct 2019 22:25:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C73088E0001; Sun, 13 Oct 2019 22:25:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B60F68E0005; Sun, 13 Oct 2019 22:25:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 9571A8E0001 for ; Sun, 13 Oct 2019 22:25:47 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 305C5181AEF1A for ; Mon, 14 Oct 2019 02:25:47 +0000 (UTC) X-FDA: 76040799534.26.jeans28_89c3ce9b49505 X-HE-Tag: jeans28_89c3ce9b49505 X-Filterd-Recvd-Size: 6180 Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Oct 2019 02:25:46 +0000 (UTC) Received: by mail-ot1-f67.google.com with SMTP id o44so12535205ota.10 for ; Sun, 13 Oct 2019 19:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lP906qLGyTEBqe55BgoOje0n/wNr+NcPtklrVASvvHA=; b=IS5BQ/44O5nPSYEgMvhA5ue5f8rm2WjOUI0H0EaNT+szqXdXyFs4SCC/ZwFmnvPMt6 EwazwfzkAyQiJJ9DFy6cE8623VjFb/VMuqqPQIZlafgsGnERyxmrMqgEnOFOtb+q0pSo NfAMizqzvJcwaj3hh2m6SzGAdM7mebp2YR9v3Zi/7ilcovua90ZnveeG/uhxtjs/1TAS 97f9ArqI/yrg+8V3hNWg0cMWeIjH44FLUMJPrHnkPX+6V4KZQa7hdKZQMaADVgjQUfTK pEvBVDvVFMqWh8PLhTpOrAMrb9MpppnpV/v6D4B8va0USsaL2eNeQ65wcNF7wie6mvbN xkLg== 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=lP906qLGyTEBqe55BgoOje0n/wNr+NcPtklrVASvvHA=; b=PLPp0bjBjnd9cR1iJ1/N2ff2+nI4LJgF26I1Mkec7KjcrB0G9dbO3guOu8tZQCwEKp CwYIVacOO6XhjTuisItwOjtUpVm9+eYHdUEc6tgyiqg39t2Q6m31wsiGxZSFlxNV12h+ ggJezzvd4nB+TOEQcXbUo6Bj2fMT68Tz+JQQ+JVRcZtb9o7vhDp5BVsA7FBfn/DW2M4r OYYe4Ntz/GwvVWjwsl3dsSXSLmnKA/QBPR09hU0oDkBpnOUqA7UzHg/WlNN+Qe9BrKtL QCQQptfv6vNDC7ZENvNmzC23yCivVpedFXthaegklgTsPnK7V+hsRRmd/Y94F3rW/SRi TVQw== X-Gm-Message-State: APjAAAWRlrmQGne9N2ODIGZxbyyVoDwWPg1wTizo30+q6fQfZ5YpWmha TbWNO95h53PHvISQGJs0V44= X-Google-Smtp-Source: APXvYqx1/+cDEztMyAYHqWplLS7mX+pExI62RCoIIFZ6rpPAtHcWGm4akpgGk84aUZCSA9QdvuLz/Q== X-Received: by 2002:a9d:12ac:: with SMTP id g41mr21703818otg.57.1571019945644; Sun, 13 Oct 2019 19:25:45 -0700 (PDT) Received: from ubuntu-m2-xlarge-x86 ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id d95sm5617723otb.25.2019.10.13.19.25.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 13 Oct 2019 19:25:45 -0700 (PDT) Date: Sun, 13 Oct 2019 19:25:43 -0700 From: Nathan Chancellor To: Shyam Saini Cc: kernel-hardening@lists.openwall.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Matthew Wilcox , Christopher Lameter , Kees Cook , clang-built-linux@googlegroups.com Subject: Re: [PATCH] kernel: dma: Make CMA boot parameters __ro_after_init Message-ID: <20191014022543.GA2674@ubuntu-m2-xlarge-x86> References: <20191012122918.8066-1-mayhs11saini@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191012122918.8066-1-mayhs11saini@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) 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: 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. 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. Cheers, Nathan