Commit 2486f6e
Bastien Nocera
Bluetooth: Improve setsockopt() handling of malformed user input
JIRA: https://issues.redhat.com/browse/RHEL-74483
commit 3e643e4
Author: Michal Luczaj <mhal@rbox.co>
Date: Tue Nov 19 14:31:40 2024 +0100
Bluetooth: Improve setsockopt() handling of malformed user input
The bt_copy_from_sockptr() return value is being misinterpreted by most
users: a non-zero result is mistakenly assumed to represent an error code,
but actually indicates the number of bytes that could not be copied.
Remove bt_copy_from_sockptr() and adapt callers to use
copy_safe_from_sockptr().
For sco_sock_setsockopt() (case BT_CODEC) use copy_struct_from_sockptr() to
scrub parts of uninitialized buffer.
Opportunistically, rename `len` to `optlen` in hci_sock_setsockopt_old()
and hci_sock_setsockopt().
Fixes: 51eda36 ("Bluetooth: SCO: Fix not validating setsockopt user input")
Fixes: a97de7b ("Bluetooth: RFCOMM: Fix not validating setsockopt user input")
Fixes: 4f39512 ("Bluetooth: L2CAP: Fix not validating setsockopt user input")
Fixes: 9e8742c ("Bluetooth: ISO: Fix not validating setsockopt user input")
Fixes: b218606 ("Bluetooth: hci_sock: Fix not validating setsockopt user input")
Reviewed-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Reviewed-by: David Wei <dw@davidwei.uk>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Bastien Nocera <bnocera@redhat.com>1 parent 5fd497e commit 2486f6e
File tree
6 files changed
+33
-40
lines changed- include/net/bluetooth
- net/bluetooth
- rfcomm
6 files changed
+33
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | 593 | | |
603 | 594 | | |
604 | 595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1938 | 1938 | | |
1939 | 1939 | | |
1940 | 1940 | | |
1941 | | - | |
| 1941 | + | |
1942 | 1942 | | |
1943 | 1943 | | |
1944 | 1944 | | |
| |||
1955 | 1955 | | |
1956 | 1956 | | |
1957 | 1957 | | |
1958 | | - | |
| 1958 | + | |
1959 | 1959 | | |
1960 | 1960 | | |
1961 | 1961 | | |
| |||
1966 | 1966 | | |
1967 | 1967 | | |
1968 | 1968 | | |
1969 | | - | |
| 1969 | + | |
1970 | 1970 | | |
1971 | 1971 | | |
1972 | 1972 | | |
| |||
1986 | 1986 | | |
1987 | 1987 | | |
1988 | 1988 | | |
1989 | | - | |
| 1989 | + | |
1990 | 1990 | | |
1991 | 1991 | | |
1992 | 1992 | | |
| |||
2017 | 2017 | | |
2018 | 2018 | | |
2019 | 2019 | | |
2020 | | - | |
| 2020 | + | |
2021 | 2021 | | |
2022 | 2022 | | |
2023 | 2023 | | |
| |||
2027 | 2027 | | |
2028 | 2028 | | |
2029 | 2029 | | |
2030 | | - | |
| 2030 | + | |
2031 | 2031 | | |
2032 | 2032 | | |
2033 | 2033 | | |
| |||
2047 | 2047 | | |
2048 | 2048 | | |
2049 | 2049 | | |
2050 | | - | |
| 2050 | + | |
2051 | 2051 | | |
2052 | 2052 | | |
2053 | 2053 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
1578 | | - | |
| 1578 | + | |
1579 | 1579 | | |
1580 | 1580 | | |
1581 | 1581 | | |
| |||
1586 | 1586 | | |
1587 | 1587 | | |
1588 | 1588 | | |
1589 | | - | |
| 1589 | + | |
1590 | 1590 | | |
1591 | 1591 | | |
1592 | 1592 | | |
| |||
1605 | 1605 | | |
1606 | 1606 | | |
1607 | 1607 | | |
1608 | | - | |
| 1608 | + | |
1609 | 1609 | | |
1610 | 1610 | | |
1611 | 1611 | | |
| |||
1626 | 1626 | | |
1627 | 1627 | | |
1628 | 1628 | | |
1629 | | - | |
1630 | | - | |
| 1629 | + | |
| 1630 | + | |
1631 | 1631 | | |
1632 | 1632 | | |
1633 | 1633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
758 | | - | |
| 758 | + | |
| 759 | + | |
759 | 760 | | |
760 | 761 | | |
761 | 762 | | |
| |||
800 | 801 | | |
801 | 802 | | |
802 | 803 | | |
803 | | - | |
| 804 | + | |
804 | 805 | | |
805 | 806 | | |
806 | 807 | | |
| |||
909 | 910 | | |
910 | 911 | | |
911 | 912 | | |
912 | | - | |
| 913 | + | |
913 | 914 | | |
914 | 915 | | |
915 | 916 | | |
| |||
956 | 957 | | |
957 | 958 | | |
958 | 959 | | |
959 | | - | |
| 960 | + | |
960 | 961 | | |
961 | 962 | | |
962 | 963 | | |
| |||
970 | 971 | | |
971 | 972 | | |
972 | 973 | | |
973 | | - | |
| 974 | + | |
974 | 975 | | |
975 | 976 | | |
976 | 977 | | |
| |||
1004 | 1005 | | |
1005 | 1006 | | |
1006 | 1007 | | |
1007 | | - | |
| 1008 | + | |
1008 | 1009 | | |
1009 | 1010 | | |
1010 | 1011 | | |
| |||
1015 | 1016 | | |
1016 | 1017 | | |
1017 | 1018 | | |
1018 | | - | |
| 1019 | + | |
1019 | 1020 | | |
1020 | 1021 | | |
1021 | 1022 | | |
| |||
1046 | 1047 | | |
1047 | 1048 | | |
1048 | 1049 | | |
1049 | | - | |
| 1050 | + | |
1050 | 1051 | | |
1051 | 1052 | | |
1052 | 1053 | | |
| |||
1076 | 1077 | | |
1077 | 1078 | | |
1078 | 1079 | | |
1079 | | - | |
| 1080 | + | |
| 1081 | + | |
1080 | 1082 | | |
1081 | 1083 | | |
1082 | 1084 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
632 | | - | |
633 | | - | |
| 632 | + | |
| 633 | + | |
634 | 634 | | |
635 | | - | |
636 | 635 | | |
637 | 636 | | |
638 | 637 | | |
| |||
685 | 684 | | |
686 | 685 | | |
687 | 686 | | |
688 | | - | |
| 687 | + | |
689 | 688 | | |
690 | 689 | | |
691 | 690 | | |
| |||
703 | 702 | | |
704 | 703 | | |
705 | 704 | | |
706 | | - | |
| 705 | + | |
707 | 706 | | |
708 | 707 | | |
709 | 708 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
896 | 896 | | |
897 | 897 | | |
898 | 898 | | |
899 | | - | |
| 899 | + | |
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
| |||
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | | - | |
919 | | - | |
| 918 | + | |
| 919 | + | |
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
| |||
941 | 941 | | |
942 | 942 | | |
943 | 943 | | |
944 | | - | |
| 944 | + | |
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
| |||
984 | 984 | | |
985 | 985 | | |
986 | 986 | | |
987 | | - | |
| 987 | + | |
| 988 | + | |
988 | 989 | | |
989 | 990 | | |
990 | 991 | | |
| |||
0 commit comments