netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iproute_lwtunnel: Add check for result of get_u32 function
@ 2024-07-07 15:49 Maks Mishin
  2024-07-07 21:22 ` Stephen Hemminger
  2024-07-08 22:19 ` Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Maks Mishin @ 2024-07-07 15:49 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Maks Mishin, netdev

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 ip/iproute_lwtunnel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index b4df4348..2946fa4d 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -1484,7 +1484,8 @@ static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp,
 				NEXT_ARG();
 				if (hmac_ok++)
 					duparg2("hmac", *argv);
-				get_u32(&hmac, *argv, 0);
+				if (get_u32(&hmac, *argv, 0) || hmac == 0)
+					invarg("\"hmac\" value is invalid\n", *argv);
 			} else {
 				continue;
 			}
-- 
2.30.2


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

* Re: [PATCH] iproute_lwtunnel: Add check for result of get_u32 function
  2024-07-07 15:49 [PATCH] iproute_lwtunnel: Add check for result of get_u32 function Maks Mishin
@ 2024-07-07 21:22 ` Stephen Hemminger
  2024-07-08 22:19 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2024-07-07 21:22 UTC (permalink / raw)
  To: Maks Mishin; +Cc: netdev

On Sun,  7 Jul 2024 18:49:28 +0300
Maks Mishin <maks.mishinfz@gmail.com> wrote:

> Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
> ---
>  ip/iproute_lwtunnel.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
> index b4df4348..2946fa4d 100644
> --- a/ip/iproute_lwtunnel.c
> +++ b/ip/iproute_lwtunnel.c
> @@ -1484,7 +1484,8 @@ static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp,
>  				NEXT_ARG();
>  				if (hmac_ok++)
>  					duparg2("hmac", *argv);
> -				get_u32(&hmac, *argv, 0);
> +				if (get_u32(&hmac, *argv, 0) || hmac == 0)
> +					invarg("\"hmac\" value is invalid\n", *argv);
>  			} else {
>  				continue;
>  			}

Fixes: 8db158b9caac ("iproute: add support for SRv6 local segment processing")

The message is not that great. Becomes:
	Error: argument "XXX" is wrong: "hmac" value is invalid.

But the rest of the tunnel parsing is equally as cryptic on error messages.

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

* Re: [PATCH] iproute_lwtunnel: Add check for result of get_u32 function
  2024-07-07 15:49 [PATCH] iproute_lwtunnel: Add check for result of get_u32 function Maks Mishin
  2024-07-07 21:22 ` Stephen Hemminger
@ 2024-07-08 22:19 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2024-07-08 22:19 UTC (permalink / raw)
  To: Maks Mishin; +Cc: netdev

On Sun,  7 Jul 2024 18:49:28 +0300
Maks Mishin <maks.mishinfz@gmail.com> wrote:

> Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
> ---
>  ip/iproute_lwtunnel.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
> index b4df4348..2946fa4d 100644
> --- a/ip/iproute_lwtunnel.c
> +++ b/ip/iproute_lwtunnel.c
> @@ -1484,7 +1484,8 @@ static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp,
>  				NEXT_ARG();
>  				if (hmac_ok++)
>  					duparg2("hmac", *argv);
> -				get_u32(&hmac, *argv, 0);
> +				if (get_u32(&hmac, *argv, 0) || hmac == 0)
> +					invarg("\"hmac\" value is invalid\n", *argv);
>  			} else {
>  				continue;
>  			}

There is another unchecked call to get_u32() in the same file.
Please fix all of them and add more detail in commit message.

If the get_XXX functions are modified to force checks on return value get:

iproute_lwtunnel.c: In function ‘parse_encap_seg6’:
iproute_lwtunnel.c:972:25: warning: ignoring return value of ‘get_u32’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  972 |                         get_u32(&hmac, *argv, 0);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~
iproute_lwtunnel.c: In function ‘parse_encap_seg6local’:
iproute_lwtunnel.c:1487:33: warning: ignoring return value of ‘get_u32’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 1487 |                                 get_u32(&hmac, *argv, 0);
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~


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

end of thread, other threads:[~2024-07-08 22:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-07 15:49 [PATCH] iproute_lwtunnel: Add check for result of get_u32 function Maks Mishin
2024-07-07 21:22 ` Stephen Hemminger
2024-07-08 22:19 ` Stephen Hemminger

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