Skip to content

Commit 0fdcaa5

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
2 parents 47e4df9 + f161dd4 commit 0fdcaa5

File tree

8 files changed

+47
-20
lines changed

8 files changed

+47
-20
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ struct hci_conn_params {
464464
HCI_AUTO_CONN_ALWAYS,
465465
HCI_AUTO_CONN_LINK_LOSS,
466466
} auto_connect;
467+
468+
struct hci_conn *conn;
467469
};
468470

469471
extern struct list_head hci_dev_list;

include/net/netns/ieee802154_6lowpan.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct netns_sysctl_lowpan {
1616
struct netns_ieee802154_lowpan {
1717
struct netns_sysctl_lowpan sysctl;
1818
struct netns_frags frags;
19-
int max_dsize;
2019
};
2120

2221
#endif

net/bluetooth/hci_conn.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,14 @@ EXPORT_SYMBOL(hci_get_route);
589589
void hci_le_conn_failed(struct hci_conn *conn, u8 status)
590590
{
591591
struct hci_dev *hdev = conn->hdev;
592+
struct hci_conn_params *params;
593+
594+
params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst,
595+
conn->dst_type);
596+
if (params && params->conn) {
597+
hci_conn_drop(params->conn);
598+
params->conn = NULL;
599+
}
592600

593601
conn->state = BT_CLOSED;
594602

net/bluetooth/hci_core.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,8 +2536,13 @@ static void hci_pend_le_actions_clear(struct hci_dev *hdev)
25362536
{
25372537
struct hci_conn_params *p;
25382538

2539-
list_for_each_entry(p, &hdev->le_conn_params, list)
2539+
list_for_each_entry(p, &hdev->le_conn_params, list) {
2540+
if (p->conn) {
2541+
hci_conn_drop(p->conn);
2542+
p->conn = NULL;
2543+
}
25402544
list_del_init(&p->action);
2545+
}
25412546

25422547
BT_DBG("All LE pending actions cleared");
25432548
}
@@ -2578,8 +2583,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
25782583

25792584
hci_dev_lock(hdev);
25802585
hci_inquiry_cache_flush(hdev);
2581-
hci_conn_hash_flush(hdev);
25822586
hci_pend_le_actions_clear(hdev);
2587+
hci_conn_hash_flush(hdev);
25832588
hci_dev_unlock(hdev);
25842589

25852590
hci_notify(hdev, HCI_DEV_DOWN);
@@ -3727,6 +3732,9 @@ void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
37273732
if (!params)
37283733
return;
37293734

3735+
if (params->conn)
3736+
hci_conn_drop(params->conn);
3737+
37303738
list_del(&params->action);
37313739
list_del(&params->list);
37323740
kfree(params);
@@ -3757,6 +3765,8 @@ void hci_conn_params_clear_all(struct hci_dev *hdev)
37573765
struct hci_conn_params *params, *tmp;
37583766

37593767
list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) {
3768+
if (params->conn)
3769+
hci_conn_drop(params->conn);
37603770
list_del(&params->action);
37613771
list_del(&params->list);
37623772
kfree(params);

net/bluetooth/hci_event.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4221,8 +4221,13 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
42214221
hci_proto_connect_cfm(conn, ev->status);
42224222

42234223
params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
4224-
if (params)
4224+
if (params) {
42254225
list_del_init(&params->action);
4226+
if (params->conn) {
4227+
hci_conn_drop(params->conn);
4228+
params->conn = NULL;
4229+
}
4230+
}
42264231

42274232
unlock:
42284233
hci_update_background_scan(hdev);
@@ -4304,8 +4309,16 @@ static void check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr,
43044309

43054310
conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
43064311
HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER);
4307-
if (!IS_ERR(conn))
4312+
if (!IS_ERR(conn)) {
4313+
/* Store the pointer since we don't really have any
4314+
* other owner of the object besides the params that
4315+
* triggered it. This way we can abort the connection if
4316+
* the parameters get removed and keep the reference
4317+
* count consistent once the connection is established.
4318+
*/
4319+
params->conn = conn;
43084320
return;
4321+
}
43094322

43104323
switch (PTR_ERR(conn)) {
43114324
case -EBUSY:

net/ieee802154/6lowpan_rtnl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ lowpan_alloc_frag(struct sk_buff *skb, int size,
246246
return ERR_PTR(-rc);
247247
}
248248
} else {
249-
frag = ERR_PTR(ENOMEM);
249+
frag = ERR_PTR(-ENOMEM);
250250
}
251251

252252
return frag;
@@ -437,7 +437,7 @@ static void lowpan_setup(struct net_device *dev)
437437
/* Frame Control + Sequence Number + Address fields + Security Header */
438438
dev->hard_header_len = 2 + 1 + 20 + 14;
439439
dev->needed_tailroom = 2; /* FCS */
440-
dev->mtu = 1281;
440+
dev->mtu = IPV6_MIN_MTU;
441441
dev->tx_queue_len = 0;
442442
dev->flags = IFF_BROADCAST | IFF_MULTICAST;
443443
dev->watchdog_timeo = 0;

net/ieee802154/reassembly.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,6 @@ int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type)
355355
struct net *net = dev_net(skb->dev);
356356
struct lowpan_frag_info *frag_info = lowpan_cb(skb);
357357
struct ieee802154_addr source, dest;
358-
struct netns_ieee802154_lowpan *ieee802154_lowpan =
359-
net_ieee802154_lowpan(net);
360358
int err;
361359

362360
source = mac_cb(skb)->source;
@@ -366,8 +364,10 @@ int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type)
366364
if (err < 0)
367365
goto err;
368366

369-
if (frag_info->d_size > ieee802154_lowpan->max_dsize)
367+
if (frag_info->d_size > IPV6_MIN_MTU) {
368+
net_warn_ratelimited("lowpan_frag_rcv: datagram size exceeds MTU\n");
370369
goto err;
370+
}
371371

372372
fq = fq_find(net, frag_info, &source, &dest);
373373
if (fq != NULL) {
@@ -415,13 +415,6 @@ static struct ctl_table lowpan_frags_ns_ctl_table[] = {
415415
.mode = 0644,
416416
.proc_handler = proc_dointvec_jiffies,
417417
},
418-
{
419-
.procname = "6lowpanfrag_max_datagram_size",
420-
.data = &init_net.ieee802154_lowpan.max_dsize,
421-
.maxlen = sizeof(int),
422-
.mode = 0644,
423-
.proc_handler = proc_dointvec
424-
},
425418
{ }
426419
};
427420

@@ -458,7 +451,6 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
458451
table[1].data = &ieee802154_lowpan->frags.low_thresh;
459452
table[1].extra2 = &ieee802154_lowpan->frags.high_thresh;
460453
table[2].data = &ieee802154_lowpan->frags.timeout;
461-
table[3].data = &ieee802154_lowpan->max_dsize;
462454

463455
/* Don't export sysctls to unprivileged users */
464456
if (net->user_ns != &init_user_ns)
@@ -533,7 +525,6 @@ static int __net_init lowpan_frags_init_net(struct net *net)
533525
ieee802154_lowpan->frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
534526
ieee802154_lowpan->frags.low_thresh = IPV6_FRAG_LOW_THRESH;
535527
ieee802154_lowpan->frags.timeout = IPV6_FRAG_TIMEOUT;
536-
ieee802154_lowpan->max_dsize = 0xFFFF;
537528

538529
inet_frags_init_net(&ieee802154_lowpan->frags);
539530

net/mac802154/wpan.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,10 @@ mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb,
462462
skb->pkt_type = PACKET_OTHERHOST;
463463
break;
464464
default:
465-
break;
465+
spin_unlock_bh(&sdata->mib_lock);
466+
pr_debug("invalid dest mode\n");
467+
kfree_skb(skb);
468+
return NET_RX_DROP;
466469
}
467470

468471
spin_unlock_bh(&sdata->mib_lock);
@@ -573,6 +576,7 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
573576
ret = mac802154_parse_frame_start(skb, &hdr);
574577
if (ret) {
575578
pr_debug("got invalid frame\n");
579+
kfree_skb(skb);
576580
return;
577581
}
578582

0 commit comments

Comments
 (0)