Skip to content

Commit 02d9c6e

Browse files
Qi Zhengnamjaejeon
authored andcommitted
ksmbd: fix potential UAF
After calling opinfo_put(), the opinfo may be freed, then using this opinfo in the next traversal will cause UAF bug. To fix it, swap the call order of opinfo_put() and rcu_read_lock(), so that the opinfo_free_rcu() will not be called, and the opinfo will not be freed, then we can safely perform the next traversal. Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Signed-off-by: Qi Zheng <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent d6fb37b commit 02d9c6e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

oplock.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,8 +1233,8 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
12331233
goto out;
12341234
}
12351235
op_next:
1236-
opinfo_put(opinfo);
12371236
rcu_read_lock();
1237+
opinfo_put(opinfo);
12381238
}
12391239
rcu_read_unlock();
12401240

@@ -1561,8 +1561,8 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
15611561
brk_op->open_trunc = is_trunc;
15621562
oplock_break(brk_op, SMB2_OPLOCK_LEVEL_NONE);
15631563
next:
1564-
opinfo_conn_put(brk_op);
15651564
rcu_read_lock();
1565+
opinfo_conn_put(brk_op);
15661566
}
15671567
rcu_read_unlock();
15681568

@@ -1986,8 +1986,8 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,
19861986
goto out;
19871987
}
19881988
op_next:
1989-
opinfo_put(opinfo);
19901989
rcu_read_lock();
1990+
opinfo_put(opinfo);
19911991
}
19921992
rcu_read_unlock();
19931993

0 commit comments

Comments
 (0)