Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6018785ybe; Tue, 10 Sep 2019 12:13:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZZ/+FWE9/k8QTSPgsgVF9EcIJjnKQiVEO7u7rYjk5HJqMPigwE++t4EcY0w/z255EQDmq X-Received: by 2002:a17:906:52d7:: with SMTP id w23mr26089571ejn.228.1568142836805; Tue, 10 Sep 2019 12:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568142836; cv=none; d=google.com; s=arc-20160816; b=DN3nchi/ecT/tyUlTvKPg9GPDb/IIkVp8B0ejzL5IEO9DubQy7tXMDVCPo21ob8n/B q+OhwqD/HlAaczO6Y8h1fSXrBkoWlhVgAd9hqOhzU/1OqPXJS3R6fErtNX3Mt9paO2ss LVIsb+V1q96X6xeaj5SBTPYRPBnjxX/8aVm2BBSY4nKyzOM3W9gD4Iq7fvOA8h97IHmD z/KQuAU6yEcR3YtNY6asG2gKZUmFzorx9zkLKxWbAqjIJbWCuYrnlJrTT9C8X+mE628m sEgQsjBZ/lDfT//7CYAxqO4qRZ7gZOZf3bcArxxS5um7CNdyppnWPa3x9gOPBQYD76dE ggOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lsF1y/LAf5L+2wQLGdeHEaRtoQrXQNuhBq52QCwbapo=; b=z2in8XkWrEr1q88UN8xoDwMPjVTrOcgAp/Jr+a6+nPgApX4QPkyCCqghu76wjcZVxn NgjIVmr9B63X/bDSIaJLU78XESyukWSbpaRO0aT0UNoikAcMWcgioATnTEkGQyI3b15n i1sQrvOEG+1sH8pJEKasYrd7DUJg8vpfaAtyEzm0c10MIpNCw3/oxMioeUrxQfeMHjhU LzQulzBd1BL2kFVDQgAJR824aqfltgUQAy9WVduxapNQgKMfvZtsfmCENDq4LQzlBdRj fUKN9TmZRMboiUjxCGrO0AeTLouPFXN1k26e3/Eq0X6Nv3EPMgQO5NeBWtQFskpLRoMr LRUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mdVQsy1c; 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 f14si11358987edd.134.2019.09.10.12.13.24; Tue, 10 Sep 2019 12:13:56 -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=mdVQsy1c; 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 S2436719AbfIJQJL (ORCPT + 99 others); Tue, 10 Sep 2019 12:09:11 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33536 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436707AbfIJQJJ (ORCPT ); Tue, 10 Sep 2019 12:09:09 -0400 Received: by mail-pg1-f195.google.com with SMTP id n190so9999723pgn.0 for ; Tue, 10 Sep 2019 09:09:09 -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=mdVQsy1cW0AfygbqRfmRAt0xnJVqMTwwmQzqbSnqPGSYkZ06kclM5ECyrWQBKM25dT XL8xTcMiEkNA0dzblEd5R9eboXRJ4QoJnyMa6iPUIWJ03wldonWCEuP7hRY3Hr/JSrhO EJ+7hQx8IJ/x/dHNQIuUT96b7SjMfakjzK7co= 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=QJAL0fOT4Pil9AliXE0HgtJDwfPm52mVmIcClpBDUvtSc+jfW4xdkDJlWiJO+bpuh0 QLN/dGYpf6BjWMG3wD6GcoqS29aGTWipgacsWg3pE+mB2roaUvgomjYthnwqgm/zv7FW M3D9ksSK8fNkgeZ4NQr3sQLl21g6NGS37yvy6N6TifYyYVNU2asHewSzZydP1wza4gSJ 28O6Kgm/mUI2f5NmDJOwZMETKBL+z+b/MjcxFk/S6lTpRMl9Ce1F7K9Q2lphcf6etLhF yaJ5IdoRBCO4P5gE+qww1tHWJT053LQXoJoo9hKzDo6wmgBTlMOI4LMX4UNUjGC7AL9Q WqFw== X-Gm-Message-State: APjAAAU00mUf780hWN0qduAPC+Raat56yVkesyU1n5x5yuAcmQY2y2dw +KcbVS0PHsp2Q2eFAwvNY8+baw== X-Received: by 2002:a17:90a:a002:: with SMTP id q2mr257538pjp.69.1568131749136; Tue, 10 Sep 2019 09:09:09 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id em21sm106088pjb.31.2019.09.10.09.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 09:09:08 -0700 (PDT) From: Stephen Boyd To: Dan Williams Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Evan Green , Rob Herring , Bjorn Andersson , Andy Gross , Will Deacon , Catalin Marinas Subject: [PATCH v3 5/5] soc: qcom: cmd-db: Map with read-only mappings Date: Tue, 10 Sep 2019 09:09:03 -0700 Message-Id: <20190910160903.65694-6-swboyd@chromium.org> X-Mailer: git-send-email 2.23.0.162.g0b9fbb3734-goog In-Reply-To: <20190910160903.65694-1-swboyd@chromium.org> References: <20190910160903.65694-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- Sent by a computer through tubes