netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: send proper config param to unknown config request
@ 2020-09-24 15:45 Archie Pusaka
  2020-09-25 16:11 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Archie Pusaka @ 2020-09-24 15:45 UTC (permalink / raw)
  To: linux-bluetooth, Marcel Holtmann
  Cc: CrosBT Upstreaming, Archie Pusaka, Alain Michaud,
	David S. Miller, Jakub Kicinski, Johan Hedberg, linux-kernel,
	netdev

From: Archie Pusaka <apusaka@chromium.org>

When receiving an L2CAP_CONFIGURATION_REQ with an unknown config
type, currently we will reply with L2CAP_CONFIGURATION_RSP with
a list of unknown types as the config param. However, this is not
a correct format of config param.

As described in the bluetooth spec v5.2, Vol 3, Part A, Sec 5,
the config param should consists of type, length, and optionally
data.

This patch copies the length and data from the received
L2CAP_CONFIGURATION_REQ and also appends them to the config param
of the corresponding L2CAP_CONFIGURATION_RSP to match the format
of the config param according to the spec.

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>

---

 net/bluetooth/l2cap_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ade83e224567..2f3ddd4f0f4c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3627,7 +3627,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
 			if (hint)
 				break;
 			result = L2CAP_CONF_UNKNOWN;
-			*((u8 *) ptr++) = type;
+			l2cap_add_conf_opt(&ptr, type, olen, val,
+					   endptr - ptr);
 			break;
 		}
 	}
@@ -3658,7 +3659,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
 	}
 
 done:
-	if (chan->mode != rfc.mode) {
+	if (chan->mode != rfc.mode && result != L2CAP_CONF_UNKNOWN) {
 		result = L2CAP_CONF_UNACCEPT;
 		rfc.mode = chan->mode;
 
-- 
2.28.0.681.g6f77f65b4e-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] Bluetooth: send proper config param to unknown config request
  2020-09-24 15:45 [PATCH v1] Bluetooth: send proper config param to unknown config request Archie Pusaka
@ 2020-09-25 16:11 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2020-09-25 16:11 UTC (permalink / raw)
  To: Archie Pusaka
  Cc: linux-bluetooth, CrosBT Upstreaming, Archie Pusaka,
	Alain Michaud, David S. Miller, Jakub Kicinski, Johan Hedberg,
	open list, netdev

Hi Archie,

> When receiving an L2CAP_CONFIGURATION_REQ with an unknown config
> type, currently we will reply with L2CAP_CONFIGURATION_RSP with
> a list of unknown types as the config param. However, this is not
> a correct format of config param.
> 
> As described in the bluetooth spec v5.2, Vol 3, Part A, Sec 5,
> the config param should consists of type, length, and optionally
> data.
> 
> This patch copies the length and data from the received
> L2CAP_CONFIGURATION_REQ and also appends them to the config param
> of the corresponding L2CAP_CONFIGURATION_RSP to match the format
> of the config param according to the spec.

any chance you could add btmon traces to the commit message to show the wrong behavior?

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-25 16:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 15:45 [PATCH v1] Bluetooth: send proper config param to unknown config request Archie Pusaka
2020-09-25 16:11 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).