diff mbox series

[net] ethtool: fix argument check in do_srxfh function to prevent segmentation fault

Message ID CAHcxVNNRRCMtT0AyNk4OTcqBn6wWTk37SJw9eWChKhxGRCjUCQ@mail.gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] ethtool: fix argument check in do_srxfh function to prevent segmentation fault | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/apply fail Patch does not apply to net-0

Commit Message

Gwangrok Baek July 27, 2024, 1:39 p.m. UTC
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(+)

--
2.43.0

Comments

Jakub Kicinski July 30, 2024, 2:04 a.m. UTC | #1
On Sat, 27 Jul 2024 22:39:46 +0900 백광록 wrote:
> Subject: [PATCH net] ethtool: fix argument check in do_srxfh function to  prevent segmentation fault

Patch makes sense, but two nit picks:

 1) please repost with subject:

    [PATCH ethtool v2] ethtool: fix argument check in do_srxfh function to prevent segmentation fault

   this is a user space CLI patch, not a kernel patch hence ethtool not
   net in the brackets.

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

 2) Please prevent line wrapping of Fixes tags
diff mbox series

Patch

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