Skip to content

Commit

Permalink
ksmbd: fix potential UAF
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Qi Zheng authored and namjaejeon committed Jul 28, 2023
1 parent 0348b11 commit 8e8d87b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions oplock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,8 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
goto out;
}
op_next:
opinfo_put(opinfo);
rcu_read_lock();
opinfo_put(opinfo);
}
rcu_read_unlock();

Expand Down Expand Up @@ -1561,8 +1561,8 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
brk_op->open_trunc = is_trunc;
oplock_break(brk_op, SMB2_OPLOCK_LEVEL_NONE);
next:
opinfo_conn_put(brk_op);
rcu_read_lock();
opinfo_conn_put(brk_op);
}
rcu_read_unlock();

Expand Down Expand Up @@ -1986,8 +1986,8 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,
goto out;
}
op_next:
opinfo_put(opinfo);
rcu_read_lock();
opinfo_put(opinfo);
}
rcu_read_unlock();

Expand Down

0 comments on commit 8e8d87b

Please sign in to comment.