From: "Lee, Chun-Yi" joeyli.kernel@gmail.com
commit 9c33663af9ad115f90c076a1828129a3fbadea98 upstream.
This patch adds code to check HCI_UART_PROTO_READY flag before accessing hci_uart->proto. It fixes the race condition in hci_uart_tty_ioctl() between HCIUARTSETPROTO and HCIUARTGETPROTO. This issue bug found by Yu Hao and Weiteng Chen:
BUG: general protection fault in hci_uart_tty_ioctl [1]
The information of C reproducer can also reference the link [2]
Reported-by: Yu Hao yhao016@ucr.edu Closes: https://lore.kernel.org/all/CA+UBctC3p49aTgzbVgkSZ2+TQcqq4fPDO7yZitFT5uBPDeC... [1] Reported-by: Weiteng Chen wchen130@ucr.edu Closes: https://lore.kernel.org/lkml/CA+UBctDPEvHdkHMwD340=n02rh+jNRJNNQ5LBZNA+Wm4Ke... [2] Signed-off-by: "Lee, Chun-Yi" jlee@suse.com Signed-off-by: Luiz Augusto von Dentz luiz.von.dentz@intel.com [Harshit: bp to stable kernels] Signed-off-by: Harshit Mogalapalli harshit.m.mogalapalli@oracle.com --- This is backport of a fix for CVE-2023-31083, it applies cleanly to all stable trees and I have build tested this.
drivers/bluetooth/hci_ldisc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 865112e96ff9..c1feebd9e3a0 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -770,7 +770,8 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd, break;
case HCIUARTGETPROTO: - if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) + if (test_bit(HCI_UART_PROTO_SET, &hu->flags) && + test_bit(HCI_UART_PROTO_READY, &hu->flags)) err = hu->proto->id; else err = -EUNATCH;
Hi,
Ping for this backport.
Thanks, Harshit
On 02/08/24 20:41, Harshit Mogalapalli wrote:
From: "Lee, Chun-Yi" joeyli.kernel@gmail.com
commit 9c33663af9ad115f90c076a1828129a3fbadea98 upstream.
This patch adds code to check HCI_UART_PROTO_READY flag before accessing hci_uart->proto. It fixes the race condition in hci_uart_tty_ioctl() between HCIUARTSETPROTO and HCIUARTGETPROTO. This issue bug found by Yu Hao and Weiteng Chen:
BUG: general protection fault in hci_uart_tty_ioctl [1]
The information of C reproducer can also reference the link [2]
Reported-by: Yu Hao yhao016@ucr.edu Closes: https://lore.kernel.org/all/CA+UBctC3p49aTgzbVgkSZ2+TQcqq4fPDO7yZitFT5uBPDeC... [1] Reported-by: Weiteng Chen wchen130@ucr.edu Closes: https://lore.kernel.org/lkml/CA+UBctDPEvHdkHMwD340=n02rh+jNRJNNQ5LBZNA+Wm4Ke... [2] Signed-off-by: "Lee, Chun-Yi" jlee@suse.com Signed-off-by: Luiz Augusto von Dentz luiz.von.dentz@intel.com [Harshit: bp to stable kernels] Signed-off-by: Harshit Mogalapalli harshit.m.mogalapalli@oracle.com
This is backport of a fix for CVE-2023-31083, it applies cleanly to all stable trees and I have build tested this.
drivers/bluetooth/hci_ldisc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 865112e96ff9..c1feebd9e3a0 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -770,7 +770,8 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd, break; case HCIUARTGETPROTO:
if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
if (test_bit(HCI_UART_PROTO_SET, &hu->flags) &&
else err = -EUNATCH;test_bit(HCI_UART_PROTO_READY, &hu->flags)) err = hu->proto->id;
linux-stable-mirror@lists.linaro.org