netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ursula Braun <ubraun@linux.vnet.ibm.com>
To: davem@davemloft.net, mschwid2@linux.vnet.ibm.com,
	heicars2@linux.vnet.ibm.com, netdev@vger.kernel.org,
	linux-s390@vger.kernel.org
Cc: ubraunu@linux.vnet.ibm.com
Subject: [PATCH net-next 2/8] iucv: call skb_linearize() when needed
Date: Fri, 11 Dec 2015 12:27:51 +0100	[thread overview]
Message-ID: <1449833277-69012-3-git-send-email-ubraun@linux.vnet.ibm.com> (raw)
In-Reply-To: <1449833277-69012-1-git-send-email-ubraun@linux.vnet.ibm.com>

From: Eugene Crosser <Eugene.Crosser@ru.ibm.com>

When the linear buffer of the received sk_buff is shorter than
the header, use skb_linearize(). sk_buffs with short linear buffer
happen on the sending side under high traffic, and some kernel
configurations, when allocated buffer starts just before page
boundary, and IUCV transport has to send it as two separate QDIO
buffer elements, with fist element shorter than the header.

Signed-off-by: Eugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
---
 net/iucv/af_iucv.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 5bc473b..ef50a94 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -2084,11 +2084,7 @@ static int afiucv_hs_callback_rx(struct sock *sk, struct sk_buff *skb)
 		return NET_RX_SUCCESS;
 	}
 
-		/* write stuff from iucv_msg to skb cb */
-	if (skb->len < sizeof(struct af_iucv_trans_hdr)) {
-		kfree_skb(skb);
-		return NET_RX_SUCCESS;
-	}
+	/* write stuff from iucv_msg to skb cb */
 	skb_pull(skb, sizeof(struct af_iucv_trans_hdr));
 	skb_reset_transport_header(skb);
 	skb_reset_network_header(skb);
@@ -2119,6 +2115,20 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
 	char nullstring[8];
 	int err = 0;
 
+	if (skb->len < (ETH_HLEN + sizeof(struct af_iucv_trans_hdr))) {
+		WARN_ONCE(1, "AF_IUCV too short skb, len=%d, min=%d",
+			  (int)skb->len,
+			  (int)(ETH_HLEN + sizeof(struct af_iucv_trans_hdr)));
+		kfree_skb(skb);
+		return NET_RX_SUCCESS;
+	}
+	if (skb_headlen(skb) < (ETH_HLEN + sizeof(struct af_iucv_trans_hdr)))
+		if (skb_linearize(skb)) {
+			WARN_ONCE(1, "AF_IUCV skb_linearize failed, len=%d",
+				  (int)skb->len);
+			kfree_skb(skb);
+			return NET_RX_SUCCESS;
+		}
 	skb_pull(skb, ETH_HLEN);
 	trans_hdr = (struct af_iucv_trans_hdr *)skb->data;
 	EBCASC(trans_hdr->destAppName, sizeof(trans_hdr->destAppName));
-- 
2.3.9

  parent reply	other threads:[~2015-12-11 11:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11 11:27 [PATCH net-next 0/8] s390 network patches Ursula Braun
2015-12-11 11:27 ` [PATCH net-next 1/8] iucv: prevent information leak in iucv_message Ursula Braun
2015-12-11 11:27 ` Ursula Braun [this message]
2015-12-11 11:27 ` [PATCH net-next 3/8] MAINTAINERS: switch to alternate IBM mail address Ursula Braun
2015-12-11 11:27 ` [PATCH net-next 4/8] s390-ctcm: Delete unnecessary checks before the function call "channel_remove" Ursula Braun
2015-12-11 11:27 ` [PATCH net-next 5/8] qeth use common function qeth_get_setassparms_cmd Ursula Braun
2015-12-11 11:27 ` [PATCH net-next 6/8] qeth: initialize net_device with carrier off Ursula Braun
2015-12-11 11:27 ` [PATCH net-next 7/8] qeth: repair SBAL elements calculation Ursula Braun
2015-12-11 11:27 ` [PATCH net-next 8/8] qeth: get rid of redundant 0-termination Ursula Braun
2015-12-14 21:17 ` [PATCH net-next 0/8] s390 network patches 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=1449833277-69012-3-git-send-email-ubraun@linux.vnet.ibm.com \
    --to=ubraun@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=heicars2@linux.vnet.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=mschwid2@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=ubraunu@linux.vnet.ibm.com \
    /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).