[bug report] cifsd: add server-side procedures for SMB3

Dan Carpenter
2024-07-19T23:55:49Z

Commit e2f34481b24d ("cifsd: add server-side procedures for SMB3")
from Mar 16, 2021 (linux-next), leads to the following Smatch static
checker warning:

fs/smb/server/smb2pdu.c:8864 smb3_preauth_hash_rsp()
error: we previously assumed 'conn->preauth_info' could be null (see line 8844)

fs/smb/server/smb2pdu.c
8832 void smb3_preauth_hash_rsp(struct ksmbd_work *work)
8833 {
8834 struct ksmbd_conn *conn = work->conn;
8835 struct ksmbd_session *sess = work->sess;
8836 struct smb2_hdr *req, *rsp;
8837
8838 if (conn->dialect != SMB311_PROT_ID)
8839 return;
8840
8841 WORK_BUFFERS(work, req, rsp);
8842
8843 if (le16_to_cpu(req->Command) == SMB2_NEGOTIATE_HE &&
8844 conn->preauth_info)
^^^^^^^^^^^^^^^^^^
This checks for NULL for ksmbd_gen_preauth_integrity_hash().

8845 ksmbd_gen_preauth_integrity_hash(conn, work->response_buf,
8846 conn->preauth_info->Preauth_HashValue);
8847
8848 if (le16_to_cpu(rsp->Command) == SMB2_SESSION_SETUP_HE && sess) {
8849 __u8 *hash_value;
8850
8851 if (conn->binding) {
8852 struct preauth_session *preauth_sess;
8853
8854 preauth_sess = ksmbd_preauth_session_lookup(conn, sess->id);
8855 if (!preauth_sess)
8856 return;
8857 hash_value = preauth_sess->Preauth_HashValue;
8858 } else {
8859 hash_value = sess->Preauth_HashValue;
8860 if (!hash_value)
8861 return;
8862 }
8863 ksmbd_gen_preauth_integrity_hash(conn, work->response_buf,
^^^^
This call doesn't.

--> 8864 hash_value);
8865 }
8866 }