stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Christian Loehle <cloehle@hyperstone.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: [PATCH 4.14 32/32] mmc: block: ensure error propagation for non-blk
Date: Mon, 19 Jun 2023 12:29:20 +0200	[thread overview]
Message-ID: <20230619102129.248431251@linuxfoundation.org> (raw)
In-Reply-To: <20230619102127.461443957@linuxfoundation.org>

From: Christian Loehle <CLoehle@hyperstone.com>

commit 003fb0a51162d940f25fc35e70b0996a12c9e08a upstream.

Requests to the mmc layer usually come through a block device IO.
The exceptions are the ioctl interface, RPMB chardev ioctl
and debugfs, which issue their own blk_mq requests through
blk_execute_rq and do not query the BLK_STS error but the
mmcblk-internal drv_op_result. This patch ensures that drv_op_result
defaults to an error and has to be overwritten by the operation
to be considered successful.

The behavior leads to a bug where the request never propagates
the error, e.g. by directly erroring out at mmc_blk_mq_issue_rq if
mmc_blk_part_switch fails. The ioctl caller of the rpmb chardev then
can never see an error (BLK_STS_IOERR, but drv_op_result is unchanged)
and thus may assume that their call executed successfully when it did not.

While always checking the blk_execute_rq return value would be
advised, let's eliminate the error by always setting
drv_op_result as -EIO to be overwritten on success (or other error)

Fixes: 614f0388f580 ("mmc: block: move single ioctl() commands to block requests")
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/59c17ada35664b818b7bd83752119b2d@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/mmc/core/block.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -243,6 +243,7 @@ static ssize_t power_ro_lock_store(struc
 		goto out_put;
 	}
 	req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP;
+	req_to_mmc_queue_req(req)->drv_op_result = -EIO;
 	blk_execute_rq(mq->queue, NULL, req, 0);
 	ret = req_to_mmc_queue_req(req)->drv_op_result;
 	blk_put_request(req);
@@ -671,6 +672,7 @@ static int mmc_blk_ioctl_cmd(struct mmc_
 	idatas[0] = idata;
 	req_to_mmc_queue_req(req)->drv_op =
 		rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL;
+	req_to_mmc_queue_req(req)->drv_op_result = -EIO;
 	req_to_mmc_queue_req(req)->drv_op_data = idatas;
 	req_to_mmc_queue_req(req)->ioc_count = 1;
 	blk_execute_rq(mq->queue, NULL, req, 0);
@@ -741,6 +743,7 @@ static int mmc_blk_ioctl_multi_cmd(struc
 	}
 	req_to_mmc_queue_req(req)->drv_op =
 		rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL;
+	req_to_mmc_queue_req(req)->drv_op_result = -EIO;
 	req_to_mmc_queue_req(req)->drv_op_data = idata;
 	req_to_mmc_queue_req(req)->ioc_count = num_of_cmds;
 	blk_execute_rq(mq->queue, NULL, req, 0);
@@ -2590,6 +2593,7 @@ static int mmc_dbg_card_status_get(void
 	if (IS_ERR(req))
 		return PTR_ERR(req);
 	req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS;
+	req_to_mmc_queue_req(req)->drv_op_result = -EIO;
 	blk_execute_rq(mq->queue, NULL, req, 0);
 	ret = req_to_mmc_queue_req(req)->drv_op_result;
 	if (ret >= 0) {
@@ -2628,6 +2632,7 @@ static int mmc_ext_csd_open(struct inode
 		goto out_free;
 	}
 	req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_EXT_CSD;
+	req_to_mmc_queue_req(req)->drv_op_result = -EIO;
 	req_to_mmc_queue_req(req)->drv_op_data = &ext_csd;
 	blk_execute_rq(mq->queue, NULL, req, 0);
 	err = req_to_mmc_queue_req(req)->drv_op_result;



  parent reply	other threads:[~2023-06-19 10:30 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 10:28 [PATCH 4.14 00/32] 4.14.319-rc1 review Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 01/32] power: supply: ab8500: Fix external_power_changed race Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 02/32] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 03/32] ARM: dts: vexpress: add missing cache properties Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 04/32] power: supply: Ratelimit no data debug output Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 05/32] regulator: Fix error checking for debugfs_create_dir Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 06/32] power: supply: Fix logic checking if system is running from battery Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 07/32] MIPS: Alchemy: fix dbdma2 Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 08/32] mips: Move initrd_start check after initrd address sanitisation Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 09/32] xen/blkfront: Only check REQ_FUA for writes Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 10/32] ocfs2: fix use-after-free when unmounting read-only filesystem Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 11/32] ocfs2: check new file size on fallocate call Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 12/32] nios2: dts: Fix tse_mac "max-frame-size" property Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 13/32] nilfs2: fix incomplete buffer cleanup in nilfs_btnode_abort_change_key() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 14/32] nilfs2: fix possible out-of-bounds segment allocation in resize ioctl Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 15/32] net: usb: qmi_wwan: add support for Compal RXM-G1 Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 16/32] Remove DECnet support from kernel Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 17/32] USB: serial: option: add Quectel EM061KGL series Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 18/32] netfilter: nfnetlink: skip error delivery on batch in case of ENOMEM Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 19/32] ping6: Fix send to link-local addresses with VRF Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 20/32] IB/isert: Fix dead lock in ib_isert Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 21/32] IB/isert: Fix possible list corruption in CMA handler Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 22/32] IB/isert: Fix incorrect release of isert connection Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 23/32] sctp: fix an error code in sctp_sf_eat_auth() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 24/32] igb: fix nvm.ops.read() error handling Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 25/32] drm/nouveau/dp: check for NULL nv_connector->native_mode Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 26/32] net: lapbether: only support ethernet devices Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 27/32] net: tipc: resize nlattr array to correct size Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 28/32] selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 29/32] neighbour: Remove unused inline function neigh_key_eq16() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 30/32] neighbour: delete neigh_lookup_nodev as not used Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 31/32] powerpc: Fix defconfig choice logic when cross compiling Greg Kroah-Hartman
2023-06-19 10:29 ` Greg Kroah-Hartman [this message]
2023-06-20  9:19 ` [PATCH 4.14 00/32] 4.14.319-rc1 review Chris Paterson
2023-06-20  9:28 ` Harshit Mogalapalli
2023-06-20 10:05 ` Naresh Kamboju
2023-06-20 10:21 ` Jon Hunter
2023-06-21  0:37 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230619102129.248431251@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=adrian.hunter@intel.com \
    --cc=cloehle@hyperstone.com \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).