]> git.baikalelectronics.ru Git - kernel.git/commit
nvmet-tcp: fix out-of-bounds access when receiving multiple h2cdata PDUs
authorSagi Grimberg <sagi@grimberg.me>
Wed, 3 Feb 2021 09:20:25 +0000 (01:20 -0800)
committerChristoph Hellwig <hch@lst.de>
Wed, 3 Feb 2021 15:57:36 +0000 (16:57 +0100)
commited424bfa51594103f20a4739b84970cef39eda3e
tree81c4f3e276b7dcec9bdfde8d9a5b5ec5d23186c8
parentb1a8b3cb77131e7a7912ba25f75fb288260c69b3
nvmet-tcp: fix out-of-bounds access when receiving multiple h2cdata PDUs

When the host sends multiple h2cdata PDUs, we keep track on
the receive progress and calculate the scatterlist index and
offsets.

The issue is that sg_offset should only be kept for the first
iov entry we map in the iovec as this is the difference between
our cursor and the sg entry offset itself.

In addition, the sg index was calculated wrong because we should
not round up when dividing the command byte offset with PAG_SIZE.

Fixes: 1d48c1a32831 ("nvmet-tcp: add NVMe over TCP target driver")
Reported-by: Narayan Ayalasomayajula <Narayan.Ayalasomayajula@wdc.com>
Tested-by: Narayan Ayalasomayajula <Narayan.Ayalasomayajula@wdc.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/tcp.c