summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2020-01-24 01:01:30 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-24 08:36:57 +0100
commitb5f6bf0fdd71eecec7fcac94049caa1017d0769c (patch)
treecb00f702c005bea9ef8a97258edad47a52cdd575
parent393b8509be3348d5b11a643f0d05597ce3ea4c7c (diff)
bcache: fix use-after-free in register_bcache()
[ Upstream commit ae3cd299919af6eb670d5af0bc9d7ba14086bd8e ] The patch "bcache: rework error unwinding in register_bcache" introduces a use-after-free regression in register_bcache(). Here are current code, 2510 out_free_path: 2511 kfree(path); 2512 out_module_put: 2513 module_put(THIS_MODULE); 2514 out: 2515 pr_info("error %s: %s", path, err); 2516 return ret; If some error happens and the above code path is executed, at line 2511 path is released, but referenced at line 2515. Then KASAN reports a use- after-free error message. This patch changes line 2515 in the following way to fix the problem, 2515 pr_info("error %s: %s", path?path:"", err); Signed-off-by: Coly Li <colyli@suse.de> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/md/bcache/super.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 86f7e09d3151..485ebc2b2144 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2472,10 +2472,11 @@ out_free_sb:
kfree(sb);
out_free_path:
kfree(path);
+ path = NULL;
out_module_put:
module_put(THIS_MODULE);
out:
- pr_info("error %s: %s", path, err);
+ pr_info("error %s: %s", path?path:"", err);
return ret;
}