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: [email protected] URL: https://tracker.ceph.com/issues/55327 Signed-off-by: Xiubo Li <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Tested-by: Aaron Tomlin <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 396ea16 commit 7acae61

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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)