From: Jeremy Allison Date: Tue, 26 Nov 2019 20:43:25 +0000 (-0800) Subject: s3: smbd: Change (*proto_reply_fn()) to return an NTSTATUS. X-Git-Tag: samba-4.10.13~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb1beba0091179554d19ac9e76efa068df169652;p=thirdparty%2Fsamba.git s3: smbd: Change (*proto_reply_fn()) to return an NTSTATUS. That way the caller can know if the negprot really succeeded or not. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14205 Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke (cherry picked from commit f4caa4159bd3db5127e114718e606867348a4f47) --- diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 0a4fcd96b43..9bb7b1f49c8 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -237,8 +237,8 @@ bool smbd_smb2_is_compound(const struct smbd_smb2_request *req); NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd, struct smbXsrv_connection **_xconn); -void reply_smb2002(struct smb_request *req, uint16_t choice); -void reply_smb20ff(struct smb_request *req, uint16_t choice); +NTSTATUS reply_smb2002(struct smb_request *req, uint16_t choice); +NTSTATUS reply_smb20ff(struct smb_request *req, uint16_t choice); NTSTATUS smbd_smb2_process_negprot(struct smbXsrv_connection *xconn, uint64_t expected_seq_low, const uint8_t *inpdu, size_t size); diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 2d5edf1282c..3b2555e3d21 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -66,7 +66,7 @@ static void get_challenge(struct smbXsrv_connection *xconn, uint8_t buff[8]) Reply for the lanman 1.0 protocol. ****************************************************************************/ -static void reply_lanman1(struct smb_request *req, uint16_t choice) +static NTSTATUS reply_lanman1(struct smb_request *req, uint16_t choice) { int secword=0; time_t t = time(NULL); @@ -100,7 +100,7 @@ static void reply_lanman1(struct smb_request *req, uint16_t choice) status = smbXsrv_connection_init_tables(xconn, PROTOCOL_LANMAN1); if (!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); - return; + return status; } /* Reply, SMBlockread, SMBwritelock supported. */ @@ -115,14 +115,14 @@ static void reply_lanman1(struct smb_request *req, uint16_t choice) srv_put_dos_date((char *)req->outbuf,smb_vwv8,t); - return; + return NT_STATUS_OK; } /**************************************************************************** Reply for the lanman 2.0 protocol. ****************************************************************************/ -static void reply_lanman2(struct smb_request *req, uint16_t choice) +static NTSTATUS reply_lanman2(struct smb_request *req, uint16_t choice) { int secword=0; time_t t = time(NULL); @@ -158,7 +158,7 @@ static void reply_lanman2(struct smb_request *req, uint16_t choice) status = smbXsrv_connection_init_tables(xconn, PROTOCOL_LANMAN2); if (!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); - return; + return status; } /* Reply, SMBlockread, SMBwritelock supported. */ @@ -169,6 +169,7 @@ static void reply_lanman2(struct smb_request *req, uint16_t choice) SSVAL(req->outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */ SSVAL(req->outbuf,smb_vwv10, set_server_zone_offset(t)/60); srv_put_dos_date((char *)req->outbuf,smb_vwv8,t); + return NT_STATUS_OK; } /**************************************************************************** @@ -266,7 +267,7 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbXsrv_connection *xconn) Reply for the nt protocol. ****************************************************************************/ -static void reply_nt1(struct smb_request *req, uint16_t choice) +static NTSTATUS reply_nt1(struct smb_request *req, uint16_t choice) { /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| @@ -359,7 +360,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice) status = smbXsrv_connection_init_tables(xconn, PROTOCOL_NT1); if (!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); - return; + return status; } SSVAL(req->outbuf,smb_vwv1+1, lp_max_mux()); /* maxmpx */ @@ -385,7 +386,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice) if (ret == -1) { DEBUG(0, ("Could not push challenge\n")); reply_nterror(req, NT_STATUS_NO_MEMORY); - return; + return NT_STATUS_NO_MEMORY; } SCVAL(req->outbuf, smb_vwv16+1, ret); } @@ -395,7 +396,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice) if (ret == -1) { DEBUG(0, ("Could not push workgroup string\n")); reply_nterror(req, NT_STATUS_NO_MEMORY); - return; + return NT_STATUS_NO_MEMORY; } ret = message_push_string(&req->outbuf, lp_netbios_name(), STR_UNICODE|STR_TERMINATE @@ -403,7 +404,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice) if (ret == -1) { DEBUG(0, ("Could not push netbios name string\n")); reply_nterror(req, NT_STATUS_NO_MEMORY); - return; + return NT_STATUS_NO_MEMORY; } DEBUG(3,("not using SPNEGO\n")); } else { @@ -411,14 +412,14 @@ static void reply_nt1(struct smb_request *req, uint16_t choice) if (spnego_blob.data == NULL) { reply_nterror(req, NT_STATUS_NO_MEMORY); - return; + return NT_STATUS_NO_MEMORY; } ret = message_push_blob(&req->outbuf, spnego_blob); if (ret == -1) { DEBUG(0, ("Could not push spnego blob\n")); reply_nterror(req, NT_STATUS_NO_MEMORY); - return; + return NT_STATUS_NO_MEMORY; } data_blob_free(&spnego_blob); @@ -426,7 +427,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice) DEBUG(3,("using SPNEGO\n")); } - return; + return NT_STATUS_OK; } /* these are the protocol lists used for auto architecture detection: @@ -540,7 +541,7 @@ protocol [SMB 2.???] static const struct { const char *proto_name; const char *short_name; - void (*proto_reply_fn)(struct smb_request *req, uint16_t choice); + NTSTATUS (*proto_reply_fn)(struct smb_request *req, uint16_t choice); int protocol_level; } supported_protocols[] = { {"SMB 2.???", "SMB2_FF", reply_smb20ff, PROTOCOL_SMB2_10}, diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c index fc0d884ad1d..1785fcf5ee8 100644 --- a/source3/smbd/smb2_negprot.c +++ b/source3/smbd/smb2_negprot.c @@ -71,20 +71,20 @@ static NTSTATUS reply_smb20xx(struct smb_request *req, uint16_t dialect) * this is the entry point if SMB2 is selected via * the SMB negprot and the "SMB 2.002" dialect. */ -void reply_smb2002(struct smb_request *req, uint16_t choice) +NTSTATUS reply_smb2002(struct smb_request *req, uint16_t choice) { - reply_smb20xx(req, SMB2_DIALECT_REVISION_202); + return reply_smb20xx(req, SMB2_DIALECT_REVISION_202); } /* * this is the entry point if SMB2 is selected via * the SMB negprot and the "SMB 2.???" dialect. */ -void reply_smb20ff(struct smb_request *req, uint16_t choice) +NTSTATUS reply_smb20ff(struct smb_request *req, uint16_t choice) { struct smbXsrv_connection *xconn = req->xconn; xconn->smb2.allow_2ff = true; - reply_smb20xx(req, SMB2_DIALECT_REVISION_2FF); + return reply_smb20xx(req, SMB2_DIALECT_REVISION_2FF); } enum protocol_types smbd_smb2_protocol_dialect_match(const uint8_t *indyn,