Skip to content

Commit 7acae61

Browse files
lxbszidryomov
authored andcommitted
ceph: fix possible NULL pointer dereference for req->r_session
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>
1 parent 396ea16 commit 7acae61

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

fs/ceph/caps.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,8 @@ static int unsafe_request_wait(struct inode *inode)
22742274
list_for_each_entry(req, &ci->i_unsafe_dirops,
22752275
r_unsafe_dir_item) {
22762276
s = req->r_session;
2277+
if (!s)
2278+
continue;
22772279
if (unlikely(s->s_mds >= max_sessions)) {
22782280
spin_unlock(&ci->i_unsafe_lock);
22792281
for (i = 0; i < max_sessions; i++) {
@@ -2294,6 +2296,8 @@ static int unsafe_request_wait(struct inode *inode)
22942296
list_for_each_entry(req, &ci->i_unsafe_iops,
22952297
r_unsafe_target_item) {
22962298
s = req->r_session;
2299+
if (!s)
2300+
continue;
22972301
if (unlikely(s->s_mds >= max_sessions)) {
22982302
spin_unlock(&ci->i_unsafe_lock);
22992303
for (i = 0; i < max_sessions; i++) {

0 commit comments

Comments
 (0)