Subject: Re: [PATCH net-next RFC 13/20] p4tc: add metadata create, update, delete, get, flush and dump

From: Simon Horman <[email-masked]>
Date: Mon, 5 Jun 2023 12:22:03 +0200

On Tue, Jan 24, 2023 at 12:05:03PM -0500, Jamal Hadi Salim wrote:

...

Hi Victor, Jamal and Pedro,

some minor feedback from my side.

> +struct p4tc_metadata *tcf_meta_create(struct nlmsghdr *n, struct nlattr *nla,
> +				      u32 m_id, struct p4tc_pipeline *pipeline,
> +				      struct netlink_ext_ack *extack)

A gcc-12 build with W=1 suggests that this function could be static.

...

> +static int _tcf_meta_fill_nlmsg(struct sk_buff *skb,
> +				const struct p4tc_metadata *meta)
> +{
> +	unsigned char *b = nlmsg_get_pos(skb);
> +	struct p4tc_meta_size_params sz_params;
> +	struct nlattr *nest;
> +
> +	if (nla_put_u32(skb, P4TC_PATH, meta->m_id))
> +		goto out_nlmsg_trim;
> +
> +	nest = nla_nest_start(skb, P4TC_PARAMS);
> +	if (!nest)
> +		goto out_nlmsg_trim;
> +
> +	sz_params.datatype = meta->m_datatype;
> +	sz_params.startbit = meta->m_startbit;
> +	sz_params.endbit = meta->m_endbit;

There may be a hole at the end of sz_params, which is uninitialised,
yet fed into nl_put below.

> +
> +	if (nla_put_string(skb, P4TC_META_NAME, meta->common.name))
> +		goto out_nlmsg_trim;
> +	if (nla_put(skb, P4TC_META_SIZE, sizeof(sz_params), &sz_params))
> +		goto out_nlmsg_trim;
> +
> +	nla_nest_end(skb, nest);
> +
> +	return skb->len;
> +
> +out_nlmsg_trim:
> +	nlmsg_trim(skb, b);
> +	return -1;
> +}

...