All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] devlink: fix segfault on health command
@ 2019-09-04 17:26 Andrea Claudi
  2019-09-04 19:03 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Andrea Claudi @ 2019-09-04 17:26 UTC (permalink / raw)
  To: netdev; +Cc: stephen, dsahern

devlink segfaults when using grace_period without reporter

$ devlink health set pci/0000:00:09.0 grace_period 3500
Segmentation fault

devlink is instead supposed to gracefully fail printing a warning
message

$ devlink health set pci/0000:00:09.0 grace_period 3500
Reporter's name is expected.

This happens because DL_OPT_HEALTH_REPORTER_NAME and
DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD are both defined as BIT(27).
When dl_opts_put() parse options and grace_period is set, it erroneously
tries to set reporter name to null.

This is fixed simply shifting by 1 bit enumeration starting with
DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD.

Fixes: b18d89195b16 ("devlink: Add devlink health set command")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
---
 devlink/devlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 91c85dc1de730..0293373928f50 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -231,8 +231,8 @@ static void ifname_map_free(struct ifname_map *ifname_map)
 #define DL_OPT_FLASH_FILE_NAME	BIT(25)
 #define DL_OPT_FLASH_COMPONENT	BIT(26)
 #define DL_OPT_HEALTH_REPORTER_NAME	BIT(27)
-#define DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD	BIT(27)
-#define DL_OPT_HEALTH_REPORTER_AUTO_RECOVER	BIT(28)
+#define DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD	BIT(28)
+#define DL_OPT_HEALTH_REPORTER_AUTO_RECOVER	BIT(29)
 
 struct dl_opts {
 	uint32_t present; /* flags of present items */
-- 
2.21.0


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

* Re: [PATCH iproute2] devlink: fix segfault on health command
  2019-09-04 17:26 [PATCH iproute2] devlink: fix segfault on health command Andrea Claudi
@ 2019-09-04 19:03 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2019-09-04 19:03 UTC (permalink / raw)
  To: Andrea Claudi; +Cc: netdev, dsahern

On Wed,  4 Sep 2019 19:26:14 +0200
Andrea Claudi <aclaudi@redhat.com> wrote:

> devlink segfaults when using grace_period without reporter
> 
> $ devlink health set pci/0000:00:09.0 grace_period 3500
> Segmentation fault
> 
> devlink is instead supposed to gracefully fail printing a warning
> message
> 
> $ devlink health set pci/0000:00:09.0 grace_period 3500
> Reporter's name is expected.
> 
> This happens because DL_OPT_HEALTH_REPORTER_NAME and
> DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD are both defined as BIT(27).
> When dl_opts_put() parse options and grace_period is set, it erroneously
> tries to set reporter name to null.
> 
> This is fixed simply shifting by 1 bit enumeration starting with
> DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD.
> 
> Fixes: b18d89195b16 ("devlink: Add devlink health set command")
> Signed-off-by: Andrea Claudi <aclaudi@redhat.com>

Thanks, applied

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

end of thread, other threads:[~2019-09-04 19:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 17:26 [PATCH iproute2] devlink: fix segfault on health command Andrea Claudi
2019-09-04 19:03 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.