public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Subject: linux-next: manual merge of the bluetooth tree with the origin tree
Date: Thu, 12 Mar 2026 13:14:04 +0000	[thread overview]
Message-ID: <abK8HK9tHmE7JC_6@sirena.org.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 5920 bytes --]

Hi all,

Today's linux-next merge of the bluetooth tree got a conflict in:

  net/bluetooth/l2cap_core.c

between commit:

  c28d2bff70444 ("Bluetooth: L2CAP: Fix result of L2CAP_ECRED_CONN_RSP when MTU is too short")

from the origin tree and commit:

  19ba9c64840d4 ("Bluetooth: L2CAP: Fix accepting multiple L2CAP_ECRED_CONN_REQ")

from the bluetooth tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --combined net/bluetooth/l2cap_core.c
index ad98db9632fd2,475fdf1908cb8..0000000000000
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@@ -442,7 -442,7 +442,7 @@@ struct l2cap_chan *l2cap_chan_create(vo
  {
  	struct l2cap_chan *chan;
  
 -	chan = kzalloc(sizeof(*chan), GFP_ATOMIC);
 +	chan = kzalloc_obj(*chan, GFP_ATOMIC);
  	if (!chan)
  		return NULL;
  
@@@ -1678,17 -1678,15 +1678,15 @@@ static void l2cap_info_timeout(struct w
  
  int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user)
  {
- 	struct hci_dev *hdev = conn->hcon->hdev;
  	int ret;
  
  	/* We need to check whether l2cap_conn is registered. If it is not, we
- 	 * must not register the l2cap_user. l2cap_conn_del() is unregisters
- 	 * l2cap_conn objects, but doesn't provide its own locking. Instead, it
- 	 * relies on the parent hci_conn object to be locked. This itself relies
- 	 * on the hci_dev object to be locked. So we must lock the hci device
- 	 * here, too. */
+ 	 * must not register the l2cap_user. l2cap_conn_del() unregisters
+ 	 * l2cap_conn objects under conn->lock, and we use the same lock here
+ 	 * to protect access to conn->users and conn->hchan.
+ 	 */
  
- 	hci_dev_lock(hdev);
+ 	mutex_lock(&conn->lock);
  
  	if (!list_empty(&user->list)) {
  		ret = -EINVAL;
@@@ -1709,16 -1707,14 +1707,14 @@@
  	ret = 0;
  
  out_unlock:
- 	hci_dev_unlock(hdev);
+ 	mutex_unlock(&conn->lock);
  	return ret;
  }
  EXPORT_SYMBOL(l2cap_register_user);
  
  void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user)
  {
- 	struct hci_dev *hdev = conn->hcon->hdev;
- 
- 	hci_dev_lock(hdev);
+ 	mutex_lock(&conn->lock);
  
  	if (list_empty(&user->list))
  		goto out_unlock;
@@@ -1727,7 -1723,7 +1723,7 @@@
  	user->remove(conn, user);
  
  out_unlock:
- 	hci_dev_unlock(hdev);
+ 	mutex_unlock(&conn->lock);
  }
  EXPORT_SYMBOL(l2cap_unregister_user);
  
@@@ -4616,7 -4612,8 +4612,8 @@@ static inline int l2cap_information_rsp
  
  	switch (type) {
  	case L2CAP_IT_FEAT_MASK:
- 		conn->feat_mask = get_unaligned_le32(rsp->data);
+ 		if (cmd_len >= sizeof(*rsp) + sizeof(u32))
+ 			conn->feat_mask = get_unaligned_le32(rsp->data);
  
  		if (conn->feat_mask & L2CAP_FEAT_FIXED_CHAN) {
  			struct l2cap_info_req req;
@@@ -4635,7 -4632,8 +4632,8 @@@
  		break;
  
  	case L2CAP_IT_FIXED_CHAN:
- 		conn->remote_fixed_chan = rsp->data[0];
+ 		if (cmd_len >= sizeof(*rsp) + sizeof(rsp->data[0]))
+ 			conn->remote_fixed_chan = rsp->data[0];
  		conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
  		conn->info_ident = 0;
  
@@@ -5059,7 -5057,7 +5057,7 @@@ static inline int l2cap_ecred_conn_req(
  	u16 mtu, mps;
  	__le16 psm;
  	u8 result, rsp_len = 0;
- 	int i, num_scid;
+ 	int i, num_scid = 0;
  	bool defer = false;
  
  	if (!enable_ecred)
@@@ -5072,6 -5070,14 +5070,14 @@@
  		goto response;
  	}
  
+ 	/* Check if there are no pending channels with the same ident */
+ 	__l2cap_chan_list_id(conn, cmd->ident, l2cap_ecred_list_defer,
+ 			     &num_scid);
+ 	if (num_scid) {
+ 		result = L2CAP_CR_LE_INVALID_PARAMS;
+ 		goto response;
+ 	}
+ 
  	cmd_len -= sizeof(*req);
  	num_scid = cmd_len / sizeof(u16);
  
@@@ -5424,7 -5430,7 +5430,7 @@@ static inline int l2cap_ecred_reconf_rs
  					 u8 *data)
  {
  	struct l2cap_chan *chan, *tmp;
- 	struct l2cap_ecred_conn_rsp *rsp = (void *) data;
+ 	struct l2cap_ecred_reconf_rsp *rsp = (void *)data;
  	u16 result;
  
  	if (cmd_len < sizeof(*rsp))
@@@ -5432,7 -5438,7 +5438,7 @@@
  
  	result = __le16_to_cpu(rsp->result);
  
- 	BT_DBG("result 0x%4.4x", rsp->result);
+ 	BT_DBG("result 0x%4.4x", result);
  
  	if (!result)
  		return 0;
@@@ -6662,8 -6668,17 +6668,17 @@@ static int l2cap_ecred_data_rcv(struct 
  		return -ENOBUFS;
  	}
  
- 	if (chan->imtu < skb->len) {
- 		BT_ERR("Too big LE L2CAP PDU");
+ 	if (skb->len > chan->imtu) {
+ 		BT_ERR("Too big LE L2CAP PDU: len %u > %u", skb->len,
+ 		       chan->imtu);
+ 		l2cap_send_disconn_req(chan, ECONNRESET);
+ 		return -ENOBUFS;
+ 	}
+ 
+ 	if (skb->len > chan->mps) {
+ 		BT_ERR("Too big LE L2CAP MPS: len %u > %u", skb->len,
+ 		       chan->mps);
+ 		l2cap_send_disconn_req(chan, ECONNRESET);
  		return -ENOBUFS;
  	}
  
@@@ -6689,7 -6704,9 +6704,9 @@@
  		       sdu_len, skb->len, chan->imtu);
  
  		if (sdu_len > chan->imtu) {
- 			BT_ERR("Too big LE L2CAP SDU length received");
+ 			BT_ERR("Too big LE L2CAP SDU length: len %u > %u",
+ 			       skb->len, sdu_len);
+ 			l2cap_send_disconn_req(chan, ECONNRESET);
  			err = -EMSGSIZE;
  			goto failed;
  		}
@@@ -6725,6 -6742,7 +6742,7 @@@
  
  	if (chan->sdu->len + skb->len > chan->sdu_len) {
  		BT_ERR("Too much LE L2CAP data received");
+ 		l2cap_send_disconn_req(chan, ECONNRESET);
  		err = -EINVAL;
  		goto failed;
  	}
@@@ -6947,7 -6965,7 +6965,7 @@@ static struct l2cap_conn *l2cap_conn_ad
  	if (!hchan)
  		return NULL;
  
 -	conn = kzalloc(sizeof(*conn), GFP_KERNEL);
 +	conn = kzalloc_obj(*conn);
  	if (!conn) {
  		hci_chan_del(hchan);
  		return NULL;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2026-03-12 13:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 13:14 Mark Brown [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-09-22  9:23 linux-next: manual merge of the bluetooth tree with the origin tree Mark Brown
2025-09-17 11:34 Mark Brown
2023-04-17 14:36 broonie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abK8HK9tHmE7JC_6@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox