Re: [PATCH net-next v6 08/14] net/smc: Introduce generic netlink interface for diagnostic purposes

Jakub Kicinski
2020-11-28T21:07:37Z

On Thu, 26 Nov 2020 21:39:10 +0100 Karsten Graul wrote:
> +/* SMC_GENL family definition */
> +struct genl_family smc_gen_nl_family __ro_after_init = {
> + .hdrsize = 0,
> + .name = SMC_GENL_FAMILY_NAME,
> + .version = SMC_GENL_FAMILY_VERSION,
> + .maxattr = SMC_GEN_MAX,
> + .netnsok = true,
> + .module = THIS_MODULE,
> + .ops = smc_gen_nl_ops,
> + .n_ops = ARRAY_SIZE(smc_gen_nl_ops)
> +};

Sorry, one more spin.

Now you'll let any attribute in. We try to reject any input that won't
be acted on in the kernel these days to allow the interfaces to be
extended in the future without worrying that something that was
throwing random data in the messages will suddenly start misbehaving.

You should still declare a policy just make it empty. And you can make
the policy array size 1, and set .maxattr to 1, AFAIK. These are both
pretty much* for input validation only.

* the only exception is dumping the policy to be able to tell types in
user space automatically, but I don't think you'll care.