Skip to content

Commit bf32fec

Browse files
committed
openvswitch: Add length check when retrieving TCP flags.
When collecting TCP flags we check that the IP header indicates that a TCP header is present but not that the packet is actually long enough to contain the header. This adds a check to prevent reading off the end of the packet. In practice, this is only likely to result in reading of bad data and not a crash due to the presence of struct skb_shared_info at the end of the packet. Signed-off-by: Jesse Gross <jesse@nicira.com>
1 parent dd775ae commit bf32fec

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎net/openvswitch/flow.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ void ovs_flow_used(struct sw_flow *flow, struct sk_buff *skb)
183183
u8 tcp_flags = 0;
184184

185185
if (flow->key.eth.type == htons(ETH_P_IP) &&
186-
flow->key.ip.proto == IPPROTO_TCP) {
186+
flow->key.ip.proto == IPPROTO_TCP &&
187+
likely(skb->len >= skb_transport_offset(skb) + sizeof(struct tcphdr))) {
187188
u8 *tcp = (u8 *)tcp_hdr(skb);
188189
tcp_flags = *(tcp + TCP_FLAGS_OFFSET) & TCP_FLAG_MASK;
189190
}

0 commit comments

Comments
 (0)