linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf()
@ 2021-11-16  8:51 Zijun Hu
  2021-11-16 13:54 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Zijun Hu @ 2021-11-16  8:51 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-kernel, linux-bluetooth, linux-arm-msm, c-hbandi, hemantg,
	rjliao, zijuhu, Zijun Hu

From: Zijun Hu <quic_zijuhu@quicinc.com>

it is erroneous to calculate padding by subtracting length of type
indication from skb->len, it will cause data analysis error for
alignment which is greater than 1, so fixed by adding length of type
indication with skb->len.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/bluetooth/hci_h4.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 4b3b14a34794..1d0cdf023243 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -252,7 +252,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
 			}
 
 			if (!dlen) {
-				hu->padding = (skb->len - 1) % alignment;
+				hu->padding = (skb->len + 1) % alignment;
 				hu->padding = (alignment - hu->padding) % alignment;
 
 				/* No more data, complete frame */
@@ -260,7 +260,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
 				skb = NULL;
 			}
 		} else {
-			hu->padding = (skb->len - 1) % alignment;
+			hu->padding = (skb->len + 1) % alignment;
 			hu->padding = (alignment - hu->padding) % alignment;
 
 			/* Complete frame */
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf()
  2021-11-16  8:51 [PATCH v2] Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf() Zijun Hu
@ 2021-11-16 13:54 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2021-11-16 13:54 UTC (permalink / raw)
  To: Zijun Hu
  Cc: Johan Hedberg, Luiz Augusto von Dentz, Linux Kernel Mailing List,
	linux-bluetooth, linux-arm-msm, c-hbandi, hemantg, rjliao,
	Zijun Hu

Hi Zijun,

> it is erroneous to calculate padding by subtracting length of type
> indication from skb->len, it will cause data analysis error for
> alignment which is greater than 1, so fixed by adding length of type
> indication with skb->len.
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> drivers/bluetooth/hci_h4.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-16 13:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16  8:51 [PATCH v2] Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf() Zijun Hu
2021-11-16 13:54 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).