summaryrefslogtreecommitdiff
path: root/fs/ceph
diff options
context:
space:
mode:
authorXiubo Li <xiubli@redhat.com>2022-04-14 04:07:21 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-02 19:40:03 +0300
commit69263bf781bef3841f22815b834a5243474aa6d4 (patch)
tree65e4cfe9ec899803ad7ddf94f8b41252abd7ab96 /fs/ceph
parent8e137ace53339eae14ced15143f95194a14999fd (diff)
downloadlinux-69263bf781bef3841f22815b834a5243474aa6d4.tar.xz
ceph: fix possible NULL pointer dereference for req->r_session
[ Upstream commit 7acae6183cf37c48b8da48bbbdb78820fb3913f3 ] The request will be inserted into the ci->i_unsafe_dirops before assigning the req->r_session, so it's possible that we will hit NULL pointer dereference bug here. Cc: stable@vger.kernel.org URL: https://tracker.ceph.com/issues/55327 Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Tested-by: Aaron Tomlin <atomlin@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Stable-dep-of: 5bd76b8de5b7 ("ceph: fix NULL pointer dereference for req->r_session") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/caps.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 4e2fada35808..ce6a858e765a 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2346,6 +2346,8 @@ retry:
list_for_each_entry(req, &ci->i_unsafe_dirops,
r_unsafe_dir_item) {
s = req->r_session;
+ if (!s)
+ continue;
if (unlikely(s->s_mds >= max_sessions)) {
spin_unlock(&ci->i_unsafe_lock);
for (i = 0; i < max_sessions; i++) {
@@ -2366,6 +2368,8 @@ retry:
list_for_each_entry(req, &ci->i_unsafe_iops,
r_unsafe_target_item) {
s = req->r_session;
+ if (!s)
+ continue;
if (unlikely(s->s_mds >= max_sessions)) {
spin_unlock(&ci->i_unsafe_lock);
for (i = 0; i < max_sessions; i++) {