cmtp: fix argument error
Subsystems (3)
Thank you for your suggestion.
This bug may not cause serious security problem. 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.
This bug is observed by manually code review.
----------
Quoted 1 line · Chenyuan Mi
Fix this issue by using
BTPROTO_CMTPas argument instead ofBTPROTO_HIDP.
Thanks for your patch. Some things you may want to consider:
* I think it would be good to describe what the effect of this problem is, if it can be observed. And if not, say so. I think it would also be useful to state how the problem was found. F.e. using a tool, or by inspection.
* As this is described as a fix, it should probably have a fixes tag. I think it would be:
Quoted 4 lines
Signed-off-by Chenyuan Mi <[email protected]>--- net/bluetooth/cmtp/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Code change looks good.
Quoted 15 lines
net/bluetooth/cmtp/sock.c +1
-2@@ -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; } --2.25.1
Quoted 5 lines · michenyuan
Thank you for your suggestion.
This bug may not cause serious security problem. 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.This bug is observed by manually code review.
Thanks, could I suggest that you post a v2 that looks a bit like this:
Subject: Re: [PATCH v2 net-next] bluetooth: unregister correct BTPROTO for CMTP
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.
Found by inspection.
...
Quoted 21 lines
Quoted 3 lines
--- net/bluetooth/cmtp/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Code change looks good.
Quoted 15 lines
net/bluetooth/cmtp/sock.c +1
-2@@ -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; } --2.25.1