From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ZGfejTqw" Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15D48186 for ; Mon, 11 Dec 2023 02:46:32 -0800 (PST) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702291590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+O6sOe34KvM3cp6aR9Fc5LCSSgtwUH7iUeiskiKEYZg=; b=ZGfejTqwvwEqAjj1aGPHyFyPTRrSRUUJS0Ya4Q1Ca1rQJ787fEK9pb8h24jaoF4JN1llsN aoQ977XnHr8a5w33RoNT230/+CSurDzIRw5GV8XCCPs8cVNqm+ym+5vDwXM95OcVcNaJ0u gEGHWl3RMRzvGtTJaVqqwT6DQ6lQ2f8= Date: Mon, 11 Dec 2023 10:46:24 +0000 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [patch net] dpll: sanitize possible null pointer dereference in dpll_pin_parent_pin_set() Content-Language: en-US To: Jiri Pirko , netdev@vger.kernel.org Cc: 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 References: <20231211083758.1082853-1-jiri@resnulli.us> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20231211083758.1082853-1-jiri@resnulli.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 11/12/2023 08:37, Jiri Pirko wrote: > From: Jiri Pirko > > 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 > Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions") > Signed-off-by: Jiri Pirko > --- > 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?