|
|
6729ff |
From 44cf46b0bbb0abf5aebfbf2f2da713da65573175 Mon Sep 17 00:00:00 2001
|
|
|
6729ff |
From: Gregor Beck <gbeck@sernet.de>
|
|
|
6729ff |
Date: Thu, 9 Jan 2014 10:15:31 +0100
|
|
|
6729ff |
Subject: [PATCH 1/2] s3:rpc_server: minor refactoring of process_request_pdu()
|
|
|
6729ff |
|
|
|
6729ff |
Signed-off-by: Gregor Beck <gbeck@sernet.de>
|
|
|
6729ff |
Reviewed-by: Stefan Metzmacher <metze@samba.org>
|
|
|
6729ff |
Reviewed-by: Guenther Deschner <gd@samba.org>
|
|
|
6729ff |
(cherry picked from commit b5f30205931a4b9d0b3b257d5855869e606f8b63)
|
|
|
6729ff |
---
|
|
|
6729ff |
source3/rpc_server/srv_pipe.c | 25 ++++++++++---------------
|
|
|
6729ff |
1 file changed, 10 insertions(+), 15 deletions(-)
|
|
|
6729ff |
|
|
|
6729ff |
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
|
|
|
6729ff |
index 894f12c..a5b74ed 100644
|
|
|
6729ff |
--- a/source3/rpc_server/srv_pipe.c
|
|
|
6729ff |
+++ b/source3/rpc_server/srv_pipe.c
|
|
|
6729ff |
@@ -1561,24 +1561,19 @@ static bool process_request_pdu(struct pipes_struct *p, struct ncacn_packet *pkt
|
|
|
6729ff |
}
|
|
|
6729ff |
}
|
|
|
6729ff |
|
|
|
6729ff |
- if (pkt->pfc_flags & DCERPC_PFC_FLAG_LAST) {
|
|
|
6729ff |
- bool ret = False;
|
|
|
6729ff |
- /*
|
|
|
6729ff |
- * Ok - we finally have a complete RPC stream.
|
|
|
6729ff |
- * Call the rpc command to process it.
|
|
|
6729ff |
- */
|
|
|
6729ff |
-
|
|
|
6729ff |
- /*
|
|
|
6729ff |
- * Process the complete data stream here.
|
|
|
6729ff |
- */
|
|
|
6729ff |
- if (pipe_init_outgoing_data(p)) {
|
|
|
6729ff |
- ret = api_pipe_request(p, pkt);
|
|
|
6729ff |
- }
|
|
|
6729ff |
+ if (!(pkt->pfc_flags & DCERPC_PFC_FLAG_LAST)) {
|
|
|
6729ff |
+ return true;
|
|
|
6729ff |
+ }
|
|
|
6729ff |
|
|
|
6729ff |
- return ret;
|
|
|
6729ff |
+ /*
|
|
|
6729ff |
+ * Ok - we finally have a complete RPC stream.
|
|
|
6729ff |
+ * Call the rpc command to process it.
|
|
|
6729ff |
+ */
|
|
|
6729ff |
+ if (!pipe_init_outgoing_data(p)) {
|
|
|
6729ff |
+ return false;
|
|
|
6729ff |
}
|
|
|
6729ff |
|
|
|
6729ff |
- return True;
|
|
|
6729ff |
+ return api_pipe_request(p, pkt);
|
|
|
6729ff |
}
|
|
|
6729ff |
|
|
|
6729ff |
/****************************************************************************
|
|
|
6729ff |
--
|
|
|
6729ff |
1.9.0
|
|
|
6729ff |
|
|
|
6729ff |
|
|
|
6729ff |
From 436aa053561b9b6ff4b991bf6a2f5196ed39dd38 Mon Sep 17 00:00:00 2001
|
|
|
6729ff |
From: Andreas Schneider <asn@cryptomilk.org>
|
|
|
6729ff |
Date: Thu, 20 Mar 2014 14:45:01 +0100
|
|
|
6729ff |
Subject: [PATCH 2/2] s3-rpc_server: Fix handling of fragmented rpc requests.
|
|
|
6729ff |
MIME-Version: 1.0
|
|
|
6729ff |
Content-Type: text/plain; charset=UTF-8
|
|
|
6729ff |
Content-Transfer-Encoding: 8bit
|
|
|
6729ff |
|
|
|
6729ff |
We need to call pipe_init_outgoing_data() as the first thing in
|
|
|
6729ff |
process_complete_pdu(). Otherwise the caller may use uninitialized
|
|
|
6729ff |
memory and tries to write a response into the socket.
|
|
|
6729ff |
|
|
|
6729ff |
The problem happens only if a real socket is used, which means
|
|
|
6729ff |
in all cases for master and only with external rpc daemons in v4-0
|
|
|
6729ff |
and v4-1.
|
|
|
6729ff |
|
|
|
6729ff |
The problem looks like this in the logs.
|
|
|
6729ff |
|
|
|
6729ff |
[2014/03/20 14:49:35.531663, 10, pid=7309, effective(0, 0), real(0, 0), class=rpc_srv] ../source3/rpc_server/srv_pipe.c:1627(process_complete_pdu)
|
|
|
6729ff |
Processing packet type 0
|
|
|
6729ff |
[2014/03/20 14:49:35.531695, 10, pid=7309, effective(0, 0), real(0, 0), class=rpc_srv] ../source3/rpc_server/srv_pipe.c:1472(dcesrv_auth_request)
|
|
|
6729ff |
Checking request auth.
|
|
|
6729ff |
[2014/03/20 14:49:35.531738, 10, pid=7309, effective(0, 0), real(0, 0)] ../source3/rpc_server/rpc_server.c:521(named_pipe_packet_process)
|
|
|
6729ff |
Sending 1 fragments in a total of 0 bytes
|
|
|
6729ff |
[2014/03/20 14:49:35.531769, 10, pid=7309, effective(0, 0), real(0, 0)] ../source3/rpc_server/rpc_server.c:526(named_pipe_packet_process)
|
|
|
6729ff |
Sending PDU number: 0, PDU Length: 4294967228
|
|
|
6729ff |
[2014/03/20 14:49:35.531801, 2, pid=7309, effective(0, 0), real(0, 0)] ../source3/rpc_server/rpc_server.c:565(named_pipe_packet_done)
|
|
|
6729ff |
Writev failed!
|
|
|
6729ff |
[2014/03/20 14:49:35.531845, 2, pid=7309, effective(0, 0), real(0, 0)] ../source3/rpc_server/rpc_server.c:595(named_pipe_packet_done)
|
|
|
6729ff |
Fatal error(Message too long). Terminating client(127.0.0.1) connection!
|
|
|
6729ff |
|
|
|
6729ff |
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10481
|
|
|
6729ff |
|
|
|
6729ff |
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
|
|
|
6729ff |
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
|
|
|
6729ff |
Reviewed-by: Guenther Deschner
|
|
|
6729ff |
|
|
|
6729ff |
Autobuild-User(master): Günther Deschner <gd@samba.org>
|
|
|
6729ff |
Autobuild-Date(master): Thu Mar 20 18:30:17 CET 2014 on sn-devel-104
|
|
|
6729ff |
|
|
|
6729ff |
(cherry picked from commit 5277fc4d0393ffe2e415ad26610b36d2986c62d7)
|
|
|
6729ff |
---
|
|
|
6729ff |
source3/rpc_server/srv_pipe.c | 19 +++++++------------
|
|
|
6729ff |
1 file changed, 7 insertions(+), 12 deletions(-)
|
|
|
6729ff |
|
|
|
6729ff |
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
|
|
|
6729ff |
index a5b74ed..7daff04 100644
|
|
|
6729ff |
--- a/source3/rpc_server/srv_pipe.c
|
|
|
6729ff |
+++ b/source3/rpc_server/srv_pipe.c
|
|
|
6729ff |
@@ -1569,9 +1569,6 @@ static bool process_request_pdu(struct pipes_struct *p, struct ncacn_packet *pkt
|
|
|
6729ff |
* Ok - we finally have a complete RPC stream.
|
|
|
6729ff |
* Call the rpc command to process it.
|
|
|
6729ff |
*/
|
|
|
6729ff |
- if (!pipe_init_outgoing_data(p)) {
|
|
|
6729ff |
- return false;
|
|
|
6729ff |
- }
|
|
|
6729ff |
|
|
|
6729ff |
return api_pipe_request(p, pkt);
|
|
|
6729ff |
}
|
|
|
6729ff |
@@ -1621,6 +1618,10 @@ void process_complete_pdu(struct pipes_struct *p)
|
|
|
6729ff |
|
|
|
6729ff |
DEBUG(10, ("Processing packet type %u\n", (unsigned int)pkt->ptype));
|
|
|
6729ff |
|
|
|
6729ff |
+ if (!pipe_init_outgoing_data(p)) {
|
|
|
6729ff |
+ goto done;
|
|
|
6729ff |
+ }
|
|
|
6729ff |
+
|
|
|
6729ff |
switch (pkt->ptype) {
|
|
|
6729ff |
case DCERPC_PKT_REQUEST:
|
|
|
6729ff |
reply = process_request_pdu(p, pkt);
|
|
|
6729ff |
@@ -1653,9 +1654,7 @@ void process_complete_pdu(struct pipes_struct *p)
|
|
|
6729ff |
/*
|
|
|
6729ff |
* We assume that a pipe bind is only in one pdu.
|
|
|
6729ff |
*/
|
|
|
6729ff |
- if (pipe_init_outgoing_data(p)) {
|
|
|
6729ff |
- reply = api_pipe_bind_req(p, pkt);
|
|
|
6729ff |
- }
|
|
|
6729ff |
+ reply = api_pipe_bind_req(p, pkt);
|
|
|
6729ff |
break;
|
|
|
6729ff |
|
|
|
6729ff |
case DCERPC_PKT_BIND_ACK:
|
|
|
6729ff |
@@ -1670,9 +1669,7 @@ void process_complete_pdu(struct pipes_struct *p)
|
|
|
6729ff |
/*
|
|
|
6729ff |
* We assume that a pipe bind is only in one pdu.
|
|
|
6729ff |
*/
|
|
|
6729ff |
- if (pipe_init_outgoing_data(p)) {
|
|
|
6729ff |
- reply = api_pipe_alter_context(p, pkt);
|
|
|
6729ff |
- }
|
|
|
6729ff |
+ reply = api_pipe_alter_context(p, pkt);
|
|
|
6729ff |
break;
|
|
|
6729ff |
|
|
|
6729ff |
case DCERPC_PKT_ALTER_RESP:
|
|
|
6729ff |
@@ -1684,9 +1681,7 @@ void process_complete_pdu(struct pipes_struct *p)
|
|
|
6729ff |
/*
|
|
|
6729ff |
* The third packet in an auth exchange.
|
|
|
6729ff |
*/
|
|
|
6729ff |
- if (pipe_init_outgoing_data(p)) {
|
|
|
6729ff |
- reply = api_pipe_bind_auth3(p, pkt);
|
|
|
6729ff |
- }
|
|
|
6729ff |
+ reply = api_pipe_bind_auth3(p, pkt);
|
|
|
6729ff |
break;
|
|
|
6729ff |
|
|
|
6729ff |
case DCERPC_PKT_SHUTDOWN:
|
|
|
6729ff |
--
|
|
|
6729ff |
1.9.0
|
|
|
6729ff |
|