netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
       [not found] <0DB595A2CB707F458400BE9663B6A72269C004777F@SC-VEXCH2.marvell.com>
@ 2013-10-11 17:53 ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2013-10-11 17:53 UTC (permalink / raw)
  To: seif; +Cc: paul, netdev, thomas.petazzoni, dima


Sorry, no HTML encoded email is allowed on the list.

Turn off all encodings and send plain ASCII text to this mailing
list.

Thank you.

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

* [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
@ 2013-10-11 17:58 Seif Mazareeb
  2013-10-11 19:02 ` Paul Moore
  0 siblings, 1 reply; 12+ messages in thread
From: Seif Mazareeb @ 2013-10-11 17:58 UTC (permalink / raw)
  To: davem@davemloft.net, paul@paul-moore.com, netdev@vger.kernel.org
  Cc: thomas.petazzoni@free-electrons.com, Dmitri Epshtein

When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could loop
forever in the main loop if opt[opt_iter +1] == 0, this will causing a kernel
crash in an SMP system, since the CPU executing this function will
stall /not respond to IPIs.

This problem can be reproduced by running the IP Stack Integrity Checker
(http://isic.sourceforge.net) using the following command on a Linux machine
connected to DUT:

"icmpsic -s rand -d <DUT IP address> -r 123456"
wait (1-2 min)

Signed-off-by: Seif Mazareeb <seif@marvell.com>
---
 include/net/cipso_ipv4.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index a7a683e..047f1f6 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -306,6 +306,10 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
                        err_offset = opt_iter + 1;
                        goto out;
                }
+
+               if (opt[opt_iter + 1] == 0)
+                       break;
+
                opt_iter += opt[opt_iter + 1];
        }

--
1.8.1.2

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

* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-11 17:58 Seif Mazareeb
@ 2013-10-11 19:02 ` Paul Moore
  2013-10-11 21:04   ` Seif Mazareeb
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Moore @ 2013-10-11 19:02 UTC (permalink / raw)
  To: Seif Mazareeb
  Cc: davem@davemloft.net, netdev@vger.kernel.org,
	thomas.petazzoni@free-electrons.com, Dmitri Epshtein

On Friday, October 11, 2013 10:58:31 AM Seif Mazareeb wrote:
> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could
> loop forever in the main loop if opt[opt_iter +1] == 0, this will causing a
> kernel crash in an SMP system, since the CPU executing this function will
> stall /not respond to IPIs.
> 
> This problem can be reproduced by running the IP Stack Integrity Checker
> (http://isic.sourceforge.net) using the following command on a Linux machine
> connected to DUT:
> 
> "icmpsic -s rand -d <DUT IP address> -r 123456"
> wait (1-2 min)
> 
> Signed-off-by: Seif Mazareeb <seif@marvell.com>
> ---
>  include/net/cipso_ipv4.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
> index a7a683e..047f1f6 100644
> --- a/include/net/cipso_ipv4.h
> +++ b/include/net/cipso_ipv4.h
> @@ -306,6 +306,10 @@ static inline int cipso_v4_validate(const struct
> sk_buff *skb, err_offset = opt_iter + 1;
>                         goto out;
>                 }
> +
> +               if (opt[opt_iter + 1] == 0)
> +                       break;
> +
>                 opt_iter += opt[opt_iter + 1];
>         }

Thanks for finding and reporting this bug.  Unfortunately, I don't think the 
supplied patch is the best way to solve this.  Since a length of zero is not 
valid for any known CIPSO tag types (at least that I am aware of), we should 
treat a zero length tag as an error, similar to how we treat tags with length 
values that stretch beyond the option itself.

I'm thinking something like this:

static inline int cipso_v4_validate(const struct sk_buff *skb,
                                    unsigned char **option)
{
        unsigned char *opt = *option;
        unsigned char err_offset = 0;
        u8 opt_len = opt[1];
        u8 opt_iter;
        u8 tag_len;

        if (opt_len < 8) {
                err_offset = 1;
                goto out;
        }

        if (get_unaligned_be32(&opt[2]) == 0) {
                err_offset = 2;
                goto out;
        }

        for (opt_iter = 6; opt_iter < opt_len;) {
                tag_len = opt[opt_iter + 1];
                if ((tag_len == 0) || (tag_len > (opt_len - opt_iter))) {
                        err_offset = opt_iter + 1;
                        goto out;
                }
                opt_iter += tag_len;
        }

out:
        *option = opt + err_offset;
        return err_offset;

}

If you want to fixup your patch that would be appreciated, if not, please let 
me know so I can submit the fix.

Thanks,
-Paul

-- 
paul moore
www.paul-moore.com

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

* RE: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-11 19:02 ` Paul Moore
@ 2013-10-11 21:04   ` Seif Mazareeb
  2013-10-12 11:57     ` Paul Moore
  0 siblings, 1 reply; 12+ messages in thread
From: Seif Mazareeb @ 2013-10-11 21:04 UTC (permalink / raw)
  To: Paul Moore
  Cc: davem@davemloft.net, netdev@vger.kernel.org,
	thomas.petazzoni@free-electrons.com, Dmitri Epshtein

When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could loop
forever in the main loop if opt[opt_iter +1] == 0, this will causing a kernel
crash in an SMP system, since the CPU executing this function will
stall /not respond to IPIs.

This problem can be reproduced by running the IP Stack Integrity Checker
(http://isic.sourceforge.net) using the following command on a Linux machine
connected to DUT:

"icmpsic -s rand -d <DUT IP address> -r 123456"
wait (1-2 min)

Signed-off-by: Seif Mazareeb <seif@marvell.com>
---
 include/net/cipso_ipv4.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index a7a683e..286b7da 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
        unsigned char err_offset = 0;
        u8 opt_len = opt[1];
        u8 opt_iter;
+       u8 tag_len;

        if (opt_len < 8) {
                err_offset = 1;
@@ -302,7 +303,8 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
        }

        for (opt_iter = 6; opt_iter < opt_len;) {
-               if (opt[opt_iter + 1] > (opt_len - opt_iter)) {
+               tag_len = opt[opt_iter + 1];
+               if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len - opt_iter))) {
                        err_offset = opt_iter + 1;
                        goto out;
                }
--
1.8.1.2

-----Original Message-----
From: Paul Moore [mailto:paul@paul-moore.com] 
Sent: Friday, October 11, 2013 12:02 PM
To: Seif Mazareeb
Cc: davem@davemloft.net; netdev@vger.kernel.org; thomas.petazzoni@free-electrons.com; Dmitri Epshtein
Subject: Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL

On Friday, October 11, 2013 10:58:31 AM Seif Mazareeb wrote:
> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function 
> could loop forever in the main loop if opt[opt_iter +1] == 0, this 
> will causing a kernel crash in an SMP system, since the CPU executing 
> this function will stall /not respond to IPIs.
> 
> This problem can be reproduced by running the IP Stack Integrity 
> Checker
> (http://isic.sourceforge.net) using the following command on a Linux 
> machine connected to DUT:
> 
> "icmpsic -s rand -d <DUT IP address> -r 123456"
> wait (1-2 min)
> 
> Signed-off-by: Seif Mazareeb <seif@marvell.com>
> ---
>  include/net/cipso_ipv4.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h index 
> a7a683e..047f1f6 100644
> --- a/include/net/cipso_ipv4.h
> +++ b/include/net/cipso_ipv4.h
> @@ -306,6 +306,10 @@ static inline int cipso_v4_validate(const struct 
> sk_buff *skb, err_offset = opt_iter + 1;
>                         goto out;
>                 }
> +
> +               if (opt[opt_iter + 1] == 0)
> +                       break;
> +
>                 opt_iter += opt[opt_iter + 1];
>         }

Thanks for finding and reporting this bug.  Unfortunately, I don't think the supplied patch is the best way to solve this.  Since a length of zero is not valid for any known CIPSO tag types (at least that I am aware of), we should treat a zero length tag as an error, similar to how we treat tags with length values that stretch beyond the option itself.

I'm thinking something like this:

static inline int cipso_v4_validate(const struct sk_buff *skb,
                                    unsigned char **option) {
        unsigned char *opt = *option;
        unsigned char err_offset = 0;
        u8 opt_len = opt[1];
        u8 opt_iter;
        u8 tag_len;

        if (opt_len < 8) {
                err_offset = 1;
                goto out;
        }

        if (get_unaligned_be32(&opt[2]) == 0) {
                err_offset = 2;
                goto out;
        }

        for (opt_iter = 6; opt_iter < opt_len;) {
                tag_len = opt[opt_iter + 1];
                if ((tag_len == 0) || (tag_len > (opt_len - opt_iter))) {
                        err_offset = opt_iter + 1;
                        goto out;
                }
                opt_iter += tag_len;
        }

out:
        *option = opt + err_offset;
        return err_offset;

}

If you want to fixup your patch that would be appreciated, if not, please let me know so I can submit the fix.

Thanks,
-Paul

--
paul moore
www.paul-moore.com

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

* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-11 21:04   ` Seif Mazareeb
@ 2013-10-12 11:57     ` Paul Moore
  2013-10-13  5:21       ` Seif Mazareeb
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Moore @ 2013-10-12 11:57 UTC (permalink / raw)
  To: Seif Mazareeb
  Cc: davem@davemloft.net, netdev@vger.kernel.org,
	thomas.petazzoni@free-electrons.com, Dmitri Epshtein

On Friday, October 11, 2013 2:04:10 PM Seif Mazareeb wrote:
> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could
> loop forever in the main loop if opt[opt_iter +1] == 0, this will causing a
> kernel crash in an SMP system, since the CPU executing this function will
> stall /not respond to IPIs.
> 
> This problem can be reproduced by running the IP Stack Integrity Checker
> (http://isic.sourceforge.net) using the following command on a Linux machine
> connected to DUT:
> 
> "icmpsic -s rand -d <DUT IP address> -r 123456"
> wait (1-2 min)
> 
> Signed-off-by: Seif Mazareeb <seif@marvell.com>
> ---
>  include/net/cipso_ipv4.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
> index a7a683e..286b7da 100644
> --- a/include/net/cipso_ipv4.h
> +++ b/include/net/cipso_ipv4.h
> @@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct sk_buff
> *skb, unsigned char err_offset = 0;
>         u8 opt_len = opt[1];
>         u8 opt_iter;
> +       u8 tag_len;
> 
>         if (opt_len < 8) {
>                 err_offset = 1;
> @@ -302,7 +303,8 @@ static inline int cipso_v4_validate(const struct sk_buff
> *skb, }
> 
>         for (opt_iter = 6; opt_iter < opt_len;) {
> -               if (opt[opt_iter + 1] > (opt_len - opt_iter)) {
> +               tag_len = opt[opt_iter + 1];
> +               if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len -
> opt_iter))) { err_offset = opt_iter + 1;
>                         goto out;
>                 }

You should also use 'tag_len' inside the for-loop, and after the if-block, 
where we increment 'opt_iter'.  See my original reply for an example.

-- 
paul moore
www.paul-moore.com

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

* RE: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-12 11:57     ` Paul Moore
@ 2013-10-13  5:21       ` Seif Mazareeb
  2013-10-14 15:12         ` Paul Moore
  0 siblings, 1 reply; 12+ messages in thread
From: Seif Mazareeb @ 2013-10-13  5:21 UTC (permalink / raw)
  To: Paul Moore
  Cc: davem@davemloft.net, netdev@vger.kernel.org,
	thomas.petazzoni@free-electrons.com, Dmitri Epshtein

When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could loop
forever in the main loop if opt[opt_iter +1] == 0, this will causing a kernel
crash in an SMP system, since the CPU executing this function will
stall /not respond to IPIs.

This problem can be reproduced by running the IP Stack Integrity Checker
(http://isic.sourceforge.net) using the following command on a Linux machine
connected to DUT:

"icmpsic -s rand -d <DUT IP address> -r 123456"
wait (1-2 min)

Signed-off-by: Seif Mazareeb <seif@marvell.com>
---
 include/net/cipso_ipv4.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index a7a683e..a8c2ef6 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
        unsigned char err_offset = 0;
        u8 opt_len = opt[1];
        u8 opt_iter;
+       u8 tag_len;

        if (opt_len < 8) {
                err_offset = 1;
@@ -302,11 +303,12 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
        }

        for (opt_iter = 6; opt_iter < opt_len;) {
-               if (opt[opt_iter + 1] > (opt_len - opt_iter)) {
+               tag_len = opt[opt_iter + 1];
+               if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len - opt_iter))) {
                        err_offset = opt_iter + 1;
                        goto out;
                }
-               opt_iter += opt[opt_iter + 1];
+               opt_iter += tag_len;
        }

 out:
--
1.8.1.2

-----Original Message-----
From: Paul Moore [mailto:paul@paul-moore.com] 
Sent: Saturday, October 12, 2013 4:57 AM
To: Seif Mazareeb
Cc: davem@davemloft.net; netdev@vger.kernel.org; thomas.petazzoni@free-electrons.com; Dmitri Epshtein
Subject: Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL

On Friday, October 11, 2013 2:04:10 PM Seif Mazareeb wrote:
> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function 
> could loop forever in the main loop if opt[opt_iter +1] == 0, this 
> will causing a kernel crash in an SMP system, since the CPU executing 
> this function will stall /not respond to IPIs.
> 
> This problem can be reproduced by running the IP Stack Integrity 
> Checker
> (http://isic.sourceforge.net) using the following command on a Linux 
> machine connected to DUT:
> 
> "icmpsic -s rand -d <DUT IP address> -r 123456"
> wait (1-2 min)
> 
> Signed-off-by: Seif Mazareeb <seif@marvell.com>
> ---
>  include/net/cipso_ipv4.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h index 
> a7a683e..286b7da 100644
> --- a/include/net/cipso_ipv4.h
> +++ b/include/net/cipso_ipv4.h
> @@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct 
> sk_buff *skb, unsigned char err_offset = 0;
>         u8 opt_len = opt[1];
>         u8 opt_iter;
> +       u8 tag_len;
> 
>         if (opt_len < 8) {
>                 err_offset = 1;
> @@ -302,7 +303,8 @@ static inline int cipso_v4_validate(const struct 
> sk_buff *skb, }
> 
>         for (opt_iter = 6; opt_iter < opt_len;) {
> -               if (opt[opt_iter + 1] > (opt_len - opt_iter)) {
> +               tag_len = opt[opt_iter + 1];
> +               if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len -
> opt_iter))) { err_offset = opt_iter + 1;
>                         goto out;
>                 }

You should also use 'tag_len' inside the for-loop, and after the if-block, where we increment 'opt_iter'.  See my original reply for an example.

--
paul moore
www.paul-moore.com

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

* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-13  5:21       ` Seif Mazareeb
@ 2013-10-14 15:12         ` Paul Moore
  2013-10-17 19:47           ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Moore @ 2013-10-14 15:12 UTC (permalink / raw)
  To: Seif Mazareeb
  Cc: davem@davemloft.net, netdev@vger.kernel.org,
	thomas.petazzoni@free-electrons.com, Dmitri Epshtein

On Saturday, October 12, 2013 10:21:50 PM Seif Mazareeb wrote:
> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could
> loop forever in the main loop if opt[opt_iter +1] == 0, this will causing a
> kernel crash in an SMP system, since the CPU executing this function will
> stall /not respond to IPIs.
> 
> This problem can be reproduced by running the IP Stack Integrity Checker
> (http://isic.sourceforge.net) using the following command on a Linux machine
> connected to DUT:
> 
> "icmpsic -s rand -d <DUT IP address> -r 123456"
> wait (1-2 min)
> 
> Signed-off-by: Seif Mazareeb <seif@marvell.com>

Thanks for sticking with this.

Acked-by: Paul Moore <paul@paul-moore.com>

> ---
>  include/net/cipso_ipv4.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
> index a7a683e..a8c2ef6 100644
> --- a/include/net/cipso_ipv4.h
> +++ b/include/net/cipso_ipv4.h
> @@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct sk_buff
> *skb, unsigned char err_offset = 0;
>         u8 opt_len = opt[1];
>         u8 opt_iter;
> +       u8 tag_len;
> 
>         if (opt_len < 8) {
>                 err_offset = 1;
> @@ -302,11 +303,12 @@ static inline int cipso_v4_validate(const struct
> sk_buff *skb, }
> 
>         for (opt_iter = 6; opt_iter < opt_len;) {
> -               if (opt[opt_iter + 1] > (opt_len - opt_iter)) {
> +               tag_len = opt[opt_iter + 1];
> +               if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len -
> opt_iter))) { err_offset = opt_iter + 1;
>                         goto out;
>                 }
> -               opt_iter += opt[opt_iter + 1];
> +               opt_iter += tag_len;
>         }
> 
>  out:
> --
> 1.8.1.2

-- 
paul moore
www.paul-moore.com

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

* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-14 15:12         ` Paul Moore
@ 2013-10-17 19:47           ` David Miller
  2013-10-18  1:20             ` Paul Moore
  0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2013-10-17 19:47 UTC (permalink / raw)
  To: paul; +Cc: seif, netdev, thomas.petazzoni, dima

From: Paul Moore <paul@paul-moore.com>
Date: Mon, 14 Oct 2013 11:12:47 -0400

> On Saturday, October 12, 2013 10:21:50 PM Seif Mazareeb wrote:
>> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could
>> loop forever in the main loop if opt[opt_iter +1] == 0, this will causing a
>> kernel crash in an SMP system, since the CPU executing this function will
>> stall /not respond to IPIs.
>> 
>> This problem can be reproduced by running the IP Stack Integrity Checker
>> (http://isic.sourceforge.net) using the following command on a Linux machine
>> connected to DUT:
>> 
>> "icmpsic -s rand -d <DUT IP address> -r 123456"
>> wait (1-2 min)
>> 
>> Signed-off-by: Seif Mazareeb <seif@marvell.com>
> 
> Thanks for sticking with this.
> 
> Acked-by: Paul Moore <paul@paul-moore.com>

This patch, like all the others Seif submitted, has been corrupted by
his email client and is this unusable.

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

* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-17 19:47           ` David Miller
@ 2013-10-18  1:20             ` Paul Moore
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Moore @ 2013-10-18  1:20 UTC (permalink / raw)
  To: seif; +Cc: David Miller, netdev, thomas.petazzoni, dima

On Thursday, October 17, 2013 03:47:42 PM David Miller wrote:
> From: Paul Moore <paul@paul-moore.com>
> Date: Mon, 14 Oct 2013 11:12:47 -0400
> 
> > On Saturday, October 12, 2013 10:21:50 PM Seif Mazareeb wrote:
> >> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could
> >> loop forever in the main loop if opt[opt_iter +1] == 0, this will causing
> >> a
> >> kernel crash in an SMP system, since the CPU executing this function will
> >> stall /not respond to IPIs.
> >> 
> >> This problem can be reproduced by running the IP Stack Integrity Checker
> >> (http://isic.sourceforge.net) using the following command on a Linux
> >> machine connected to DUT:
> >> 
> >> "icmpsic -s rand -d <DUT IP address> -r 123456"
> >> wait (1-2 min)
> >> 
> >> Signed-off-by: Seif Mazareeb <seif@marvell.com>
> > 
> > Thanks for sticking with this.
> > 
> > Acked-by: Paul Moore <paul@paul-moore.com>
> 
> This patch, like all the others Seif submitted, has been corrupted by
> his email client and is this unusable.

Seif, please fix this.  If I don't see a new patch by tomorrow I'll go ahead 
and resubmit.

-- 
paul moore
www.paul-moore.com

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

* [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
@ 2013-10-18  3:33 Seif Mazareeb
  2013-10-18 21:01 ` Paul Moore
  0 siblings, 1 reply; 12+ messages in thread
From: Seif Mazareeb @ 2013-10-18  3:33 UTC (permalink / raw)
  To: paul, davem; +Cc: seif, netdev

From: Seif Mazareeb <seif@marvell.com>

When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could loop
forever in the main loop if opt[opt_iter +1] == 0, this will causing a kernel
crash in an SMP system, since the CPU executing this function will
stall /not respond to IPIs.

This problem can be reproduced by running the IP Stack Integrity Checker
(http://isic.sourceforge.net) using the following command on a Linux machine
connected to DUT:

"icmpsic -s rand -d <DUT IP address> -r 123456"
wait (1-2 min)

Signed-off-by: Seif Mazareeb <seif@marvell.com>
---
 include/net/cipso_ipv4.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index a7a683e..a8c2ef6 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
 	unsigned char err_offset = 0;
 	u8 opt_len = opt[1];
 	u8 opt_iter;
+	u8 tag_len;
 
 	if (opt_len < 8) {
 		err_offset = 1;
@@ -302,11 +303,12 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
 	}
 
 	for (opt_iter = 6; opt_iter < opt_len;) {
-		if (opt[opt_iter + 1] > (opt_len - opt_iter)) {
+		tag_len = opt[opt_iter + 1];
+		if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len - opt_iter))) {
 			err_offset = opt_iter + 1;
 			goto out;
 		}
-		opt_iter += opt[opt_iter + 1];
+		opt_iter += tag_len;
 	}
 
 out:
-- 
1.8.1.2

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

* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-18  3:33 Seif Mazareeb
@ 2013-10-18 21:01 ` Paul Moore
  2013-10-19 22:56   ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Moore @ 2013-10-18 21:01 UTC (permalink / raw)
  To: Seif Mazareeb, netdev; +Cc: davem, seif

On Thursday, October 17, 2013 08:33:21 PM Seif Mazareeb wrote:
> From: Seif Mazareeb <seif@marvell.com>
> 
> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could
> loop forever in the main loop if opt[opt_iter +1] == 0, this will causing a
> kernel crash in an SMP system, since the CPU executing this function will
> stall /not respond to IPIs.
> 
> This problem can be reproduced by running the IP Stack Integrity Checker
> (http://isic.sourceforge.net) using the following command on a Linux machine
> connected to DUT:
> 
> "icmpsic -s rand -d <DUT IP address> -r 123456"
> wait (1-2 min)
> 
> Signed-off-by: Seif Mazareeb <seif@marvell.com>

This version imported properly for me.

Acked-by: Paul Moore <paul@paul-moore.com>

> ---
>  include/net/cipso_ipv4.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
> index a7a683e..a8c2ef6 100644
> --- a/include/net/cipso_ipv4.h
> +++ b/include/net/cipso_ipv4.h
> @@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct sk_buff
> *skb, unsigned char err_offset = 0;
>  	u8 opt_len = opt[1];
>  	u8 opt_iter;
> +	u8 tag_len;
> 
>  	if (opt_len < 8) {
>  		err_offset = 1;
> @@ -302,11 +303,12 @@ static inline int cipso_v4_validate(const struct
> sk_buff *skb, }
> 
>  	for (opt_iter = 6; opt_iter < opt_len;) {
> -		if (opt[opt_iter + 1] > (opt_len - opt_iter)) {
> +		tag_len = opt[opt_iter + 1];
> +		if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len - opt_iter))) {
>  			err_offset = opt_iter + 1;
>  			goto out;
>  		}
> -		opt_iter += opt[opt_iter + 1];
> +		opt_iter += tag_len;
>  	}
> 
>  out:

-- 
paul moore
www.paul-moore.com

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

* Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL
  2013-10-18 21:01 ` Paul Moore
@ 2013-10-19 22:56   ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2013-10-19 22:56 UTC (permalink / raw)
  To: paul; +Cc: seif.mazareeb, netdev, seif

From: Paul Moore <paul@paul-moore.com>
Date: Fri, 18 Oct 2013 17:01:11 -0400

> On Thursday, October 17, 2013 08:33:21 PM Seif Mazareeb wrote:
>> From: Seif Mazareeb <seif@marvell.com>
>> 
>> When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could
>> loop forever in the main loop if opt[opt_iter +1] == 0, this will causing a
>> kernel crash in an SMP system, since the CPU executing this function will
>> stall /not respond to IPIs.
>> 
>> This problem can be reproduced by running the IP Stack Integrity Checker
>> (http://isic.sourceforge.net) using the following command on a Linux machine
>> connected to DUT:
>> 
>> "icmpsic -s rand -d <DUT IP address> -r 123456"
>> wait (1-2 min)
>> 
>> Signed-off-by: Seif Mazareeb <seif@marvell.com>
> 
> This version imported properly for me.
> 
> Acked-by: Paul Moore <paul@paul-moore.com>

Applied and queued up for -stable, thanks!

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

end of thread, other threads:[~2013-10-19 22:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0DB595A2CB707F458400BE9663B6A72269C004777F@SC-VEXCH2.marvell.com>
2013-10-11 17:53 ` [PATCH 1/1] net: fix cipso packet validation when !NETLABEL David Miller
2013-10-11 17:58 Seif Mazareeb
2013-10-11 19:02 ` Paul Moore
2013-10-11 21:04   ` Seif Mazareeb
2013-10-12 11:57     ` Paul Moore
2013-10-13  5:21       ` Seif Mazareeb
2013-10-14 15:12         ` Paul Moore
2013-10-17 19:47           ` David Miller
2013-10-18  1:20             ` Paul Moore
  -- strict thread matches above, loose matches on Subject: below --
2013-10-18  3:33 Seif Mazareeb
2013-10-18 21:01 ` Paul Moore
2013-10-19 22:56   ` David Miller

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