From: Max Gurtovoy <mgurtovoy@nvidia.com>
To: <martin.petersen@oracle.com>, <hch@lst.de>, <sagi@grimberg.me>,
<linux-nvme@lists.infradead.org>
Cc: <hare@suse.de>, <kbusch@kernel.org>, <axboe@kernel.dk>,
<linux-block@vger.kernel.org>, <oren@nvidia.com>,
<oevron@nvidia.com>, <israelr@nvidia.com>,
Max Gurtovoy <mgurtovoy@nvidia.com>
Subject: [PATCH v2 2/2] nvme-multipath: fix path failover for integrity ns
Date: Tue, 25 Apr 2023 01:54:42 +0300 [thread overview]
Message-ID: <20230424225442.18916-3-mgurtovoy@nvidia.com> (raw)
In-Reply-To: <20230424225442.18916-1-mgurtovoy@nvidia.com>
In case the integrity capabilities of the failed path and the failover
path don't match, we may run into NULL dereference. Free the integrity
context during the path failover and let the block layer prepare it
again if needed during bio_submit.
Reviewed-by: Israel Rukshin <israelr@nvidia.com>
Tested-by: Ori Evron <oevron@nvidia.com>
Signed-off-by: Ori Evron <oevron@nvidia.com>
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
drivers/nvme/host/multipath.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 9171452e2f6d..f439916f4447 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -6,6 +6,7 @@
#include <linux/backing-dev.h>
#include <linux/moduleparam.h>
#include <linux/vmalloc.h>
+#include <linux/blk-integrity.h>
#include <trace/events/block.h>
#include "nvme.h"
@@ -106,6 +107,14 @@ void nvme_failover_req(struct request *req)
bio->bi_opf &= ~REQ_POLLED;
bio->bi_cookie = BLK_QC_T_NONE;
}
+ /*
+ * If the failover path will not be integrity capable the bio
+ * should not have integrity context.
+ * If the failover path will be integrity capable the bio will
+ * be prepared for integrity again.
+ */
+ if (bio_integrity(bio))
+ bio_integrity_free(bio);
}
blk_steal_bios(&ns->head->requeue_list, req);
spin_unlock_irqrestore(&ns->head->requeue_lock, flags);
--
2.18.1
next prev parent reply other threads:[~2023-04-24 22:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 22:54 [PATCH v2 0/2] Fix failover to non integrity NVMe path Max Gurtovoy
2023-04-24 22:54 ` [PATCH v2 1/2] block: bio-integrity: export bio_integrity_free func Max Gurtovoy
2023-04-24 22:54 ` Max Gurtovoy [this message]
2023-04-25 2:12 ` [PATCH v2 2/2] nvme-multipath: fix path failover for integrity ns Martin K. Petersen
2023-04-25 10:24 ` Max Gurtovoy
2023-04-25 22:39 ` Keith Busch
2023-04-26 1:22 ` Martin K. Petersen
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=20230424225442.18916-3-mgurtovoy@nvidia.com \
--to=mgurtovoy@nvidia.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=israelr@nvidia.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martin.petersen@oracle.com \
--cc=oevron@nvidia.com \
--cc=oren@nvidia.com \
--cc=sagi@grimberg.me \
/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