netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davide Caratti <dcaratti@redhat.com>
To: Colin King <colin.king@canonical.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S . Miller" <davem@davemloft.net>,
	Gautam Ramakrishnan <gautamramk@gmail.com>,
	"Sachin D . Patil" <sdp.sachin@gmail.com>,
	Mohit Bhasi <mohitbhasi1998@gmail.com>,
	Leslie Monis <lesliemonis@gmail.com>,
	"Mohit P . Tahiliani" <tahiliani@nitk.edu.in>,
	netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: sched: Fix potential infinite loop
Date: Wed, 07 Apr 2021 22:20:08 +0200	[thread overview]
Message-ID: <4396d0b86d66afa1d3211403b48a15a4d0a03e55.camel@redhat.com> (raw)
In-Reply-To: <20210407163808.499027-1-colin.king@canonical.com>

hello Colin, and thanks for your patch!

On Wed, 2021-04-07 at 17:38 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The for-loop iterates with a u16 loop counter idx and compares this
> with the loop upper limit of q->flows_cnt that is a u32 type.

the value of 'flows_cnt' has 65535 as an upper bound in the ->init()
function, so it should be safe to use an u16 for 'idx'. (BTW, the
infinite loop loop was a real thing, see [1] :) ).

> There is a potential infinite loop if q->flows_cnt is larger than
> the u8 loop counter.

(u16 loop counter, IIUC)

>  Fix this by making the loop counter the same
> type as q->flows_cnt.

the same 'for' loop is in fq_pie_init() and fq_pie_reset(): so, in my
opinion just changing fq_pie_timer() to fix an infinite loop is not very
useful: 'idx' is also used as an index for q->flows[], that's allocated
in [2]. Maybe (but I might be wrong) just allowing bigger values might
potentially cause other covscan warnings. WDYT?

> Addresses-Coverity: ("Infinite loop")
> Fixes: ec97ecf1ebe4 ("net: sched: add Flow Queue PIE packet scheduler")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

thanks!
-- 
davide


[1] https://lore.kernel.org/netdev/416eb03a8ca70b5dfb5e882e2752b7fc13c42f92.1590537338.git.dcaratti@redhat.com/
[2] https://elixir.bootlin.com/linux/latest/source/net/sched/sch_fq_pie.c#L417



      reply	other threads:[~2021-04-07 20:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 16:38 [PATCH] net: sched: Fix potential infinite loop Colin King
2021-04-07 20:20 ` Davide Caratti [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=4396d0b86d66afa1d3211403b48a15a4d0a03e55.camel@redhat.com \
    --to=dcaratti@redhat.com \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=gautamramk@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lesliemonis@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mohitbhasi1998@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdp.sachin@gmail.com \
    --cc=tahiliani@nitk.edu.in \
    --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;
as well as URLs for NNTP newsgroup(s).