[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ffd827e6-95ed-4d96-b5ad-ec1f5b8d4e24@linux.dev>
Date: Mon, 11 Dec 2023 10:46:24 +0000
From: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
To: Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org
Cc: kuba@...nel.org, pabeni@...hat.com, davem@...emloft.net,
edumazet@...gle.com, arkadiusz.kubalewski@...el.com,
gregkh@...uxfoundation.org, hdthky0@...il.com, michal.michalik@...el.com,
milena.olech@...el.com
Subject: Re: [patch net] dpll: sanitize possible null pointer dereference in
dpll_pin_parent_pin_set()
On 11/12/2023 08:37, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@...dia.com>
>
> User may not pass DPLL_A_PIN_STATE attribute in the pin set operation
> message. Sanitize that by checking if the attr pointer is not null
> and process the passed state attribute value only in that case.
>
> Reported-by: Xingyuan Mo <hdthky0@...il.com>
> Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
> Signed-off-by: Jiri Pirko <jiri@...dia.com>
> ---
> drivers/dpll/dpll_netlink.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
> index 442a0ebeb953..ce7cf736f020 100644
> --- a/drivers/dpll/dpll_netlink.c
> +++ b/drivers/dpll/dpll_netlink.c
> @@ -925,7 +925,6 @@ dpll_pin_parent_pin_set(struct dpll_pin *pin, struct nlattr *parent_nest,
> struct netlink_ext_ack *extack)
> {
> struct nlattr *tb[DPLL_A_PIN_MAX + 1];
> - enum dpll_pin_state state;
> u32 ppin_idx;
> int ret;
>
> @@ -936,10 +935,14 @@ dpll_pin_parent_pin_set(struct dpll_pin *pin, struct nlattr *parent_nest,
> return -EINVAL;
> }
> ppin_idx = nla_get_u32(tb[DPLL_A_PIN_PARENT_ID]);
> - state = nla_get_u32(tb[DPLL_A_PIN_STATE]);
> - ret = dpll_pin_on_pin_state_set(pin, ppin_idx, state, extack);
> - if (ret)
> - return ret;
> +
> + if (tb[DPLL_A_PIN_STATE]) {
> + enum dpll_pin_state state = nla_get_u32(tb[DPLL_A_PIN_STATE]);
> +
> + ret = dpll_pin_on_pin_state_set(pin, ppin_idx, state, extack);
> + if (ret)
> + return ret;
> + }
>
> return 0;
> }
I don't believe that "set" command without set value should return 0
meaning "request was completed successfully". Maybe it's better to add
another check like for DPLL_A_PIN_PARENT_ID and fill extack with
description?
Powered by blists - more mailing lists