RE: [RFC PATCH net-next 9/9] ethtool: Add ability to flash transceiver modules' firmware
From: Danielle Ratson
Date: Wed Jan 24 2024 - 10:47:17 EST
> > > GENL_REQ_ATTR_CHECK, and you can check it in the caller, before
> > > taking rtnl_lock.
> > >
> >
> > OK, np. The idea was to have module_flash_fw() that checks the attrs
> > and extract them into params and ethnl_act_module_fw_flash() should be
> > free from those checks. But if so, maybe this separation is redundant
> > and should combine the two?
>
> No strong preference, whatever looks better :) To use
> GENL_REQ_ATTR_CHECK() I think you'll need to pass genl_info here.
> You can either to that or move the validation.
>
> > > > +
> > > tb[ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME],
> > > > + "File name attribute is missing");
> > > > + return -EINVAL;
> > > > + }
> > > > +
> > > > + params.file_name =
> > > > + nla_data(tb[ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME]);
> > >
> > > Hm. I think you copy the param struct by value to the work container.
> > > nla_data() is in the skb which is going to get freed after _ACT returns.
> > > So if anyone tries to access the name from the work it's going to UAF?
> >
> > The file_name parameter is not really needed inside the work. Once we
> > called request_firmware_direct(), we have all that we need in
> > module_fw->fw. Do we still need to avoid that situation? If so, can
> > you please suggest how?
>
> I'd pass it to module_flash_fw_schedule() as a separate argument, if it doesn't
> have to be saved.
It doesn’t make the module_fw->file_name attribute redundant?