nbd: allow genl access outside init_net
Subsystems (2)
PATCH 2/2 nbd: use the structured req attr check
In reply to Jakub KicinskiUse the macro for checking presence of required attributes. It has the advantage of reporting to the user which attr was missing in a machine-readable format (extack).
--- drivers/block/nbd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/nbd.c +4 -4
@@ -1934,11 +1934,11 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)return -EINVAL ; } } -if (!info->attrs[NBD_ATTR_SOCKETS ]) { +if (GENL_REQ_ATTR_CHECK (info,NBD_ATTR_SOCKETS )) {pr_err ("must specify at least one socket\n" );return -EINVAL ; } -if (!info->attrs[NBD_ATTR_SIZE_BYTES ]) { +if (GENL_REQ_ATTR_CHECK (info,NBD_ATTR_SIZE_BYTES )) {pr_err ("must specify a size in bytes for the device\n" );return -EINVAL ; }
@@ -2123,7 +2123,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)if (!netlink_capable (skb,CAP_SYS_ADMIN ))return -EPERM ; -if (!info->attrs[NBD_ATTR_INDEX ]) { +if (GENL_REQ_ATTR_CHECK (info,NBD_ATTR_INDEX )) {pr_err ("must specify an index to disconnect\n" );return -EINVAL ; }
@@ -2161,7 +2161,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)if (!netlink_capable (skb,CAP_SYS_ADMIN ))return -EPERM ; -if (!info->attrs[NBD_ATTR_INDEX ]) { +if (GENL_REQ_ATTR_CHECK (info,NBD_ATTR_INDEX )) {pr_err ("must specify a device to reconfigure\n" );return -EINVAL ; }
Signature · 1 line
2.39.2
PATCH 1/2 nbd: allow genl access outside init_net
NBD doesn't have much to do with networking, allow users outside init_net to access the family.
--- drivers/block/nbd.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/nbd.c +1 -0
@@ -2325,6 +2325,7 @@ static struct genl_family nbd_genl_family __ro_after_init = { .n_small_ops = ARRAY_SIZE(nbd_connect_genl_ops), .resv_start_op = NBD_CMD_STATUS + 1, .maxattr = NBD_ATTR_MAX, + .netnsok = 1, .policy = nbd_attr_policy, .mcgrps = nbd_mcast_grps, .n_mcgrps = ARRAY_SIZE(nbd_mcast_grps),
Signature · 1 line
2.39.2
Quoted 6 lines · Jakub Kicinski
NBD doesn't have much to do with networking, allow users outside
init_netto access the family.Reviewed-by Josef Bacik <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>---
Looks good.
-ck
Re: [PATCH -next 2/2] nbd: use the structured req attr check
In reply to Jakub KicinskiQuoted 7 lines · Jakub Kicinski
Use the macro for checking presence of required attributes. It has the advantage of reporting to the user which attr was missing in a machine-readable format (extack).
Reviewed-by Josef Bacik <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>---
Looks good.
-ck
Quoted 4 lines · Jakub Kicinski
NBD doesn't have much to do with networking, allow users outside
init_netto access the family.
Applied, thanks!
[1/2] nbd: allow genl access outside init_net
commit: 6a650ef04718aff580d6b352c38ca839991fd3ae
[2/2] nbd: use the structured req attr check
commit: d09b3a9ff6c6ef74298e19b22b362bc0a6e4e9ddBest regards,
Signature · 1 line
Jens Axboe