diff options
author | Jon Paul Maloy <jon.maloy@ericsson.com> | 2017-02-23 11:10:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-24 11:42:54 -0500 |
commit | 681a55d71799b575f46fe94121728cf67460d1c3 (patch) | |
tree | 571316773e7f47c7bdb2d86fa599c93de0d76eaa /net/tipc | |
parent | fbf68229ffe7e12c78b55714de08c1c34a2e2047 (diff) |
tipc: move premature initilalization of stack variables
In the function tipc_rcv() we initialize a couple of stack variables
from the message header before that same header has been validated.
In rare cases when the arriving header is non-linar, the validation
function itself may linearize the buffer by calling skb_may_pull(),
while the wrongly initialized stack fields are not updated accordingly.
We fix this in this commit.
Reported-by: Matthew Wong <mwong@sonusnet.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/node.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c index e9295fa3a554..4512e83652b1 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -1505,19 +1505,21 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b) | |||
1505 | { | 1505 | { |
1506 | struct sk_buff_head xmitq; | 1506 | struct sk_buff_head xmitq; |
1507 | struct tipc_node *n; | 1507 | struct tipc_node *n; |
1508 | struct tipc_msg *hdr = buf_msg(skb); | 1508 | struct tipc_msg *hdr; |
1509 | int usr = msg_user(hdr); | ||
1510 | int bearer_id = b->identity; | 1509 | int bearer_id = b->identity; |
1511 | struct tipc_link_entry *le; | 1510 | struct tipc_link_entry *le; |
1512 | u16 bc_ack = msg_bcast_ack(hdr); | ||
1513 | u32 self = tipc_own_addr(net); | 1511 | u32 self = tipc_own_addr(net); |
1514 | int rc = 0; | 1512 | int usr, rc = 0; |
1513 | u16 bc_ack; | ||
1515 | 1514 | ||
1516 | __skb_queue_head_init(&xmitq); | 1515 | __skb_queue_head_init(&xmitq); |
1517 | 1516 | ||
1518 | /* Ensure message is well-formed */ | 1517 | /* Ensure message is well-formed before touching the header */ |
1519 | if (unlikely(!tipc_msg_validate(skb))) | 1518 | if (unlikely(!tipc_msg_validate(skb))) |
1520 | goto discard; | 1519 | goto discard; |
1520 | hdr = buf_msg(skb); | ||
1521 | usr = msg_user(hdr); | ||
1522 | bc_ack = msg_bcast_ack(hdr); | ||
1521 | 1523 | ||
1522 | /* Handle arrival of discovery or broadcast packet */ | 1524 | /* Handle arrival of discovery or broadcast packet */ |
1523 | if (unlikely(msg_non_seq(hdr))) { | 1525 | if (unlikely(msg_non_seq(hdr))) { |