diff mbox series

Bluetooth: cmtp: fix possible panic when cmtp_init_sockets() fails

Message ID 20211022034417.766659-1-wanghai38@huawei.com (mailing list archive)
State Superseded
Headers show
Series Bluetooth: cmtp: fix possible panic when cmtp_init_sockets() fails | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 468, Passed: 0 (0.0%), Failed: 0, Not Run: 468
tedd_an/testrunnerrfcomm-tester success Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Wang Hai Oct. 22, 2021, 3:44 a.m. UTC
I got a kernel BUG report when doing fault injection test:

------------[ cut here ]------------
kernel BUG at lib/list_debug.c:45!
...
RIP: 0010:__list_del_entry_valid.cold+0x12/0x4d
...
Call Trace:
 proto_unregister+0x83/0x220
 cmtp_cleanup_sockets+0x37/0x40 [cmtp]
 cmtp_exit+0xe/0x1f [cmtp]
 do_syscall_64+0x35/0xb0
 entry_SYSCALL_64_after_hwframe+0x44/0xae

If cmtp_init_sockets() in cmtp_init() fails, cmtp_init() still returns
success. This will cause a kernel bug when accessing uncreated ctmp
related data when the module exits.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
 net/bluetooth/cmtp/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

bluez.test.bot@gmail.com Oct. 22, 2021, 4:08 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=568307

---Test result---

Test Summary:
CheckPatch                    PASS      1.58 seconds
GitLint                       PASS      0.94 seconds
BuildKernel                   PASS      610.72 seconds
TestRunner: Setup             PASS      448.16 seconds
TestRunner: l2cap-tester      PASS      9.65 seconds
TestRunner: bnep-tester       PASS      5.30 seconds
TestRunner: mgmt-tester       PASS      52.35 seconds
TestRunner: rfcomm-tester     PASS      6.93 seconds
TestRunner: sco-tester        PASS      7.09 seconds
TestRunner: smp-tester        PASS      6.74 seconds
TestRunner: userchan-tester   PASS      5.51 seconds



---
Regards,
Linux Bluetooth
Marcel Holtmann Oct. 22, 2021, 4:48 a.m. UTC | #2
Hi Wang,

> I got a kernel BUG report when doing fault injection test:
> 
> ------------[ cut here ]------------
> kernel BUG at lib/list_debug.c:45!
> ...
> RIP: 0010:__list_del_entry_valid.cold+0x12/0x4d
> ...
> Call Trace:
> proto_unregister+0x83/0x220
> cmtp_cleanup_sockets+0x37/0x40 [cmtp]
> cmtp_exit+0xe/0x1f [cmtp]
> do_syscall_64+0x35/0xb0
> entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> If cmtp_init_sockets() in cmtp_init() fails, cmtp_init() still returns
> success. This will cause a kernel bug when accessing uncreated ctmp
> related data when the module exits.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
> net/bluetooth/cmtp/core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
> index 0a2d78e811cf..ccf48f50afdf 100644
> --- a/net/bluetooth/cmtp/core.c
> +++ b/net/bluetooth/cmtp/core.c
> @@ -499,11 +499,13 @@ int cmtp_get_conninfo(struct cmtp_conninfo *ci)
> 
> static int __init cmtp_init(void)
> {
> +	int err;
> +
> 	BT_INFO("CMTP (CAPI Emulation) ver %s", VERSION);
> 
> -	cmtp_init_sockets();
> +	err = cmtp_init_sockets();
> 
> -	return 0;
> +	return err;
> }

just do return cmtp_init_sockets();

Regards

Marcel
Wang Hai Oct. 22, 2021, 8:43 a.m. UTC | #3
在 2021/10/22 12:48, Marcel Holtmann 写道:
> Hi Wang,
>
>> I got a kernel BUG report when doing fault injection test:
>>
>> ------------[ cut here ]------------
>> kernel BUG at lib/list_debug.c:45!
>> ...
>> RIP: 0010:__list_del_entry_valid.cold+0x12/0x4d
>> ...
>> Call Trace:
>> proto_unregister+0x83/0x220
>> cmtp_cleanup_sockets+0x37/0x40 [cmtp]
>> cmtp_exit+0xe/0x1f [cmtp]
>> do_syscall_64+0x35/0xb0
>> entry_SYSCALL_64_after_hwframe+0x44/0xae
>>
>> If cmtp_init_sockets() in cmtp_init() fails, cmtp_init() still returns
>> success. This will cause a kernel bug when accessing uncreated ctmp
>> related data when the module exits.
>>
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Wang Hai <wanghai38@huawei.com>
>> ---
>> net/bluetooth/cmtp/core.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
>> index 0a2d78e811cf..ccf48f50afdf 100644
>> --- a/net/bluetooth/cmtp/core.c
>> +++ b/net/bluetooth/cmtp/core.c
>> @@ -499,11 +499,13 @@ int cmtp_get_conninfo(struct cmtp_conninfo *ci)
>>
>> static int __init cmtp_init(void)
>> {
>> +	int err;
>> +
>> 	BT_INFO("CMTP (CAPI Emulation) ver %s", VERSION);
>>
>> -	cmtp_init_sockets();
>> +	err = cmtp_init_sockets();
>>
>> -	return 0;
>> +	return err;
>> }
> just do return cmtp_init_sockets();
>
> Regards
>
> Marcel
Ok, I will send v2
> .
>
diff mbox series

Patch

diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 0a2d78e811cf..ccf48f50afdf 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -499,11 +499,13 @@  int cmtp_get_conninfo(struct cmtp_conninfo *ci)
 
 static int __init cmtp_init(void)
 {
+	int err;
+
 	BT_INFO("CMTP (CAPI Emulation) ver %s", VERSION);
 
-	cmtp_init_sockets();
+	err = cmtp_init_sockets();
 
-	return 0;
+	return err;
 }
 
 static void __exit cmtp_exit(void)