Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp181239ybe; Wed, 18 Sep 2019 15:09:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKBzAnOh/5vQmflHSSaBMZHqraZN08nx3oxBYPAholE3OQjJ3qEc+A33dUhLxjP51qVax8 X-Received: by 2002:a17:906:e2d8:: with SMTP id gr24mr11209966ejb.55.1568844592754; Wed, 18 Sep 2019 15:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568844592; cv=none; d=google.com; s=arc-20160816; b=aaiECSKDv9rH312/VJOEM0BMnjVwW0axiggKzMPWyBZUE3dQvxnjG025msn1wLehun 93ekJ4kdgwSjmK3g1hLcuBg/N4MLzHFV0kTo/fhD7kWxfgCvRcr6JtbNb/uv0jzFXEGY 34frcci8jSJUV7gN9G3OTjAqxX44TkV87iY5iMQS7wtEFTYN4do1K6hNORkmKPHW1BJx +eLcdevmnbxKabj+VVR4gEDSOAijTSYrdO/d78hLsAnZtjz1Y4970gj9YrvS4aEeFw4t DHNwNV9Llbk+MH7J8xKZZbv3F19XH/Gt8m+YNRm0W3CpSn64nj+PW9KHon/c0eGZqnzw 2pcQ== 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=DUtNy6zmsY/nY12iTbVrTLFA5neR54fGcg9sdDNwfEY=; b=dHEtBOAhgehmI6xJqbU6VRwKLgz8Cq8HqlbK1Maniy0GCpQ9FktEOpMkkJ6qoKeKvA qp5srNmwYhPMA/cTj7AvCh7S7iSctwQDgR+evF8OGdFA46HVoB8WMaEU/epbaxLi+C1K lExstyjzpzZoyugVHAJDv6Ue2GliJsVfw6khO+hKzA0HY6pge3DxbSRmx4iK8Tt/W7h7 mRdNPfILNBjWzXEE3+HCQYoZ1vh20/orhPgBJX0rYcX/oy1vO6GK+1u5WCV5Nxwgp1rn x4NACvneZWEz+TLUCBIFMMahnT78tpKZ0ASoBzrEs9+lXuDsX4OtHxDOD04qzlSCYLbi sXoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fVyFu7iC; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si4712421edk.315.2019.09.18.15.09.29; Wed, 18 Sep 2019 15:09:52 -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=@chromium.org header.s=google header.b=fVyFu7iC; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731693AbfIRTle (ORCPT + 99 others); Wed, 18 Sep 2019 15:41:34 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:39719 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729275AbfIRTle (ORCPT ); Wed, 18 Sep 2019 15:41:34 -0400 Received: by mail-lf1-f67.google.com with SMTP id 72so539465lfh.6 for ; Wed, 18 Sep 2019 12:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DUtNy6zmsY/nY12iTbVrTLFA5neR54fGcg9sdDNwfEY=; b=fVyFu7iCUvOtyuHv+Xj2YthhNrZOr4I5cNqzFjMxLMOPNrE71+G8H1jVo9wOMKgtTc TNIIlFcXqPJtyGWq7EIhgQ/QTvke2Pgso2evo8wAVJRrFT99b162lg4tZoUwvjLXnxF5 bBF15QD8KKnIOevl3afUFS9klNlHkQ2aatRIk= 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=DUtNy6zmsY/nY12iTbVrTLFA5neR54fGcg9sdDNwfEY=; b=FtvXVRV9DMSEM65QOt9NY7buM5LH1d/582UlT44p4QAaCi6O1AwZUzY+zi8jAl3u8a O48EBqkpGWdXn+navHVc61TArYBnqW36IMfxm2HgPbxbD8/L/WnFEWKPaF5sKffYPh7S qD54fkl8bv8Mj4lmHUVv7S91CX+YJ8q2SfoZ9rlAjLjPH1gWwjnyavejZA3fGQdvEoG2 uvGqxrGqdBTEOdGsxdWxtRzyDn+jZCe0bRb4jH6Qzve2Nl5E+PjIENzKmM+DhSPy4jYz 6qKZV786/PChQMrdzRiHkD28xMVfNmjwoAlHiL4SMao++oR/aLlelYY52mX0L6HHhQJZ 6COA== X-Gm-Message-State: APjAAAX+06nVgh/GS0zc+i53gQjwxITrYfyneyqA/EacBzEuJbRrM4BA sSfvf0Pk6O2Jt+gmJ6axu4BnqOKQA2w= X-Received: by 2002:a19:8c1d:: with SMTP id o29mr3020497lfd.73.1568835690626; Wed, 18 Sep 2019 12:41:30 -0700 (PDT) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id e29sm1177199ljb.105.2019.09.18.12.41.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Sep 2019 12:41:29 -0700 (PDT) Received: by mail-lj1-f181.google.com with SMTP id s19so1132116lji.6 for ; Wed, 18 Sep 2019 12:41:28 -0700 (PDT) X-Received: by 2002:a2e:9881:: with SMTP id b1mr3145788ljj.134.1568835688462; Wed, 18 Sep 2019 12:41:28 -0700 (PDT) MIME-Version: 1.0 References: <20190910160903.65694-1-swboyd@chromium.org> <20190910160903.65694-6-swboyd@chromium.org> In-Reply-To: <20190910160903.65694-6-swboyd@chromium.org> From: Evan Green Date: Wed, 18 Sep 2019 12:40:52 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 5/5] soc: qcom: cmd-db: Map with read-only mappings To: Stephen Boyd Cc: Dan Williams , LKML , linux-arm-msm , linux-arm Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Rob Herring , Bjorn Andersson , Andy Gross , Will Deacon , Catalin Marinas 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 On Tue, Sep 10, 2019 at 9:09 AM Stephen Boyd wrote: > > The command DB is read-only already to the kernel because everything is > const marked once we map it. Let's go one step further and try to map > the memory as read-only in the page tables. This should make it harder > for random code to corrupt the database and change the contents. > > Cc: Evan Green > Cc: Rob Herring > Cc: Bjorn Andersson > Cc: Andy Gross > Cc: Will Deacon > Cc: Catalin Marinas > Cc: Dan Williams > Reviewed-by: Bjorn Andersson > Signed-off-by: Stephen Boyd > --- > drivers/soc/qcom/cmd-db.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c > index 10a34d26b753..6365e8260282 100644 > --- a/drivers/soc/qcom/cmd-db.c > +++ b/drivers/soc/qcom/cmd-db.c > @@ -240,7 +240,8 @@ static int cmd_db_dev_probe(struct platform_device *pdev) > { > int ret = 0; > > - cmd_db_header = devm_memremap_reserved_mem(&pdev->dev, MEMREMAP_WB); > + cmd_db_header = devm_memremap_reserved_mem(&pdev->dev, > + MEMREMAP_RO | MEMREMAP_WB); It seems weird to have both flags, like: "It's read-only, but if it ever did get written to somehow, make it writeback". > if (IS_ERR(cmd_db_header)) { > ret = PTR_ERR(cmd_db_header); > cmd_db_header = NULL; > -- > Sent by a computer through tubes >