diff options
| author | Marcel Holtmann <marcel@holtmann.org> | 2004-04-05 15:00:19 +0200 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2004-04-05 15:00:19 +0200 |
| commit | 7b00dc76e18522fecc6c133fd9b46bbf2a5a065f (patch) | |
| tree | 0b769dcc2791a132d80c3e82a7f6953d1d869126 | |
| parent | e2a786731a0ceb852224bf83c008eed45e7b196d (diff) | |
[Bluetooth] Fix broken HCI security filter
The HCI security filter is broken on 64-bit architectures and this patch
restores the version from 2.4, which is working perfect on 32-bit and
64-bit machines.
| -rw-r--r-- | include/net/bluetooth/hci_core.h | 6 | ||||
| -rw-r--r-- | net/bluetooth/hci_sock.c | 13 |
2 files changed, 12 insertions, 7 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index faddd520a69c..eed980fb1f1a 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -515,9 +515,9 @@ struct hci_pinfo { #define HCI_SFLT_MAX_OGF 5 struct hci_sec_filter { - unsigned long type_mask; - unsigned long event_mask[2]; - unsigned long ocf_mask[HCI_SFLT_MAX_OGF + 1][4]; + __u32 type_mask; + __u32 event_mask[2]; + __u32 ocf_mask[HCI_SFLT_MAX_OGF + 1][4]; }; /* ----- HCI requests ----- */ diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 886163ece9ac..ceee7074613c 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -61,6 +61,11 @@ /* ----- HCI socket interface ----- */ +static inline int hci_test_bit(int nr, void *addr) +{ + return *((__u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31)); +} + /* Security filter */ static struct hci_sec_filter hci_sec_filter = { /* Packet types */ @@ -115,8 +120,8 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) if (skb->pkt_type == HCI_EVENT_PKT) { register int evt = (*(__u8 *)skb->data & HCI_FLT_EVENT_BITS); - - if (!test_bit(evt, flt->event_mask)) + + if (!hci_test_bit(evt, &flt->event_mask)) continue; if (flt->opcode && ((evt == HCI_EV_CMD_COMPLETE && @@ -399,8 +404,8 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, u16 ogf = hci_opcode_ogf(opcode); u16 ocf = hci_opcode_ocf(opcode); - if (((ogf > HCI_SFLT_MAX_OGF) || - !test_bit(ocf & HCI_FLT_OCF_BITS, hci_sec_filter.ocf_mask[ogf])) && + if (((ogf > HCI_SFLT_MAX_OGF) || + !hci_test_bit(ocf & HCI_FLT_OCF_BITS, &hci_sec_filter.ocf_mask[ogf])) && !capable(CAP_NET_RAW)) { err = -EPERM; goto drop; |
