From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 4/7] svcrpc: close connection if client sends short packet
Date: Wed, 6 Apr 2011 19:06:23 -0400 [thread overview]
Message-ID: <1302131186-6578-5-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <1302131186-6578-1-git-send-email-bfields@redhat.com>
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>
---
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 2053259..9d72a79 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -949,6 +949,9 @@ static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp)
}
}
+ if (svsk->sk_reclen < 8)
+ goto err_delete; /* client is nuts. */
+
/* Check whether enough data is available */
len = svc_recv_available(svsk);
if (len < 0)
@@ -1052,20 +1055,10 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
vec[0] = rqstp->rq_arg.head[0];
vlen = PAGE_SIZE;
- /*
- * We have enough data for the whole tcp record. Let's try and read the
- * first 8 bytes to get the xid and the call direction. We can use this
- * to figure out if this is a call or a reply to a callback. If
- * sk_reclen is < 8 (xid and calldir), then this is a malformed packet.
- * In that case, don't bother with the calldir and just read the data.
- * It will be rejected in svc_process.
- */
- if (len >= 8) {
- len = svc_process_calldir(svsk, rqstp, &req, vec);
- if (len < 0)
- goto err_again;
- vlen -= 8;
- }
+ len = svc_process_calldir(svsk, rqstp, &req, vec);
+ if (len < 0)
+ goto err_again;
+ vlen -= 8;
pnum = 1;
while (vlen < svsk->sk_reclen - 8) {
--
1.7.1
next prev parent reply other threads:[~2011-04-06 23:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-06 23:06 server tcp performance patches J. Bruce Fields
2011-04-06 23:06 ` [PATCH 1/7] SUNRPC: requeue tcp socket less frequently J. Bruce Fields
2011-04-06 23:06 ` [PATCH 2/7] SUNRPC: svc_tcp_recvfrom cleanup J. Bruce Fields
2011-04-06 23:06 ` [PATCH 3/7] svcrpc: note network-order types in svc_process_calldir J. Bruce Fields
2011-04-06 23:06 ` J. Bruce Fields [this message]
2011-04-06 23:06 ` [PATCH 5/7] svcrpc: copy cb reply instead of pages J. Bruce Fields
2011-04-06 23:06 ` [PATCH 6/7] SUNRPC: Don't wait for full record to receive tcp data J. Bruce Fields
2011-04-06 23:06 ` [PATCH 7/7] svcrpc: take advantage of tcp autotuning J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1302131186-6578-5-git-send-email-bfields@redhat.com \
--to=bfields@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).