netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ethtool v2] ethtool: fix argument check in do_srxfh function to prevent segmentation fault
@ 2024-07-31 13:09 Gwangrok Baek
  2024-08-08  8:09 ` Petr Machata
  0 siblings, 1 reply; 2+ messages in thread
From: Gwangrok Baek @ 2024-07-31 13:09 UTC (permalink / raw)
  To: netdev; +Cc: kuba, mkubecek, ahmed.zaki, ecree

Ensure that do_srxfh function in ethtool.c checks for the presence of
additional arguments when context or xfrm parameter is provided before
performing strcmp. This prevents segmentation faults caused by missing
arguments.

Without this patch, running 'ethtool -X DEVNAME [ context | xfrm ]' without
additional arguments results in a segmentation fault due to an invalid
strcmp operation.

Fixes: f5d55b967e0c ("ethtool: add support for extra RSS contexts and
RSS steering filters")
Fixes: a6050b18ba73 ("ethtool: add support for RSS input transformation")
Signed-off-by: Gwangrok Baek <zester926@gmail.com>
---
 ethtool.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ethtool.c b/ethtool.c
index d85a57a..8cb722b 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4261,6 +4261,8 @@ static int do_srxfh(struct cmd_context *ctx)
                        ++arg_num;
                } else if (!strcmp(ctx->argp[arg_num], "xfrm")) {
                        ++arg_num;
+                       if (!ctx->argp[arg_num])
+                               exit_bad_args();
                        if (!strcmp(ctx->argp[arg_num], "symmetric-xor"))
                                req_input_xfrm = RXH_XFRM_SYM_XOR;
                        else if (!strcmp(ctx->argp[arg_num], "none"))
@@ -4270,6 +4272,8 @@ static int do_srxfh(struct cmd_context *ctx)
                        ++arg_num;
                } else if (!strcmp(ctx->argp[arg_num], "context")) {
                        ++arg_num;
+                       if (!ctx->argp[arg_num])
+                               exit_bad_args();
                        if(!strcmp(ctx->argp[arg_num], "new"))
                                rss_context = ETH_RXFH_CONTEXT_ALLOC;
                        else
--
2.43.0

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

* Re: [PATCH ethtool v2] ethtool: fix argument check in do_srxfh function to prevent segmentation fault
  2024-07-31 13:09 [PATCH ethtool v2] ethtool: fix argument check in do_srxfh function to prevent segmentation fault Gwangrok Baek
@ 2024-08-08  8:09 ` Petr Machata
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Machata @ 2024-08-08  8:09 UTC (permalink / raw)
  To: Gwangrok Baek; +Cc: netdev, kuba, mkubecek, ahmed.zaki, ecree


Gwangrok Baek <zester926@gmail.com> writes:

> Ensure that do_srxfh function in ethtool.c checks for the presence of
> additional arguments when context or xfrm parameter is provided before
> performing strcmp. This prevents segmentation faults caused by missing
> arguments.
>
> Without this patch, running 'ethtool -X DEVNAME [ context | xfrm ]' without
> additional arguments results in a segmentation fault due to an invalid
> strcmp operation.
>
> Fixes: f5d55b967e0c ("ethtool: add support for extra RSS contexts and
> RSS steering filters")

As Jakub wrote on v1, the Fixes: tag should not be line-wrapped.

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

end of thread, other threads:[~2024-08-08  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 13:09 [PATCH ethtool v2] ethtool: fix argument check in do_srxfh function to prevent segmentation fault Gwangrok Baek
2024-08-08  8:09 ` Petr Machata

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