diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-02-14 15:03:35 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-04-07 14:36:40 -0400 |
commit | cc6c2127f2316c2b2ad1e8919b45cde5e03f65aa (patch) | |
tree | d75c2fe1f4e0be7756b0277e9c707b5dc03c9912 /net | |
parent | 48e6555c7b3bf0d92f8167d8b8b8ecf4a3fdab84 (diff) |
svcrpc: close connection if client sends short packet
If the client sents a record too short to contain even the beginning of
the rpc header, then just close the connection.
The current code drops the record data and continues. I don't see the
point. It's a hopeless situation and simpler just to cut off the
connection completely.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/svcsock.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 1955e1a1e390..62ff7c5c09c2 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -955,6 +955,9 @@ static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp) | |||
955 | } | 955 | } |
956 | } | 956 | } |
957 | 957 | ||
958 | if (svsk->sk_reclen < 8) | ||
959 | goto err_delete; /* client is nuts. */ | ||
960 | |||
958 | /* Check whether enough data is available */ | 961 | /* Check whether enough data is available */ |
959 | len = svc_recv_available(svsk); | 962 | len = svc_recv_available(svsk); |
960 | if (len < 0) | 963 | if (len < 0) |
@@ -1058,20 +1061,10 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) | |||
1058 | vec[0] = rqstp->rq_arg.head[0]; | 1061 | vec[0] = rqstp->rq_arg.head[0]; |
1059 | vlen = PAGE_SIZE; | 1062 | vlen = PAGE_SIZE; |
1060 | 1063 | ||
1061 | /* | 1064 | len = svc_process_calldir(svsk, rqstp, &req, vec); |
1062 | * We have enough data for the whole tcp record. Let's try and read the | 1065 | if (len < 0) |
1063 | * first 8 bytes to get the xid and the call direction. We can use this | 1066 | goto err_again; |
1064 | * to figure out if this is a call or a reply to a callback. If | 1067 | vlen -= 8; |
1065 | * sk_reclen is < 8 (xid and calldir), then this is a malformed packet. | ||
1066 | * In that case, don't bother with the calldir and just read the data. | ||
1067 | * It will be rejected in svc_process. | ||
1068 | */ | ||
1069 | if (len >= 8) { | ||
1070 | len = svc_process_calldir(svsk, rqstp, &req, vec); | ||
1071 | if (len < 0) | ||
1072 | goto err_again; | ||
1073 | vlen -= 8; | ||
1074 | } | ||
1075 | 1068 | ||
1076 | pnum = 1; | 1069 | pnum = 1; |
1077 | while (vlen < svsk->sk_reclen - 8) { | 1070 | while (vlen < svsk->sk_reclen - 8) { |