[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CO1PR11MB5089142F465D060B9AE3FDC0D686A@CO1PR11MB5089.namprd11.prod.outlook.com>
Date: Mon, 4 Dec 2023 19:17:24 +0000
From: "Keller, Jacob E" <jacob.e.keller@...el.com>
To: Jiri Pirko <jiri@...nulli.us>, "Kitszel, Przemyslaw"
<przemyslaw.kitszel@...el.com>
CC: "kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com"
<pabeni@...hat.com>, "davem@...emloft.net" <davem@...emloft.net>,
"edumazet@...gle.com" <edumazet@...gle.com>, "Hadi Salim, Jamal"
<jhs@...atatu.com>, "johannes@...solutions.net" <johannes@...solutions.net>,
"andriy.shevchenko@...ux.intel.com" <andriy.shevchenko@...ux.intel.com>,
"Nambiar, Amritha" <amritha.nambiar@...el.com>, "sdf@...gle.com"
<sdf@...gle.com>, "horms@...nel.org" <horms@...nel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [patch net-next v4 8/9] devlink: add a command to set
notification filter and use it for multicasts
> -----Original Message-----
> From: Jiri Pirko <jiri@...nulli.us>
> Sent: Monday, December 4, 2023 8:25 AM
> To: Kitszel, Przemyslaw <przemyslaw.kitszel@...el.com>
> Cc: kuba@...nel.org; pabeni@...hat.com; davem@...emloft.net;
> edumazet@...gle.com; Keller, Jacob E <jacob.e.keller@...el.com>; Hadi Salim,
> Jamal <jhs@...atatu.com>; johannes@...solutions.net;
> andriy.shevchenko@...ux.intel.com; Nambiar, Amritha
> <amritha.nambiar@...el.com>; sdf@...gle.com; horms@...nel.org;
> netdev@...r.kernel.org
> Subject: Re: [patch net-next v4 8/9] devlink: add a command to set notification
> filter and use it for multicasts
>
> Mon, Nov 27, 2023 at 04:40:22PM CET, przemyslaw.kitszel@...el.com wrote:
> >On 11/23/23 19:15, Jiri Pirko wrote:
> >> From: Jiri Pirko <jiri@...dia.com>
> >>
>
> [...]
>
>
> >> diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c
> >> index fa9afe3e6d9b..33a8e51dea68 100644
> >> --- a/net/devlink/netlink.c
> >> +++ b/net/devlink/netlink.c
> >> @@ -17,6 +17,79 @@ static const struct genl_multicast_group
> devlink_nl_mcgrps[] = {
> >> [DEVLINK_MCGRP_CONFIG] = { .name =
> DEVLINK_GENL_MCGRP_CONFIG_NAME },
> >> };
> >> +int devlink_nl_notify_filter_set_doit(struct sk_buff *skb,
> >> + struct genl_info *info)
> >> +{
> >> + struct nlattr **attrs = info->attrs;
> >> + struct devlink_obj_desc *flt;
> >> + size_t data_offset = 0;
> >> + size_t data_size = 0;
> >> + char *pos;
> >> +
> >> + if (attrs[DEVLINK_ATTR_BUS_NAME])
> >> + data_size += nla_len(attrs[DEVLINK_ATTR_BUS_NAME]) + 1;
> >> + if (attrs[DEVLINK_ATTR_DEV_NAME])
> >> + data_size += nla_len(attrs[DEVLINK_ATTR_DEV_NAME]) + 1;
> >> +
> >> + flt = kzalloc(sizeof(*flt) + data_size, GFP_KERNEL);
> >
> >instead of arithmetic here, you could use struct_size()
>
> That is used for flex array, yet I have no flex array here.
>
Yea this isn't a flexible array. You could use size_add to ensure that this can't overflow. I don't know what the bound on the attribute sizes is.
Powered by blists - more mailing lists