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=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 6377ACA9EAC for ; Sat, 19 Oct 2019 05:38:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0C21821925 for ; Sat, 19 Oct 2019 05:38:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I2ArurjZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C21821925 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 9DBC58E0006; Sat, 19 Oct 2019 01:38:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98D2D8E0003; Sat, 19 Oct 2019 01:38:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A1C08E0006; Sat, 19 Oct 2019 01:38:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 67EA68E0003 for ; Sat, 19 Oct 2019 01:38:00 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id DF033180ACC34 for ; Sat, 19 Oct 2019 05:37:59 +0000 (UTC) X-FDA: 76059427878.30.pet57_45c661f4ac863 X-HE-Tag: pet57_45c661f4ac863 X-Filterd-Recvd-Size: 4751 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Oct 2019 05:37:59 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id z6so6800106otb.2 for ; Fri, 18 Oct 2019 22:37:59 -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=dZD1rhZmQDM/H+GbTbYnSSIXxS9iO4DRfvqaZaVLmHA=; b=I2ArurjZWxXb7+XpLicdsV0rlFMZFv7gBdh8euQxI0hZMDcpnlpIoJZu5ltMe9sWnb DMG+2YBnDafJ9umzHpMqXhkhj8pHS4XAOZ0TDHp/p4y+cMp1hx3IHzeWCuB39zcqgjfj msjJ1LArDkb6x6lsD8lb1dJ5GD204iI8auQKUnK539L4cpwBf/8UM1kNERPkdY+d/W66 P3H41YvHbbcfSy2/P+MzhkN72fgSNkI1nzurPybrCZqAzztSOhcEaDbR09FqlasCoovs kXvovL0pU9ESneKb2ZJioZPYRBxw23HwTU2ZRSGD1TRQR7AgDrGP6LcPUVNL0U7swV7S YbaQ== 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=dZD1rhZmQDM/H+GbTbYnSSIXxS9iO4DRfvqaZaVLmHA=; b=A/fx9lyZYZFTc0QKfQVXRTJKpIkq0Z9fww1LawQEZsepfxTfjb3AdR0ws/wvhpYn1e ILMZo94oukY2vCDSQJ1ZpF4AujZebMquNKiMf9dOdoaSxsn7DYDaMouFujYkE/4B06TS tUPAHEGw30oe7AxHdIe7xLRxsVkSfccFXZ9D3PykOdpkUxXOgA0E5X/oD0NvjN56WlSC 465pG9nY+UppwMFCjyRTiyBsATIlQHMQHOm24HOP6ibEz7jMRuPkMbFON8ADaQBGD8G9 2tgn/OkC1NW+oYWJKPA/LiNg96cX2sEqf+ib0EhCgXU8CtQayvNOjrrwqIj/6K9l5bZF G48g== X-Gm-Message-State: APjAAAXuQpR67h1Wnfrf9GfHsv9lfhiC+o8eaG/XpRYGwL5ot/cta50p eAba+yD/kIbOweTqJVLJm7OdzmuaS61I//bkdJ4= X-Google-Smtp-Source: APXvYqxWRplW90eHZs/5G1y76NalbYYyDOet1jwKXgcM26aLqw7XHltBJMnUYIgx0qdZyyIcHCdpk3LqAa+mZJoGEFY= X-Received: by 2002:a9d:6e1a:: with SMTP id e26mr10354403otr.307.1571463478507; Fri, 18 Oct 2019 22:37:58 -0700 (PDT) MIME-Version: 1.0 References: <20191012122918.8066-1-mayhs11saini@gmail.com> <95842b81-c751-abed-dd3f-258b9fd70393@arm.com> In-Reply-To: <95842b81-c751-abed-dd3f-258b9fd70393@arm.com> From: Shyam Saini Date: Sat, 19 Oct 2019 11:07:47 +0530 Message-ID: Subject: Re: [PATCH] kernel: dma: Make CMA boot parameters __ro_after_init To: Robin Murphy Cc: Kernel Hardening , Kees Cook , linux-kernel , Matthew Wilcox , linux-mm , iommu@lists.linux-foundation.org, Christopher Lameter , Christoph Hellwig 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 Robin, Sorry for the late reply. > This parameters are not changed after early boot. > > By making them __ro_after_init will reduce any attack surface in the > > kernel. > > At a glance, it looks like these are only referenced by a couple of > __init functions, so couldn't they just be __initdata/__initconst? yes, You are right it is only used by __init calls and not used anywhere else. I will resend the updated version. Thanks a lot for the feedback. > > 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; > > +static phys_addr_t __ro_after_init size_cmdline = -1; > > +static phys_addr_t __ro_after_init base_cmdline; > > +static phys_addr_t __ro_after_init limit_cmdline; > > > > static int __init early_cma(char *p) > > { > >