netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v1 0/3] tipc: buffer reassignment fixes
@ 2017-08-24 14:31 Parthasarathy Bhuvaragan
  2017-08-24 14:31 ` [PATCH net v1 1/3] tipc: perform skb_linearize() before parsing the inner header Parthasarathy Bhuvaragan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Parthasarathy Bhuvaragan @ 2017-08-24 14:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, tipc-discussion, jon.maloy, maloy, ying.xue

This series contains fixes for buffer reassignments and a context imbalance.

Parthasarathy Bhuvaragan (3):
  tipc: perform skb_linearize() before parsing the inner header
  tipc: reassign pointers after skb reallocation / linearization
  tipc: context imbalance at node read unlock

 net/tipc/msg.c  | 7 +++++--
 net/tipc/node.c | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v1 1/3] tipc: perform skb_linearize() before parsing the inner header
  2017-08-24 14:31 [PATCH net v1 0/3] tipc: buffer reassignment fixes Parthasarathy Bhuvaragan
@ 2017-08-24 14:31 ` Parthasarathy Bhuvaragan
  2017-08-24 14:31 ` [PATCH net v1 2/3] tipc: reassign pointers after skb reallocation / linearization Parthasarathy Bhuvaragan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Parthasarathy Bhuvaragan @ 2017-08-24 14:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, tipc-discussion, jon.maloy, maloy, ying.xue

In tipc_rcv(), we linearize only the header and usually the packets
are consumed as the nodes permit direct reception. However, if the
skb contains tunnelled message due to fail over or synchronization
we parse it in tipc_node_check_state() without performing
linearization. This will cause link disturbances if the skb was
non linear.

In this commit, we perform linearization for the above messages.

Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
 net/tipc/node.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index 9b4dcb6a16b5..b113a52f8914 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1557,6 +1557,8 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)
 
 	/* Check/update node state before receiving */
 	if (unlikely(skb)) {
+		if (unlikely(skb_linearize(skb)))
+			goto discard;
 		tipc_node_write_lock(n);
 		if (tipc_node_check_state(n, skb, bearer_id, &xmitq)) {
 			if (le->link) {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net v1 2/3] tipc: reassign pointers after skb reallocation / linearization
  2017-08-24 14:31 [PATCH net v1 0/3] tipc: buffer reassignment fixes Parthasarathy Bhuvaragan
  2017-08-24 14:31 ` [PATCH net v1 1/3] tipc: perform skb_linearize() before parsing the inner header Parthasarathy Bhuvaragan
@ 2017-08-24 14:31 ` Parthasarathy Bhuvaragan
  2017-08-24 14:31 ` [PATCH net v1 3/3] tipc: context imbalance at node read unlock Parthasarathy Bhuvaragan
  2017-08-25  4:54 ` [PATCH net v1 0/3] tipc: buffer reassignment fixes David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Parthasarathy Bhuvaragan @ 2017-08-24 14:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, tipc-discussion, jon.maloy, maloy, ying.xue

In tipc_msg_reverse(), we assign skb attributes to local pointers
in stack at startup. This is followed by skb_linearize() and for
cloned buffers we perform skb relocation using pskb_expand_head().
Both these methods may update the skb attributes and thus making
the pointers incorrect.

In this commit, we fix this error by ensuring that the pointers
are re-assigned after any of these skb operations.

Fixes: 29042e19f2c60 ("tipc: let function tipc_msg_reverse() expand header
when needed")
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
 net/tipc/msg.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index dcd90e6fa7c3..6ef379f004ac 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -479,13 +479,14 @@ bool tipc_msg_make_bundle(struct sk_buff **skb,  struct tipc_msg *msg,
 bool tipc_msg_reverse(u32 own_node,  struct sk_buff **skb, int err)
 {
 	struct sk_buff *_skb = *skb;
-	struct tipc_msg *hdr = buf_msg(_skb);
+	struct tipc_msg *hdr;
 	struct tipc_msg ohdr;
-	int dlen = min_t(uint, msg_data_sz(hdr), MAX_FORWARD_SIZE);
+	int dlen;
 
 	if (skb_linearize(_skb))
 		goto exit;
 	hdr = buf_msg(_skb);
+	dlen = min_t(uint, msg_data_sz(hdr), MAX_FORWARD_SIZE);
 	if (msg_dest_droppable(hdr))
 		goto exit;
 	if (msg_errcode(hdr))
@@ -511,6 +512,8 @@ bool tipc_msg_reverse(u32 own_node,  struct sk_buff **skb, int err)
 	    pskb_expand_head(_skb, BUF_HEADROOM, BUF_TAILROOM, GFP_ATOMIC))
 		goto exit;
 
+	/* reassign after skb header modifications */
+	hdr = buf_msg(_skb);
 	/* Now reverse the concerned fields */
 	msg_set_errcode(hdr, err);
 	msg_set_non_seq(hdr, 0);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net v1 3/3] tipc: context imbalance at node read unlock
  2017-08-24 14:31 [PATCH net v1 0/3] tipc: buffer reassignment fixes Parthasarathy Bhuvaragan
  2017-08-24 14:31 ` [PATCH net v1 1/3] tipc: perform skb_linearize() before parsing the inner header Parthasarathy Bhuvaragan
  2017-08-24 14:31 ` [PATCH net v1 2/3] tipc: reassign pointers after skb reallocation / linearization Parthasarathy Bhuvaragan
@ 2017-08-24 14:31 ` Parthasarathy Bhuvaragan
  2017-08-25  4:54 ` [PATCH net v1 0/3] tipc: buffer reassignment fixes David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Parthasarathy Bhuvaragan @ 2017-08-24 14:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, tipc-discussion, jon.maloy, maloy, ying.xue

If we fail to find a valid bearer in tipc_node_get_linkname(),
node_read_unlock() is called without holding the node read lock.

This commit fixes this error.

Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
 net/tipc/node.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index b113a52f8914..7dd22330a6b4 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1126,8 +1126,8 @@ int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr,
 		strncpy(linkname, tipc_link_name(link), len);
 		err = 0;
 	}
-exit:
 	tipc_node_read_unlock(node);
+exit:
 	tipc_node_put(node);
 	return err;
 }
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net v1 0/3] tipc: buffer reassignment fixes
  2017-08-24 14:31 [PATCH net v1 0/3] tipc: buffer reassignment fixes Parthasarathy Bhuvaragan
                   ` (2 preceding siblings ...)
  2017-08-24 14:31 ` [PATCH net v1 3/3] tipc: context imbalance at node read unlock Parthasarathy Bhuvaragan
@ 2017-08-25  4:54 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-08-25  4:54 UTC (permalink / raw)
  To: parthasarathy.bhuvaragan; +Cc: jon.maloy, netdev, tipc-discussion, ying.xue

From: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Date: Thu, 24 Aug 2017 16:31:21 +0200

> This series contains fixes for buffer reassignments and a context
> imbalance.

Series applied, thanks.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-25  4:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-24 14:31 [PATCH net v1 0/3] tipc: buffer reassignment fixes Parthasarathy Bhuvaragan
2017-08-24 14:31 ` [PATCH net v1 1/3] tipc: perform skb_linearize() before parsing the inner header Parthasarathy Bhuvaragan
2017-08-24 14:31 ` [PATCH net v1 2/3] tipc: reassign pointers after skb reallocation / linearization Parthasarathy Bhuvaragan
2017-08-24 14:31 ` [PATCH net v1 3/3] tipc: context imbalance at node read unlock Parthasarathy Bhuvaragan
2017-08-25  4:54 ` [PATCH net v1 0/3] tipc: buffer reassignment fixes David Miller

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).