* [PATCH] slip: Check if rstate is initialized before uncompressing
@ 2018-04-09 8:53 Tejaswi Tanikella
2018-04-09 15:04 ` David Miller
0 siblings, 1 reply; 8+ messages in thread
From: Tejaswi Tanikella @ 2018-04-09 8:53 UTC (permalink / raw)
To: netdev
On receiving a packet the state index points to the rstate which must be
used to fill up IP and TCP headers. But if the state index points to a
rstate which is unitialized, i.e. filled with zeros, it gets stuck in an
infinite loop inside ip_fast_csum trying to compute the ip checsum of a
header with zero length.
89.666953: <2> [<ffffff9dd3e94d38>] slhc_uncompress+0x464/0x468
89.666965: <2> [<ffffff9dd3e87d88>] ppp_receive_nonmp_frame+0x3b4/0x65c
89.666978: <2> [<ffffff9dd3e89dd4>] ppp_receive_frame+0x64/0x7e0
89.666991: <2> [<ffffff9dd3e8a708>] ppp_input+0x104/0x198
89.667005: <2> [<ffffff9dd3e93868>] pppopns_recv_core+0x238/0x370
89.667027: <2> [<ffffff9dd4428fc8>] __sk_receive_skb+0xdc/0x250
89.667040: <2> [<ffffff9dd3e939e4>] pppopns_recv+0x44/0x60
89.667053: <2> [<ffffff9dd4426848>] __sock_queue_rcv_skb+0x16c/0x24c
89.667065: <2> [<ffffff9dd4426954>] sock_queue_rcv_skb+0x2c/0x38
89.667085: <2> [<ffffff9dd44f7358>] raw_rcv+0x124/0x154
89.667098: <2> [<ffffff9dd44f7568>] raw_local_deliver+0x1e0/0x22c
89.667117: <2> [<ffffff9dd44c8ba0>] ip_local_deliver_finish+0x70/0x24c
89.667131: <2> [<ffffff9dd44c92f4>] ip_local_deliver+0x100/0x10c
./scripts/faddr2line vmlinux slhc_uncompress+0x464/0x468 output:
ip_fast_csum at arch/arm64/include/asm/checksum.h:40
(inlined by) slhc_uncompress at drivers/net/slip/slhc.c:615
Adding a variable to indicate if the current rstate is initialized. If
such a packet arrives, move to toss state.
Signed-off-by: Tejaswi Tanikella <tejaswit@codeaurora.org>
---
drivers/net/slip/slhc.c | 5 +++++
include/net/slhc_vj.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
index 5782733..e710b0b 100644
--- a/drivers/net/slip/slhc.c
+++ b/drivers/net/slip/slhc.c
@@ -509,6 +509,10 @@ struct slcompress *
if(x < 0 || x > comp->rslot_limit)
goto bad;
+ /* Check if the cstate is initialized */
+ if(!comp->rstate[x].initialized)
+ goto bad;
+
comp->flags &=~ SLF_TOSS;
comp->recv_current = x;
} else {
@@ -673,6 +677,7 @@ struct slcompress *
if (cs->cs_tcp.doff > 5)
memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr), (cs->cs_tcp.doff - 5) * 4);
cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
+ cs->initialized = 1;
/* Put headers back on packet
* Neither header checksum is recalculated
*/
diff --git a/include/net/slhc_vj.h b/include/net/slhc_vj.h
index 8716d59..d673365 100644
--- a/include/net/slhc_vj.h
+++ b/include/net/slhc_vj.h
@@ -127,6 +127,7 @@
*/
struct cstate {
byte_t cs_this; /* connection id number (xmit) */
+ byte_t initialized; /* non-zero if initialized */
struct cstate *next; /* next in ring (xmit) */
struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */
struct tcphdr cs_tcp;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] slip: Check if rstate is initialized before uncompressing
2018-04-09 8:53 [PATCH] slip: Check if rstate is initialized before uncompressing Tejaswi Tanikella
@ 2018-04-09 15:04 ` David Miller
2018-04-10 5:58 ` tejaswit
0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2018-04-09 15:04 UTC (permalink / raw)
To: tejaswit; +Cc: netdev
From: Tejaswi Tanikella <tejaswit@codeaurora.org>
Date: Mon, 9 Apr 2018 14:23:49 +0530
> @@ -673,6 +677,7 @@ struct slcompress *
> if (cs->cs_tcp.doff > 5)
> memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr), (cs->cs_tcp.doff - 5) * 4);
> cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
> + cs->initialized = 1;
> /* Put headers back on packet
...
> struct cstate {
> byte_t cs_this; /* connection id number (xmit) */
> + byte_t initialized; /* non-zero if initialized */
Please use 'bool' and true/false for 'initialized'.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slip: Check if rstate is initialized before uncompressing
2018-04-09 15:04 ` David Miller
@ 2018-04-10 5:58 ` tejaswit
2018-04-10 9:48 ` Guillaume Nault
2018-04-10 14:03 ` David Miller
0 siblings, 2 replies; 8+ messages in thread
From: tejaswit @ 2018-04-10 5:58 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 627 bytes --]
On 2018-04-09 20:34, David Miller wrote:
> From: Tejaswi Tanikella <tejaswit@codeaurora.org>
> Date: Mon, 9 Apr 2018 14:23:49 +0530
>
>> @@ -673,6 +677,7 @@ struct slcompress *
>> if (cs->cs_tcp.doff > 5)
>> memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr),
>> (cs->cs_tcp.doff - 5) * 4);
>> cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
>> + cs->initialized = 1;
>> /* Put headers back on packet
> ...
>> struct cstate {
>> byte_t cs_this; /* connection id number (xmit) */
>> + byte_t initialized; /* non-zero if initialized */
>
> Please use 'bool' and true/false for 'initialized'.
Made the changes.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-slip-Check-if-rstate-is-initialized-before-uncompres.patch --]
[-- Type: text/x-diff; name=0001-slip-Check-if-rstate-is-initialized-before-uncompres.patch, Size: 3032 bytes --]
From b04441041034a5e044705d3c5a2cc338dd4bfc3a Mon Sep 17 00:00:00 2001
From: Tejaswi Tanikella <tejaswit@codeaurora.org>
Date: Thu, 29 Mar 2018 14:46:41 +0530
Subject: [PATCH] slip: Check if rstate is initialized before uncompressing
On receiving a packet the state index points to the rstate which must be
used to fill up IP and TCP headers. But if the state index points to a
rstate which is unitialized, i.e. filled with zeros, it gets stuck in an
infinite loop inside ip_fast_csum trying to compute the ip checsum of a
header with zero length.
89.666953: <2> [<ffffff9dd3e94d38>] slhc_uncompress+0x464/0x468
89.666965: <2> [<ffffff9dd3e87d88>] ppp_receive_nonmp_frame+0x3b4/0x65c
89.666978: <2> [<ffffff9dd3e89dd4>] ppp_receive_frame+0x64/0x7e0
89.666991: <2> [<ffffff9dd3e8a708>] ppp_input+0x104/0x198
89.667005: <2> [<ffffff9dd3e93868>] pppopns_recv_core+0x238/0x370
89.667027: <2> [<ffffff9dd4428fc8>] __sk_receive_skb+0xdc/0x250
89.667040: <2> [<ffffff9dd3e939e4>] pppopns_recv+0x44/0x60
89.667053: <2> [<ffffff9dd4426848>] __sock_queue_rcv_skb+0x16c/0x24c
89.667065: <2> [<ffffff9dd4426954>] sock_queue_rcv_skb+0x2c/0x38
89.667085: <2> [<ffffff9dd44f7358>] raw_rcv+0x124/0x154
89.667098: <2> [<ffffff9dd44f7568>] raw_local_deliver+0x1e0/0x22c
89.667117: <2> [<ffffff9dd44c8ba0>] ip_local_deliver_finish+0x70/0x24c
89.667131: <2> [<ffffff9dd44c92f4>] ip_local_deliver+0x100/0x10c
./scripts/faddr2line vmlinux slhc_uncompress+0x464/0x468 output:
ip_fast_csum at arch/arm64/include/asm/checksum.h:40
(inlined by) slhc_uncompress at drivers/net/slip/slhc.c:615
Adding a variable to indicate if the current rstate is initialized. If
such a packet arrives, move to toss state.
Signed-off-by: Tejaswi Tanikella <tejaswit@codeaurora.org>
---
drivers/net/slip/slhc.c | 5 +++++
include/net/slhc_vj.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
index 5782733..f4e93f5 100644
--- a/drivers/net/slip/slhc.c
+++ b/drivers/net/slip/slhc.c
@@ -509,6 +509,10 @@ struct slcompress *
if(x < 0 || x > comp->rslot_limit)
goto bad;
+ /* Check if the cstate is initialized */
+ if (!comp->rstate[x].initialized)
+ goto bad;
+
comp->flags &=~ SLF_TOSS;
comp->recv_current = x;
} else {
@@ -673,6 +677,7 @@ struct slcompress *
if (cs->cs_tcp.doff > 5)
memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr), (cs->cs_tcp.doff - 5) * 4);
cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
+ cs->initialized = true;
/* Put headers back on packet
* Neither header checksum is recalculated
*/
diff --git a/include/net/slhc_vj.h b/include/net/slhc_vj.h
index 8716d59..8fcf890 100644
--- a/include/net/slhc_vj.h
+++ b/include/net/slhc_vj.h
@@ -127,6 +127,7 @@
*/
struct cstate {
byte_t cs_this; /* connection id number (xmit) */
+ bool initialized; /* true if initialized */
struct cstate *next; /* next in ring (xmit) */
struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */
struct tcphdr cs_tcp;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] slip: Check if rstate is initialized before uncompressing
2018-04-10 5:58 ` tejaswit
@ 2018-04-10 9:48 ` Guillaume Nault
2018-04-10 14:03 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: Guillaume Nault @ 2018-04-10 9:48 UTC (permalink / raw)
To: tejaswit; +Cc: David Miller, netdev
On Tue, Apr 10, 2018 at 11:28:10AM +0530, tejaswit@codeaurora.org wrote:
> On 2018-04-09 20:34, David Miller wrote:
> > From: Tejaswi Tanikella <tejaswit@codeaurora.org>
> > Date: Mon, 9 Apr 2018 14:23:49 +0530
> >
> > > @@ -673,6 +677,7 @@ struct slcompress *
> > > if (cs->cs_tcp.doff > 5)
> > > memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr),
> > > (cs->cs_tcp.doff - 5) * 4);
> > > cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
> > > + cs->initialized = 1;
> > > /* Put headers back on packet
> > ...
> > > struct cstate {
> > > byte_t cs_this; /* connection id number (xmit) */
> > > + byte_t initialized; /* non-zero if initialized */
> >
> > Please use 'bool' and true/false for 'initialized'.
>
> Made the changes.
Hi Tejaswi,
Please send the new version of your patch as fresh new submission, with
proper subject prefix. In this case, it should be [PATCH net v2]. 'net'
because this is a bugfix and it should therefore target the 'net' tree.
'v2' because that's the second version of this series.
Also it'd be good if you could add a proper 'Fixes' tag in order to
help with stable backports. If the bug has always been there, just say
so.
I have no expertise on slhc, but overall, the patch content looks fine.
Guillaume
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slip: Check if rstate is initialized before uncompressing
2018-04-10 5:58 ` tejaswit
2018-04-10 9:48 ` Guillaume Nault
@ 2018-04-10 14:03 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2018-04-10 14:03 UTC (permalink / raw)
To: tejaswit; +Cc: netdev
From: tejaswit@codeaurora.org
Date: Tue, 10 Apr 2018 11:28:10 +0530
> On 2018-04-09 20:34, David Miller wrote:
>> From: Tejaswi Tanikella <tejaswit@codeaurora.org>
>> Date: Mon, 9 Apr 2018 14:23:49 +0530
>>
>>> @@ -673,6 +677,7 @@ struct slcompress *
>>> if (cs->cs_tcp.doff > 5)
>>> memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr),
>>> (cs->cs_tcp.doff - 5) * 4);
>>> cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
>>> + cs->initialized = 1;
>>> /* Put headers back on packet
>> ...
>>> struct cstate {
>>> byte_t cs_this; /* connection id number (xmit) */
>>> + byte_t initialized; /* non-zero if initialized */
>> Please use 'bool' and true/false for 'initialized'.
>
> Made the changes.
Please, when you are asked to fix a patch, post it as a new posting
with '[PATCH v2 net] slip: ...' in the subject line.
And also not as an attachment, all patches must be inline.
Thank you.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slip: Check if rstate is initialized before uncompressing
2018-03-29 9:58 Tejaswi Tanikella
2018-04-04 10:51 ` Tejaswi Tanikella
@ 2018-04-05 17:47 ` Guillaume Nault
1 sibling, 0 replies; 8+ messages in thread
From: Guillaume Nault @ 2018-04-05 17:47 UTC (permalink / raw)
To: linux-ppp
On Wed, Apr 04, 2018 at 04:21:25PM +0530, Tejaswi Tanikella wrote:
> On receiving a packet the state index points to the rstate which must be
> used to fill up IP and TCP headers. But if the state index points to a
> rstate which is unitialized, i.e. filled with zeros, it gets stuck in an
> infinite loop inside ip_fast_csum trying to compute the ip checsum of a
> header with zero length.
>
Hi Tejaswi,
Patches aren't reviewed on linux-ppp but on netdev. You should post
your patch there.
Regards,
Guillaume
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] slip: Check if rstate is initialized before uncompressing
2018-03-29 9:58 Tejaswi Tanikella
@ 2018-04-04 10:51 ` Tejaswi Tanikella
2018-04-05 17:47 ` Guillaume Nault
1 sibling, 0 replies; 8+ messages in thread
From: Tejaswi Tanikella @ 2018-04-04 10:51 UTC (permalink / raw)
To: linux-ppp
On receiving a packet the state index points to the rstate which must be
used to fill up IP and TCP headers. But if the state index points to a
rstate which is unitialized, i.e. filled with zeros, it gets stuck in an
infinite loop inside ip_fast_csum trying to compute the ip checsum of a
header with zero length.
89.666953: <2> [<ffffff9dd3e94d38>] slhc_uncompress+0x464/0x468
89.666965: <2> [<ffffff9dd3e87d88>] ppp_receive_nonmp_frame+0x3b4/0x65c
89.666978: <2> [<ffffff9dd3e89dd4>] ppp_receive_frame+0x64/0x7e0
89.666991: <2> [<ffffff9dd3e8a708>] ppp_input+0x104/0x198
89.667005: <2> [<ffffff9dd3e93868>] pppopns_recv_core+0x238/0x370
89.667027: <2> [<ffffff9dd4428fc8>] __sk_receive_skb+0xdc/0x250
89.667040: <2> [<ffffff9dd3e939e4>] pppopns_recv+0x44/0x60
89.667053: <2> [<ffffff9dd4426848>] __sock_queue_rcv_skb+0x16c/0x24c
89.667065: <2> [<ffffff9dd4426954>] sock_queue_rcv_skb+0x2c/0x38
89.667085: <2> [<ffffff9dd44f7358>] raw_rcv+0x124/0x154
89.667098: <2> [<ffffff9dd44f7568>] raw_local_deliver+0x1e0/0x22c
89.667117: <2> [<ffffff9dd44c8ba0>] ip_local_deliver_finish+0x70/0x24c
89.667131: <2> [<ffffff9dd44c92f4>] ip_local_deliver+0x100/0x10c
./scripts/faddr2line vmlinux slhc_uncompress+0x464/0x468 output:
ip_fast_csum at arch/arm64/include/asm/checksum.h:40
(inlined by) slhc_uncompress at drivers/net/slip/slhc.c:615
Adding a variable to indicate if the current rstate is initialized. If
such a packet arrives, move to toss state.
Signed-off-by: Tejaswi Tanikella <tejaswit@codeaurora.org>
---
drivers/net/slip/slhc.c | 5 +++++
include/net/slhc_vj.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
index 5782733..e710b0b 100644
--- a/drivers/net/slip/slhc.c
+++ b/drivers/net/slip/slhc.c
@@ -509,6 +509,10 @@ struct slcompress *
if(x < 0 || x > comp->rslot_limit)
goto bad;
+ /* Check if the cstate is initialized */
+ if(!comp->rstate[x].initialized)
+ goto bad;
+
comp->flags &=~ SLF_TOSS;
comp->recv_current = x;
} else {
@@ -673,6 +677,7 @@ struct slcompress *
if (cs->cs_tcp.doff > 5)
memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr), (cs->cs_tcp.doff - 5) * 4);
cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
+ cs->initialized = 1;
/* Put headers back on packet
* Neither header checksum is recalculated
*/
diff --git a/include/net/slhc_vj.h b/include/net/slhc_vj.h
index 8716d59..d673365 100644
--- a/include/net/slhc_vj.h
+++ b/include/net/slhc_vj.h
@@ -127,6 +127,7 @@
*/
struct cstate {
byte_t cs_this; /* connection id number (xmit) */
+ byte_t initialized; /* non-zero if initialized */
struct cstate *next; /* next in ring (xmit) */
struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */
struct tcphdr cs_tcp;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] slip: Check if rstate is initialized before uncompressing
@ 2018-03-29 9:58 Tejaswi Tanikella
2018-04-04 10:51 ` Tejaswi Tanikella
2018-04-05 17:47 ` Guillaume Nault
0 siblings, 2 replies; 8+ messages in thread
From: Tejaswi Tanikella @ 2018-03-29 9:58 UTC (permalink / raw)
To: linux-ppp
On receiving a packet the state index points to the rstate which must be
used to fill up IP and TCP headers. But if the state index points to a
rstate which is unitialized, i.e. filled with zeros, watch-dog bites.
It gets stuck in an infinite loop inside ip_fast_csum trying to compute
the ip checsum of a header with length zero.
89.666953: <2> [<ffffff9dd3e94d38>] slhc_uncompress+0x464/0x468
89.666965: <2> [<ffffff9dd3e87d88>] ppp_receive_nonmp_frame+0x3b4/0x65c
89.666978: <2> [<ffffff9dd3e89dd4>] ppp_receive_frame+0x64/0x7e0
89.666991: <2> [<ffffff9dd3e8a708>] ppp_input+0x104/0x198
89.667005: <2> [<ffffff9dd3e93868>] pppopns_recv_core+0x238/0x370
89.667027: <2> [<ffffff9dd4428fc8>] __sk_receive_skb+0xdc/0x250
89.667040: <2> [<ffffff9dd3e939e4>] pppopns_recv+0x44/0x60
89.667053: <2> [<ffffff9dd4426848>] __sock_queue_rcv_skb+0x16c/0x24c
89.667065: <2> [<ffffff9dd4426954>] sock_queue_rcv_skb+0x2c/0x38
89.667085: <2> [<ffffff9dd44f7358>] raw_rcv+0x124/0x154
89.667098: <2> [<ffffff9dd44f7568>] raw_local_deliver+0x1e0/0x22c
89.667117: <2> [<ffffff9dd44c8ba0>] ip_local_deliver_finish+0x70/0x24c
89.667131: <2> [<ffffff9dd44c92f4>] ip_local_deliver+0x100/0x10c
./scripts/faddr2line vmlinux slhc_uncompress+0x464/0x468 output:
ip_fast_csum at arch/arm64/include/asm/checksum.h:40
(inlined by) slhc_uncompress at drivers/net/slip/slhc.c:615
Adding a variable to indicate if the current rstate is initialized. If
such a packet arrives, move to toss state.
Signed-off-by: Tejaswi Tanikella <tejaswit@codeaurora.org>
---
drivers/net/slip/slhc.c | 5 +++++
include/net/slhc_vj.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
index 5782733..e710b0b 100644
--- a/drivers/net/slip/slhc.c
+++ b/drivers/net/slip/slhc.c
@@ -509,6 +509,10 @@ struct slcompress *
if(x < 0 || x > comp->rslot_limit)
goto bad;
+ /* Check if the cstate is initialized */
+ if(!comp->rstate[x].initialized)
+ goto bad;
+
comp->flags &=~ SLF_TOSS;
comp->recv_current = x;
} else {
@@ -673,6 +677,7 @@ struct slcompress *
if (cs->cs_tcp.doff > 5)
memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr), (cs->cs_tcp.doff - 5) * 4);
cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
+ cs->initialized = 1;
/* Put headers back on packet
* Neither header checksum is recalculated
*/
diff --git a/include/net/slhc_vj.h b/include/net/slhc_vj.h
index 8716d59..d673365 100644
--- a/include/net/slhc_vj.h
+++ b/include/net/slhc_vj.h
@@ -127,6 +127,7 @@
*/
struct cstate {
byte_t cs_this; /* connection id number (xmit) */
+ byte_t initialized; /* non-zero if initialized */
struct cstate *next; /* next in ring (xmit) */
struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */
struct tcphdr cs_tcp;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-04-10 14:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09 8:53 [PATCH] slip: Check if rstate is initialized before uncompressing Tejaswi Tanikella
2018-04-09 15:04 ` David Miller
2018-04-10 5:58 ` tejaswit
2018-04-10 9:48 ` Guillaume Nault
2018-04-10 14:03 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2018-03-29 9:58 Tejaswi Tanikella
2018-04-04 10:51 ` Tejaswi Tanikella
2018-04-05 17:47 ` Guillaume Nault
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.