NVMe: Fix 0-length integrity payload

A user could send a passthrough IO command with a metadata pointer to a
namespace without metadata. With metadata length of 0, kmalloc returns
ZERO_SIZE_PTR. Since that is not NULL, the driver would have set this as
the bio's integrity payload, which causes an access fault on completion.

This patch ignores the users metadata buffer if the namespace format
does not support separate metadata.

Reported-by: Stephen Bates <stephen.bates@microsemi.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Keith Busch 2016-02-24 09:15:58 -07:00 committed by Jens Axboe
parent 63088ec7c8
commit e9fc63d682
1 changed files with 1 additions and 1 deletions

View File

@ -184,7 +184,7 @@ int __nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd,
goto out_unmap; goto out_unmap;
} }
if (meta_buffer) { if (meta_buffer && meta_len) {
struct bio_integrity_payload *bip; struct bio_integrity_payload *bip;
meta = kmalloc(meta_len, GFP_KERNEL); meta = kmalloc(meta_len, GFP_KERNEL);