Skip to contentSkip to conversation

bluetooth: unregister correct BTPROTO for CMTP

PATCH michenyuan 1 participant 1 message May 10, 2023

Subsystems (3)
lore
Share & tools
lore

michenyuan

author
#0 lore raw

Hi, this bug seems to have not been fixed, it still exists in the current main branch in linux kernel. Is there anything blocking the bug fixing?

--------

Quoted 42 lines · Luiz Augusto von Dentz

Hi,

Quoted 39 lines · Simon Horman
Quoted 12 lines · Chenyuan Mi

On error unregister BTPROTO_CMTP to match the registration earlier in the same code-path. Without this change BTPROTO_HIDP is incorrectly unregistered.

This bug does not appear to cause serious security problem.

The function 'bt_sock_unregister' takes its parameter as an index and NULLs the corresponding element of 'bt_proto' which is an array of pointers. When 'bt_proto' dereferences each element, it would check whether the element is empty or not. Therefore, the problem of null pointer deference does not occur.

Quoted 5 lines

Found by inspection.

Fixes 8c8de589cedd ("Bluetooth: Added /proc/net/cmtp via

bt_procfs_init()")

Quoted 17 lines
---
 net/bluetooth/cmtp/sock.c | 2 +-
 1 files changed, 1 insertions(+), 1 deletion(-)
net/bluetooth/cmtp/sock.c +1 -1
index 96d49d9fae96..cf4370055ce2 100644
@@ -250,7 +250,7 @@ int cmtp_init_sockets(void)
      err = bt_procfs_init(&init_net, "cmtp", &cmtp_sk_list, NULL);
      if (err < 0) {
              BT_ERR("Failed to create CMTP proc file");
-             bt_sock_unregister(BTPROTO_HIDP);
+             bt_sock_unregister(BTPROTO_CMTP);
              goto error;
      }
 
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

--
2.25.1

This one does not appear on pw for some reason, not sure if that was because of subject or what, so please resubmit it, don't forget to add Reviewed-by you got in this thread.

Yes, curious.

Perhaps it is due to the 'net-next' in the subject prefix.
I previously advised adding that, which I now see was in correct as this is a Bluetooth patch. Sorry about that.