netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 4/4] net: wwan: iosm: fix incorrect skb length
@ 2022-11-22 17:47 m.chetan.kumar
  2022-11-23  4:46 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: m.chetan.kumar @ 2022-11-22 17:47 UTC (permalink / raw)
  To: netdev
  Cc: kuba, davem, johannes, ryazanov.s.a, loic.poulain,
	m.chetan.kumar, linuxwwan, edumazet, pabeni

From: M Chetan Kumar <m.chetan.kumar@linux.intel.com>

skb passed to network layer contains incorrect length.

In mux aggregation protocol, the datagram block received
from device contains block signature, packet & datagram
header. The right skb len to be calculated by subracting
datagram pad len from datagram length.

Whereas in mux lite protocol, the skb contains single
datagram so skb len is calculated by subtracting the
packet offset from datagram header.

Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support")
Signed-off-by: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
---
 drivers/net/wwan/iosm/iosm_ipc_mux_codec.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
index 738420bd14af..16f319dd2804 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
@@ -365,7 +365,8 @@ static void ipc_mux_dl_cmd_decode(struct iosm_mux *ipc_mux, struct sk_buff *skb)
 /* Pass the DL packet to the netif layer. */
 static int ipc_mux_net_receive(struct iosm_mux *ipc_mux, int if_id,
 			       struct iosm_wwan *wwan, u32 offset,
-			       u8 service_class, struct sk_buff *skb)
+			       u8 service_class, struct sk_buff *skb,
+			       u32 pkt_len)
 {
 	struct sk_buff *dest_skb = skb_clone(skb, GFP_ATOMIC);

@@ -373,7 +374,7 @@ static int ipc_mux_net_receive(struct iosm_mux *ipc_mux, int if_id,
 		return -ENOMEM;

 	skb_pull(dest_skb, offset);
-	skb_set_tail_pointer(dest_skb, dest_skb->len);
+	skb_trim(dest_skb, pkt_len);
 	/* Pass the packet to the netif layer. */
 	dest_skb->priority = service_class;

@@ -473,7 +474,8 @@ static void ipc_mux_dl_adgh_decode(struct iosm_mux *ipc_mux,

 	/* Pass the packet to the netif layer */
 	rc = ipc_mux_net_receive(ipc_mux, if_id, wwan, packet_offset,
-				 adgh->service_class, skb);
+				 adgh->service_class, skb,
+				 adgh->length - packet_offset);
 	if (rc) {
 		dev_err(ipc_mux->dev, "mux adgh decoding error");
 		return;
@@ -565,8 +567,9 @@ static int mux_dl_process_dg(struct iosm_mux *ipc_mux, struct mux_adbh *adbh,
 			/* Pass the packet to the netif layer. */
 			rc = ipc_mux_net_receive(ipc_mux, if_id, ipc_mux->wwan,
 						 packet_offset,
-						 dg->service_class,
-						 skb);
+						 dg->service_class, skb,
+						 dg->datagram_length -
+						 dl_head_pad_len);
 			if (rc)
 				goto dg_error;
 		}
--
2.34.1


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

* Re: [PATCH net 4/4] net: wwan: iosm: fix incorrect skb length
  2022-11-22 17:47 [PATCH net 4/4] net: wwan: iosm: fix incorrect skb length m.chetan.kumar
@ 2022-11-23  4:46 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2022-11-23  4:46 UTC (permalink / raw)
  To: m.chetan.kumar
  Cc: netdev, davem, johannes, ryazanov.s.a, loic.poulain, linuxwwan,
	edumazet, pabeni

On Tue, 22 Nov 2022 23:17:46 +0530 m.chetan.kumar@linux.intel.com wrote:
> From: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
> 
> skb passed to network layer contains incorrect length.
> 
> In mux aggregation protocol, the datagram block received
> from device contains block signature, packet & datagram
> header. The right skb len to be calculated by subracting
> datagram pad len from datagram length.
> 
> Whereas in mux lite protocol, the skb contains single
> datagram so skb len is calculated by subtracting the
> packet offset from datagram header.

Sparse says:

drivers/net/wwan/iosm/iosm_ipc_mux_codec.c:478:38: warning: restricted __le16 degrades to integer
drivers/net/wwan/iosm/iosm_ipc_mux_codec.c:571:52: warning: restricted __le16 degrades to integer

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

end of thread, other threads:[~2022-11-23  4:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 17:47 [PATCH net 4/4] net: wwan: iosm: fix incorrect skb length m.chetan.kumar
2022-11-23  4:46 ` Jakub Kicinski

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).