Message ID | 20240405204827.3458726-1-luiz.dentz@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [v2,1/5] Bluetooth: SCO: Fix not validating setsockopt user input | expand |
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=841947 ---Test result--- Test Summary: CheckPatch FAIL 3.11 seconds GitLint PASS 1.10 seconds SubjectPrefix PASS 0.36 seconds BuildKernel PASS 29.78 seconds CheckAllWarning PASS 32.66 seconds CheckSparse WARNING 38.45 seconds CheckSmatch FAIL 36.08 seconds BuildKernel32 PASS 29.07 seconds TestRunnerSetup PASS 521.30 seconds TestRunner_l2cap-tester PASS 18.21 seconds TestRunner_iso-tester FAIL 36.63 seconds TestRunner_bnep-tester PASS 5.08 seconds TestRunner_mgmt-tester PASS 107.86 seconds TestRunner_rfcomm-tester PASS 7.25 seconds TestRunner_sco-tester PASS 14.88 seconds TestRunner_ioctl-tester PASS 9.16 seconds TestRunner_mesh-tester FAIL 5.92 seconds TestRunner_smp-tester PASS 6.64 seconds TestRunner_userchan-tester PASS 4.76 seconds IncrementalBuild PASS 47.21 seconds Details ############################## Test: CheckPatch - FAIL Desc: Run checkpatch.pl script Output: [v2,1/5] Bluetooth: SCO: Fix not validating setsockopt user input WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #107: Reported-by: syzbot <syzkaller@googlegroups.com> Signed-off-by: Eric Dumazet <edumazet@google.com> total: 0 errors, 1 warnings, 0 checks, 72 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13619406.patch has style problems, please review. NOTE: Ignored message types: UNKNOWN_COMMIT_ID NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. [v2,2/5] Bluetooth: RFCOMM: Fix not validating setsockopt user input WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #112: Reported-by: syzbot <syzkaller@googlegroups.com> Signed-off-by: Eric Dumazet <edumazet@google.com> total: 0 errors, 1 warnings, 0 checks, 40 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13619407.patch has style problems, please review. NOTE: Ignored message types: UNKNOWN_COMMIT_ID NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. ############################## Test: CheckSparse - WARNING Desc: Run sparse tool with linux kernel Output: net/bluetooth/sco.c: note: in included file:./include/net/bluetooth/hci_core.h:150:35: warning: array of flexible structures ############################## Test: CheckSmatch - FAIL Desc: Run smatch tool with source Output: Segmentation fault (core dumped) make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 139 make[4]: *** Deleting file 'net/bluetooth/hci_core.o' make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: net] Error 2 make[2]: *** Waiting for unfinished jobs.... Segmentation fault (core dumped) make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bcm203x.o] Error 139 make[4]: *** Deleting file 'drivers/bluetooth/bcm203x.o' make[4]: *** Waiting for unfinished jobs.... Segmentation fault (core dumped) make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bpa10x.o] Error 139 make[4]: *** Deleting file 'drivers/bluetooth/bpa10x.o' make[3]: *** [scripts/Makefile.build:485: drivers/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: drivers] Error 2 make[1]: *** [/github/workspace/src/src/Makefile:1919: .] Error 2 make: *** [Makefile:240: __sub-make] Error 2 ############################## Test: TestRunner_iso-tester - FAIL Desc: Run iso-tester with test-runner Output: Total: 121, Passed: 119 (98.3%), Failed: 2, Not Run: 0 Failed Test Cases ISO Connect Suspend - Success Failed 4.187 seconds ISO Connect2 Suspend - Success Failed 6.220 seconds ############################## Test: TestRunner_mesh-tester - FAIL Desc: Run mesh-tester with test-runner Output: Total: 10, Passed: 9 (90.0%), Failed: 1, Not Run: 0 Failed Test Cases Mesh - Send cancel - 2 Failed 0.096 seconds --- Regards, Linux Bluetooth
Hello: This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Fri, 5 Apr 2024 16:48:23 -0400 you wrote: > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > syzbot reported sco_sock_setsockopt() is copying data without > checking user input length. > > BUG: KASAN: slab-out-of-bounds in copy_from_sockptr_offset > include/linux/sockptr.h:49 [inline] > BUG: KASAN: slab-out-of-bounds in copy_from_sockptr > include/linux/sockptr.h:55 [inline] > BUG: KASAN: slab-out-of-bounds in sco_sock_setsockopt+0xc0b/0xf90 > net/bluetooth/sco.c:893 > Read of size 4 at addr ffff88805f7b15a3 by task syz-executor.5/12578 > > [...] Here is the summary with links: - [v2,1/5] Bluetooth: SCO: Fix not validating setsockopt user input https://git.kernel.org/bluetooth/bluetooth-next/c/82f018d9ae0e - [v2,2/5] Bluetooth: RFCOMM: Fix not validating setsockopt user input https://git.kernel.org/bluetooth/bluetooth-next/c/05dcb647b289 - [v2,3/5] Bluetooth: L2CAP: Fix not validating setsockopt user input https://git.kernel.org/bluetooth/bluetooth-next/c/d10a75a2b47c - [v2,4/5] Bluetooth: ISO: Fix not validating setsockopt user input https://git.kernel.org/bluetooth/bluetooth-next/c/723cf24d84c1 - [v2,5/5] Bluetooth: hci_sock: Fix not validating setsockopt user input https://git.kernel.org/bluetooth/bluetooth-next/c/f3ab06000608 You are awesome, thank you!
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 1ada4f85e982..431c907155e7 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -586,6 +586,15 @@ static inline struct sk_buff *bt_skb_sendmmsg(struct sock *sk, return skb; } +static inline int bt_copy_from_sockptr(void *dst, size_t dst_size, + sockptr_t src, size_t src_size) +{ + if (dst_size > src_size) + return -EINVAL; + + return copy_from_sockptr(dst, src, dst_size); +} + int bt_to_errno(u16 code); __u8 bt_status(int err); diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 99c2b713d826..cc72f05d4f0e 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -839,7 +839,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; - int len, err = 0; + int err = 0; struct bt_voice voice; u32 opt; struct bt_codecs *codecs; @@ -858,10 +858,9 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (copy_from_sockptr(&opt, optval, sizeof(u32))) { - err = -EFAULT; + err = bt_copy_from_sockptr(&opt, sizeof(opt), optval, optlen); + if (err) break; - } if (opt) set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); @@ -878,11 +877,10 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, voice.setting = sco_pi(sk)->setting; - len = min_t(unsigned int, sizeof(voice), optlen); - if (copy_from_sockptr(&voice, optval, len)) { - err = -EFAULT; + err = bt_copy_from_sockptr(&voice, sizeof(voice), optval, + optlen); + if (err) break; - } /* Explicitly check for these values */ if (voice.setting != BT_VOICE_TRANSPARENT && @@ -905,10 +903,9 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, break; case BT_PKT_STATUS: - if (copy_from_sockptr(&opt, optval, sizeof(u32))) { - err = -EFAULT; + err = bt_copy_from_sockptr(&opt, sizeof(opt), optval, optlen); + if (err) break; - } if (opt) set_bit(BT_SK_PKT_STATUS, &bt_sk(sk)->flags); @@ -949,9 +946,9 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (copy_from_sockptr(buffer, optval, optlen)) { + err = bt_copy_from_sockptr(buffer, optlen, optval, optlen); + if (err) { hci_dev_put(hdev); - err = -EFAULT; break; }