Skip to contentSkip to conversation

Properly mask header fields

TIPC Max Krasnyansky 2 participants 6 messages Feb 16, 2007 – Feb 21, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

TIPC code is a bit inconsistent in masking out upper bits of various message fields when packing them into the headers. For the most part things seem to be ok but we happened to hit a corner case in our labs when broadcast counter reached certain value (don't remember exact details) and was messing up status bits in the header. At which point the link was busted and required a reset to bring it back up. It's much safer to apply proper mask in the function that does the actual packing rather than doing it all over the place, and missing a few ;-).

---
 net/tipc/msg.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/tipc/msg.h +1 -1
index 6699aaf..4e681c8 100644
@@ -72,7 +72,7 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w,
 				u32 pos, u32 mask, u32 val)
 {
 	u32 word = msg_word(m,w) & ~(mask << pos);
-	msg_set_word(m, w, (word |= (val << pos)));
+	msg_set_word(m, w, (word |= ((val & mask) << pos)));
 }
 
 /* 
Signature · 1 line
1.4.4.2
#1 lore raw

[TIPC] Missing null check in the socket code.

Fixes an oops in the non-blocking mode.

---
 net/tipc/socket.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/tipc/socket.c +4 -0
index 2a6a5a6..767f791 100644
@@ -862,6 +862,10 @@ restart:
 	/* Get access to first message in receive queue */
 
 	buf = skb_peek(&sock->sk->sk_receive_queue);
+	if (NULL == buf) {
+		res = -EAGAIN;
+		goto exit;
+	}
 	msg = buf_msg(buf);
 	sz = msg_data_sz(msg);
 	err = msg_errcode(msg);
Signature · 1 line
1.4.4.2
#2 lore raw

Re: [TIPC] Missing null check in the socket code.

Quoted 12 lines · Max Krasnyansky

Fixes an oops in the non-blocking mode.

---
 net/tipc/socket.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/tipc/socket.c +0 -0
index 2a6a5a6..767f791 100644

net/tipc/socket.c restart: · line 871

Quoted 10 lines
net/tipc/socket.c +4 -0
@@ -862,6 +862,10 @@ restart:
 	/* Get access to first message in receive queue */
 
 	buf = skb_peek(&sock->sk->sk_receive_queue);
+	if (NULL == buf) {
+		res = -EAGAIN;
+		goto exit;
+	}
 	msg = buf_msg(buf);
 	sz = msg_data_sz(msg);
 	err = msg_errcode(msg);

Just a reminder. Please apply.

Thanx
Max

#3 lore raw

RE: [TIPC] Missing null check in the socket code.

Acknowledged. We'll deliver it along with
some other patches ASAP.

///jon

-----Original Message-----
From: Max Krasnyansky [mailto:[email protected]]
Sent: Tue 2/20/2007 1:48 PM
To: [email protected]
Cc: [email protected]; Jon Maloy (QB/EMC); [email protected]
Subject: Re: [TIPC] Missing null check in the socket code.

Quoted 12 lines · Max Krasnyansky

Fixes an oops in the non-blocking mode.

---
 net/tipc/socket.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/tipc/socket.c +0 -0
index 2a6a5a6..767f791 100644

net/tipc/socket.c restart: · line 871

Quoted 10 lines
net/tipc/socket.c +4 -0
@@ -862,6 +862,10 @@ restart:
 	/* Get access to first message in receive queue */
 
 	buf = skb_peek(&sock->sk->sk_receive_queue);
+	if (NULL == buf) {
+		res = -EAGAIN;
+		goto exit;
+	}
 	msg = buf_msg(buf);
 	sz = msg_data_sz(msg);
 	err = msg_errcode(msg);

Just a reminder. Please apply.

Thanx
Max

#4 lore raw

Re: [TIPC] Missing null check in the socket code.

Hi Jon,

Quoted 1 line

Acknowledged. We'll deliver it along with some other patches ASAP.

Thanx

Did you get a chance to look at my other patch for the header packing ?

Max

#5 lore raw
In reply to Max Krasnyansky

Dave, Alan, Jon,

Quoted 20 lines · Max Krasnyansky

TIPC code is a bit inconsistent in masking out upper bits of various message fields when packing them into the headers. For the most part things seem to be ok but we happened to hit a corner case in our labs when broadcast counter reached certain value (don't remember exact details) and was messing up status bits in the header. At which point the link was busted and required a reset to bring it back up. It's much safer to apply proper mask in the function that does the actual packing rather than doing it all over the place, and missing a few ;-).

---
 net/tipc/msg.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/tipc/msg.h +0 -0
index 6699aaf..4e681c8 100644

net/tipc/msg.h static inline void msg_set_bits(struct tipc_msg *m, u32 w, · line 78

Quoted 8 lines
net/tipc/msg.h +1 -1
@@ -72,7 +72,7 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w,
 				u32 pos, u32 mask, u32 val)
 {
 	u32 word = msg_word(m,w) & ~(mask << pos);
-	msg_set_word(m, w, (word |= (val << pos)));
+	msg_set_word(m, w, (word |= ((val & mask) << pos)));
 }
 
 /* 

Just making sure that this does not get lost in the blizzard of other patches :). Please apply.

Thanx
Max