From patchwork Fri Jun 14 20:37:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 10996805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04DB2112C for ; Fri, 14 Jun 2019 20:42:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E96A428733 for ; Fri, 14 Jun 2019 20:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD2EE2876E; Fri, 14 Jun 2019 20:42:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8815628733 for ; Fri, 14 Jun 2019 20:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dtg7JHU3Xb/l5we36pyZWoOvc0+yoiaAFW+eaiVuxBU=; b=AXZVtdXGoVSTeQ dt5JQ1FjDMeRrTN1jVxasXZcFkm9lr08mNndZVpr4SIeoX+06TGwOtFjSSdEzuTkeV2JCJOmewJtw zaJg21Q6dRUOfsJQ7yjnkHWCbtiREzv5JiT0MPrAjtQatMs0ZVMnM7SZYVkmAbLuart03hEr0doGV RZ9I/hh3OLwSuwoQk9nG+RVKIoSlyGRpdhQSGKO2llYpIXNjEIkCkgohKmu12NwuoU5bdbM0tpvT/ sYSPC8u6+PTrcOXpHPmG/UJzOQBqCLuzZI5g8AyZJVQoGRT0XX95aMgqP4DnSMh6x6oN0C2LmCKPp BsublYH8+Ey9G+FPtg7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbt26-0001x8-P5; Fri, 14 Jun 2019 20:42:46 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hbswu-0004Mi-BD for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2019 20:37:34 +0000 Received: by mail-pg1-x543.google.com with SMTP id 83so2152586pgg.8 for ; Fri, 14 Jun 2019 13:37:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lsF1y/LAf5L+2wQLGdeHEaRtoQrXQNuhBq52QCwbapo=; b=OLPYBKcTI+78/S0FOVJMy9P3vw12j1xgEFVW/Zh4gP7hfjAUxnZ/FizK29hQocZGeB 2VpJiAbbc9MRZmfY6iqA6wq4sqz/DCAzWfkPb3oBtXfVwHvMeiqwUEbDqYQklOTGGTb+ Mt95Re9HEDvxMcRC3XaQjslmVZQNgfybwBtYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lsF1y/LAf5L+2wQLGdeHEaRtoQrXQNuhBq52QCwbapo=; b=d0zaVkq5Rg7fsm54VmwrRQc3g0TgmOm9dq4y83YA06c1fAPm503hJ1duBbV1EeNpU5 MdLPUzij5CT0xSeOkLiodGjvjOYaxJC6GPnwhmY1pPWkM8E6+5IUIFLAtMRgkbwh7BX+ YSAbWqvX+CJRzAYv+pNZPFDTiRDUPFEv/UlMEHwShkEF/xExTaf7CP6+yK9ANJ8zea6M nFcH0rpinBYrtv1TbvHXI46fyAHlUR4jXxcDNKj3xoRPA+fOkRuXc5LFdCX/t2pTDBrM /zjTGA50mj8Qla8kBtEk+QNppA9W2YWER3/qFGbXg1IlXeWG0vCtStsqTfqi4YX6d7ea NcJw== X-Gm-Message-State: APjAAAWxeAec22Cp2Q8NtO1QEoA95YL2q+MUritGir4Zom3RSGu0E2Ko oP1aBjbcyOqqRiSEvHFL55XXWQ== X-Google-Smtp-Source: APXvYqyh8elsGc5/c/L5iwGKta5WBR5tLdN1CqyHJTufMS/UgZnVCWVLvirzqoh1gd6Gf0IQIIbSKw== X-Received: by 2002:a17:90a:d14a:: with SMTP id t10mr13015629pjw.85.1560544643851; Fri, 14 Jun 2019 13:37:23 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id x5sm3673187pjp.21.2019.06.14.13.37.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 13:37:23 -0700 (PDT) From: Stephen Boyd To: Dan Williams Subject: [PATCH v2 5/5] soc: qcom: cmd-db: Map with read-only mappings Date: Fri, 14 Jun 2019 13:37:17 -0700 Message-Id: <20190614203717.75479-6-swboyd@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190614203717.75479-1-swboyd@chromium.org> References: <20190614203717.75479-1-swboyd@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190614_133724_422380_06C1DD9D X-CRM114-Status: GOOD ( 14.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, Will Deacon , linux-kernel@vger.kernel.org, Evan Green , Bjorn Andersson , Rob Herring , Andy Gross , Catalin Marinas , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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); if (IS_ERR(cmd_db_header)) { ret = PTR_ERR(cmd_db_header); cmd_db_header = NULL;