lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210425060207.2591-3-avri.altman@wdc.com>
Date:   Sun, 25 Apr 2021 09:02:07 +0300
From:   Avri Altman <avri.altman@....com>
To:     Ulf Hansson <ulf.hansson@...aro.org>, linux-mmc@...r.kernel.org,
        Adrian Hunter <adrian.hunter@...el.com>
Cc:     linux-kernel@...r.kernel.org, Avri Altman <avri.altman@....com>,
        Brendan Peter <bpeter@...x.com>
Subject: [PATCH v5 2/2] mmc: block: Issue flush only if allowed

The cache may be flushed to the nonvolatile storage by writing to
FLUSH_CACHE byte (EXT_CSD byte [32]). When in command queueing mode, the
cache may be flushed by issuing a CMDQ_TASK_ DEV_MGMT (CMD48) with a
FLUSH_CACHE op-code.  Either way, verify that The cache function is
turned ON before doing so.

fixes: 1e8e55b67030 (mmc: block: Add CQE support)

Reported-by: Brendan Peter <bpeter@...x.com>
Tested-by: Brendan Peter <bpeter@...x.com>
Signed-off-by: Avri Altman <avri.altman@....com>
Acked-by: Adrian Hunter <adrian.hunter@...el.com>
---
 drivers/mmc/core/block.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 6cd5d03bcc64..e3062bbf110e 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2198,6 +2198,11 @@ static int mmc_blk_wait_for_idle(struct mmc_queue *mq, struct mmc_host *host)
 	return mmc_blk_rw_wait(mq, NULL);
 }
 
+static bool mmc_blk_cache_disabled(struct mmc_host *host)
+{
+	return !mmc_cache_enabled(host);
+}
+
 enum mmc_issued mmc_blk_mq_issue_rq(struct mmc_queue *mq, struct request *req)
 {
 	struct mmc_blk_data *md = mq->blkdata;
@@ -2237,6 +2242,10 @@ enum mmc_issued mmc_blk_mq_issue_rq(struct mmc_queue *mq, struct request *req)
 	case MMC_ISSUE_ASYNC:
 		switch (req_op(req)) {
 		case REQ_OP_FLUSH:
+			if (mmc_blk_cache_disabled(host)) {
+				blk_mq_end_request(req, BLK_STS_OK);
+				return MMC_REQ_FINISHED;
+			}
 			ret = mmc_blk_cqe_issue_flush(mq, req);
 			break;
 		case REQ_OP_READ:
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ