diff mbox series

[net-next,v2] devlink: don't allow to change net namespace for FW_ACTIVATE reload action

Message ID 20230213115836.3404039-1-jiri@resnulli.us (mailing list archive)
State Accepted
Commit 2edd92570441dd33246210042dc167319a5cf7e3
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] devlink: don't allow to change net namespace for FW_ACTIVATE reload action | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers fail 1 blamed authors not CCed: moshe@mellanox.com; 1 maintainers not CCed: moshe@mellanox.com
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiri Pirko Feb. 13, 2023, 11:58 a.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

The change on network namespace only makes sense during re-init reload
action. For FW activation it is not applicable. So check if user passed
an ATTR indicating network namespace change request and forbid it.

Fixes: ccdf07219da6 ("devlink: Add reload action option to devlink reload command")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
Sending to net-next as this is not actually fixing any real bug,
it just adds a forgotten check.
---
v1->v2:
- don't fail in case the user requests change to the current namespace
---
 net/devlink/dev.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jakub Kicinski Feb. 14, 2023, 6:13 a.m. UTC | #1
On Mon, 13 Feb 2023 12:58:36 +0100 Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> The change on network namespace only makes sense during re-init reload
> action. For FW activation it is not applicable. So check if user passed
> an ATTR indicating network namespace change request and forbid it.
> 
> Fixes: ccdf07219da6 ("devlink: Add reload action option to devlink reload command")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>

The fixes tag needs to go, too, in that case. Otherwise stable will
likely suck it in. Which is riskier than putting it into an -rc.
No need to repost tho, we can drop the tag when applying.

Acked-by: Jakub Kicinski <kuba@kernel.org>
Jiri Pirko Feb. 14, 2023, 7:31 a.m. UTC | #2
Tue, Feb 14, 2023 at 07:13:11AM CET, kuba@kernel.org wrote:
>On Mon, 13 Feb 2023 12:58:36 +0100 Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>> 
>> The change on network namespace only makes sense during re-init reload
>> action. For FW activation it is not applicable. So check if user passed
>> an ATTR indicating network namespace change request and forbid it.
>> 
>> Fixes: ccdf07219da6 ("devlink: Add reload action option to devlink reload command")
>> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
>
>The fixes tag needs to go, too, in that case. Otherwise stable will
>likely suck it in. Which is riskier than putting it into an -rc.
>No need to repost tho, we can drop the tag when applying.

Okay, up to you. Thanks!

>
>Acked-by: Jakub Kicinski <kuba@kernel.org>
patchwork-bot+netdevbpf@kernel.org Feb. 14, 2023, 2:30 p.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 13 Feb 2023 12:58:36 +0100 you wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> The change on network namespace only makes sense during re-init reload
> action. For FW activation it is not applicable. So check if user passed
> an ATTR indicating network namespace change request and forbid it.
> 
> Fixes: ccdf07219da6 ("devlink: Add reload action option to devlink reload command")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> 
> [...]

Here is the summary with links:
  - [net-next,v2] devlink: don't allow to change net namespace for FW_ACTIVATE reload action
    https://git.kernel.org/netdev/net-next/c/2edd92570441

You are awesome, thank you!
Simon Horman Feb. 20, 2023, 9:01 a.m. UTC | #4
On Mon, Feb 13, 2023 at 12:58:36PM +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> The change on network namespace only makes sense during re-init reload
> action. For FW activation it is not applicable. So check if user passed
> an ATTR indicating network namespace change request and forbid it.
> 
> Fixes: ccdf07219da6 ("devlink: Add reload action option to devlink reload command")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
> Sending to net-next as this is not actually fixing any real bug,
> it just adds a forgotten check.
> ---
> v1->v2:
> - don't fail in case the user requests change to the current namespace

Thanks for fixing my feedback on v1 and sorry for not
reviewing v2 earlier - I was taking a break last week.

For the record, and I know the patch has already been accepted,
this looks good to me.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
diff mbox series

Patch

diff --git a/net/devlink/dev.c b/net/devlink/dev.c
index ab4e0f3c4e3d..b40153fa2680 100644
--- a/net/devlink/dev.c
+++ b/net/devlink/dev.c
@@ -476,6 +476,12 @@  int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
 		dest_net = devlink_netns_get(skb, info);
 		if (IS_ERR(dest_net))
 			return PTR_ERR(dest_net);
+		if (!net_eq(dest_net, devlink_net(devlink)) &&
+		    action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT) {
+			NL_SET_ERR_MSG_MOD(info->extack,
+					   "Changing namespace is only supported for reinit action");
+			return -EOPNOTSUPP;
+		}
 	}
 
 	err = devlink_reload(devlink, dest_net, action, limit, &actions_performed, info->extack);