Message ID | CAHcxVNOf38nOzoWZ6cxxFUpvkfHPYa+DFZ4tBBYBntkLag93Gw@mail.gmail.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Michal Kubecek |
Headers | show |
Series | [ethtool,v2] ethtool: fix argument check in do_srxfh function to prevent segmentation fault | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
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.
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
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