All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Cc: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	davem@davemloft.net, edumazet@google.com,
	arkadiusz.kubalewski@intel.com, gregkh@linuxfoundation.org,
	hdthky0@gmail.com, michal.michalik@intel.com,
	milena.olech@intel.com
Subject: Re: [patch net] dpll: sanitize possible null pointer dereference in dpll_pin_parent_pin_set()
Date: Mon, 11 Dec 2023 12:43:13 +0100	[thread overview]
Message-ID: <ZXb10Wdef76u2xBy@nanopsycho> (raw)
In-Reply-To: <ffd827e6-95ed-4d96-b5ad-ec1f5b8d4e24@linux.dev>

Mon, Dec 11, 2023 at 11:46:24AM CET, vadim.fedorenko@linux.dev wrote:
>On 11/12/2023 08:37, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.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@gmail.com>
>> Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
>> Signed-off-by: Jiri Pirko <jiri@nvidia.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?

Please see dpll_pin_parent_device_set(). State here is treated exactly
the same as there. It makes sense during set operation to process only
the attributes that are passed. In the future, dpll_pin_parent_pin_set()
can process more attributes, lets be prepared for that.

  reply	other threads:[~2023-12-11 11:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11  8:37 [patch net] dpll: sanitize possible null pointer dereference in dpll_pin_parent_pin_set() Jiri Pirko
2023-12-11 10:46 ` Vadim Fedorenko
2023-12-11 11:43   ` Jiri Pirko [this message]
2023-12-11 12:13     ` Vadim Fedorenko
2023-12-13  0:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZXb10Wdef76u2xBy@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdthky0@gmail.com \
    --cc=kuba@kernel.org \
    --cc=michal.michalik@intel.com \
    --cc=milena.olech@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.