Netdev List
 help / color / mirror / Atom feed
From: Larysa Zaremba <larysa.zaremba@intel.com>
To: Alok Tiwari <alok.a.tiwari@oracle.com>
Cc: <netdev@vger.kernel.org>, <darren.kenny@oracle.com>,
	<linux-kernel@vger.kernel.org>, <jhs@mojatatu.com>,
	<xiyou.wangcong@gmail.com>, <jiri@resnulli.us>, <kuba@kernel.org>,
	<simon.horman@corigine.com>, <keescook@chromium.org>
Subject: Re: [PATCH] net: sched: sch: null pointer dereference in htb_offload_move_qdisc()
Date: Thu, 16 Feb 2023 16:24:58 +0100	[thread overview]
Message-ID: <Y+5KyhntRjMzDM2G@lincoln> (raw)
In-Reply-To: <20230216104939.3553390-1-alok.a.tiwari@oracle.com>

On Thu, Feb 16, 2023 at 02:49:40AM -0800, Alok Tiwari wrote:
> A possible case of null pointer dereference detected by static analyzer
> htb_destroy_class_offload() is calling htb_find() which can return NULL value
> for invalid class id, moved_cl=htb_find(classid, sch);
> in that case it should not pass 'moved_cl' to htb_offload_move_qdisc()
> if 'moved_cl' is NULL pointer return -EINVAL.
> 
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>

Conceptually, code looks fine, but it probably won't be accepted without:
- imperative verb in the title
- tree, to which patch must be applied [0]
- more nicely written and formatted commit message. If you are referring to a 
  static analyzer and not to common logic, maybe include, how the warning looks.
  Separate your text into sentences and paragraphs.

[0] https://www.kernel.org/doc/html/v5.3/networking/netdev-FAQ.html#q-how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

> ---
>  net/sched/sch_htb.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
> index 92f2975b6a82..5a96d9ea3221 100644
> --- a/net/sched/sch_htb.c
> +++ b/net/sched/sch_htb.c
> @@ -1601,6 +1601,8 @@ static int htb_destroy_class_offload(struct Qdisc *sch, struct htb_class *cl,
>  		u32 classid = TC_H_MAJ(sch->handle) |
>  			      TC_H_MIN(offload_opt.classid);
>  		struct htb_class *moved_cl = htb_find(classid, sch);
> +		if (WARN_ON_ONCE(!moved_cl))
> +			return -EINVAL;
>  
>  		htb_offload_move_qdisc(sch, moved_cl, cl, destroying);
>  	}
> -- 
> 2.39.1
> 

      reply	other threads:[~2023-02-16 15:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 10:49 [PATCH] net: sched: sch: null pointer dereference in htb_offload_move_qdisc() Alok Tiwari
2023-02-16 15:24 ` Larysa Zaremba [this message]

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=Y+5KyhntRjMzDM2G@lincoln \
    --to=larysa.zaremba@intel.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=darren.kenny@oracle.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@corigine.com \
    --cc=xiyou.wangcong@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox