netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Santosh Shilimkar <santosh.shilimkar@oracle.com>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, davem@davemloft.net,
	ssantosh@kernel.org, Mukesh Kacker <mukesh.kacker@oracle.com>,
	Santosh Shilimkar <santosh.shilimkar@oracle.com>
Subject: [PATCH 13/14] RDS: return EMSGSIZE for oversize requests before processing/queueing
Date: Sat, 22 Aug 2015 15:45:34 -0700	[thread overview]
Message-ID: <1440283535-4800-14-git-send-email-santosh.shilimkar@oracle.com> (raw)
In-Reply-To: <1440283535-4800-1-git-send-email-santosh.shilimkar@oracle.com>

From: Mukesh Kacker <mukesh.kacker@oracle.com>

rds_send_queue_rm() allows for the "current datagram" being queued
to exceed SO_SNDBUF thresholds by checking bytes queued without
counting in length of current datagram. (Since sk_sndbuf is set
to twice requested SO_SNDBUF value as a kernel heuristic this
is usually fine!)

If this "current datagram" squeezing past the threshold is itself
many times the size of the sk_sndbuf threshold itself then even
twice the SO_SNDBUF does not save us and it gets queued but
cannot be transmitted. Threads block and deadlock and device
becomes unusable. The check for this datagram not exceeding
SNDBUF thresholds (EMSGSIZE) is not done on this datagram as
that check is only done if queueing attempt fails.
(Datagrams that follow this datagram fail queueing attempts, go
through the check and eventually trip EMSGSIZE error but zero
length datagrams silently fail!)

This fix moves the check for datagrams exceeding SNDBUF limits
before any processing or queueing is attempted and returns EMSGSIZE
early in the rds_sndmsg() code. This change also ensures that all
datagrams get checked for exceeding SNDBUF/sk_sndbuf size limits
and the large datagrams that exceed those limits do not get to
rds_send_queue_rm() code for processing.

Signed-off-by: Mukesh Kacker <mukesh.kacker@oracle.com>
Signed-off-by: Santosh Shilimkar <ssantosh@kernel.org>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
---
 net/rds/send.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/rds/send.c b/net/rds/send.c
index b0fe412..c2667bf 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -1015,6 +1015,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
 		goto out;
 	}
 
+	if (payload_len > rds_sk_sndbuf(rs)) {
+		ret = -EMSGSIZE;
+		goto out;
+	}
+
 	/* size of rm including all sgs */
 	ret = rds_rm_size(msg, payload_len);
 	if (ret < 0)
@@ -1086,11 +1091,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
 	while (!rds_send_queue_rm(rs, conn, rm, rs->rs_bound_port,
 				  dport, &queued)) {
 		rds_stats_inc(s_send_queue_full);
-		/* XXX make sure this is reasonable */
-		if (payload_len > rds_sk_sndbuf(rs)) {
-			ret = -EMSGSIZE;
-			goto out;
-		}
+
 		if (nonblock) {
 			ret = -EAGAIN;
 			goto out;
-- 
1.9.1

  parent reply	other threads:[~2015-08-22 22:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-22 22:45 [PATCH 00/14] RDS: Assorted bug fixes Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 01/14] RDS: restore return value in rds_cmsg_rdma_args() Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 02/14] RDS: always free recv frag as we free its ring entry Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 03/14] RDS: destroy the ib state earlier during shutdown Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 04/14] RDS: don't update ip address tables if the address hasn't changed Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 05/14] RDS: make sure we post recv buffers Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 06/14] RDS: check for congestion updates during rds_send_xmit Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 07/14] RDS: add a sock_destruct callback debug aid Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 08/14] RDS: Mark message mapped before transmit Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 09/14] RDS: Make sure we do a signaled send for large-send Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 10/14] RDS: Fix assertion level from fatal to warning Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 11/14] RDS: Don't destroy the rdma id until after we're done using it Santosh Shilimkar
2015-08-22 22:45 ` [PATCH 12/14] RDS: make sure rds_send_drop_to properly takes the m_rs_lock Santosh Shilimkar
2015-08-22 22:45 ` Santosh Shilimkar [this message]
2015-08-22 22:45 ` [PATCH 14/14] RDS: check for valid cm_id before initiating connection Santosh Shilimkar
2015-08-25 20:35 ` [PATCH 00/14] RDS: Assorted bug fixes David Miller

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=1440283535-4800-14-git-send-email-santosh.shilimkar@oracle.com \
    --to=santosh.shilimkar@oracle.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mukesh.kacker@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=ssantosh@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).