Commit 4a274f7e authored by Damien Le Moal's avatar Damien Le Moal Committed by sanglipeng
Browse files

nvmet: avoid potential UAF in nvmet_req_complete()

stable inclusion
from stable-v5.10.176
commit a6317235da8aa7cb97529ebc8121cc2a4c4c437a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8CHVQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a6317235da8aa7cb97529ebc8121cc2a4c4c437a



--------------------------------

[ Upstream commit 6173a77b ]

An nvme target ->queue_response() operation implementation may free the
request passed as argument. Such implementation potentially could result
in a use after free of the request pointer when percpu_ref_put() is
called in nvmet_req_complete().

Avoid such problem by using a local variable to save the sq pointer
before calling __nvmet_req_complete(), thus avoiding dereferencing the
req pointer after that function call.

Fixes: a07b4970 ("nvmet: add a generic NVMe target")
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 2d5afda9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment