[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250228171753.GL1615191@kernel.org>
Date: Fri, 28 Feb 2025 17:17:53 +0000
From: Simon Horman <horms@...nel.org>
To: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@...ux.intel.com>
Cc: intel-wired-lan@...ts.osuosl.org, netdev@...r.kernel.org,
Mateusz Polchlopek <mateusz.polchlopek@...el.com>
Subject: Re: [iwl-net v2 5/5] ice: fix using untrusted value of pkt_len in
ice_vc_fdir_parse_raw()
On Tue, Feb 25, 2025 at 10:08:49AM +0100, Martyna Szapar-Mudlaw wrote:
> From: Mateusz Polchlopek <mateusz.polchlopek@...el.com>
>
> Fix using the untrusted value of proto->raw.pkt_len in function
> ice_vc_fdir_parse_raw() by verifying if it does not exceed the
> VIRTCHNL_MAX_SIZE_RAW_PACKET value.
>
> Fixes: 99f419df8a5c ("ice: enable FDIR filters from raw binary patterns for VFs")
> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@...el.com>
> Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@...ux.intel.com>
> ---
> .../ethernet/intel/ice/ice_virtchnl_fdir.c | 25 +++++++++++++------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
> index 14e3f0f89c78..6250629ee8f9 100644
> --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
> +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
> @@ -835,18 +835,27 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
> u8 *pkt_buf, *msk_buf __free(kfree);
> struct ice_parser_result rslt;
> struct ice_pf *pf = vf->pf;
> + u16 pkt_len, udp_port = 0;
> struct ice_parser *psr;
> int status = -ENOMEM;
> struct ice_hw *hw;
> - u16 udp_port = 0;
>
> - pkt_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
> - msk_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
> + if (!proto->raw.pkt_len)
> + return -EINVAL;
Hi Martyna,
It seems to me that the use of __free() above will result in
kfree(msk_buf) being called here. But msk_buf is not initialised at this
point.
My suggest would be to drop the use of __free().
But if not, I think that in order to be safe it would be best to do this
(completely untested;
u8 *pkt_buf, *msk_buf __free(kfree) = NULL;
...
Powered by blists - more mailing lists