diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2010-05-11 21:02:00 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-07-21 13:39:07 -0400 |
commit | 260000896750690b774d4343294ae5cbff1423e5 (patch) | |
tree | 696f1a945371bb3bd363dd8741eec86b22920e66 /net/bluetooth | |
parent | 45d65c46acc39945219eeb3752367ee80ed82799 (diff) |
Bluetooth: Check packet FCS earlier
This way, if FCS is enabled and the packet is corrupted, we just drop it
without read it len, which could be corrupted.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 6094870d5d2a..8c9f577dd46d 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -4166,25 +4166,25 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
4166 | skb_pull(skb, 2); | 4166 | skb_pull(skb, 2); |
4167 | len = skb->len; | 4167 | len = skb->len; |
4168 | 4168 | ||
4169 | /* | ||
4170 | * We can just drop the corrupted I-frame here. | ||
4171 | * Receiver will miss it and start proper recovery | ||
4172 | * procedures and ask retransmission. | ||
4173 | */ | ||
4174 | if (l2cap_check_fcs(pi, skb)) | ||
4175 | goto drop; | ||
4176 | |||
4169 | if (__is_sar_start(control) && __is_iframe(control)) | 4177 | if (__is_sar_start(control) && __is_iframe(control)) |
4170 | len -= 2; | 4178 | len -= 2; |
4171 | 4179 | ||
4172 | if (pi->fcs == L2CAP_FCS_CRC16) | 4180 | if (pi->fcs == L2CAP_FCS_CRC16) |
4173 | len -= 2; | 4181 | len -= 2; |
4174 | 4182 | ||
4175 | /* | ||
4176 | * We can just drop the corrupted I-frame here. | ||
4177 | * Receiver will miss it and start proper recovery | ||
4178 | * procedures and ask retransmission. | ||
4179 | */ | ||
4180 | if (len > pi->mps) { | 4183 | if (len > pi->mps) { |
4181 | l2cap_send_disconn_req(pi->conn, sk); | 4184 | l2cap_send_disconn_req(pi->conn, sk); |
4182 | goto drop; | 4185 | goto drop; |
4183 | } | 4186 | } |
4184 | 4187 | ||
4185 | if (l2cap_check_fcs(pi, skb)) | ||
4186 | goto drop; | ||
4187 | |||
4188 | req_seq = __get_reqseq(control); | 4188 | req_seq = __get_reqseq(control); |
4189 | req_seq_offset = (req_seq - pi->expected_ack_seq) % 64; | 4189 | req_seq_offset = (req_seq - pi->expected_ack_seq) % 64; |
4190 | if (req_seq_offset < 0) | 4190 | if (req_seq_offset < 0) |
@@ -4224,6 +4224,9 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
4224 | skb_pull(skb, 2); | 4224 | skb_pull(skb, 2); |
4225 | len = skb->len; | 4225 | len = skb->len; |
4226 | 4226 | ||
4227 | if (l2cap_check_fcs(pi, skb)) | ||
4228 | goto drop; | ||
4229 | |||
4227 | if (__is_sar_start(control)) | 4230 | if (__is_sar_start(control)) |
4228 | len -= 2; | 4231 | len -= 2; |
4229 | 4232 | ||
@@ -4233,9 +4236,6 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
4233 | if (len > pi->mps || len < 0 || __is_sframe(control)) | 4236 | if (len > pi->mps || len < 0 || __is_sframe(control)) |
4234 | goto drop; | 4237 | goto drop; |
4235 | 4238 | ||
4236 | if (l2cap_check_fcs(pi, skb)) | ||
4237 | goto drop; | ||
4238 | |||
4239 | tx_seq = __get_txseq(control); | 4239 | tx_seq = __get_txseq(control); |
4240 | 4240 | ||
4241 | if (pi->expected_tx_seq == tx_seq) | 4241 | if (pi->expected_tx_seq == tx_seq) |