From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: ilia.gavrilov@infotecs.ru, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org,
lucien.xin@gmail.com, lvc-project@linuxtesting.org,
netdev@vger.kernel.org, nhorman@tuxdriver.com, pabeni@redhat.com,
simon.horman@corigine.com
Subject: Re: [PATCH net v2] sctp: fix a potential buffer overflow in sctp_sched_set_sched()
Date: Tue, 2 May 2023 14:49:34 -0300 [thread overview]
Message-ID: <ZFFNLtBYepvBzoPr@t14s.localdomain> (raw)
In-Reply-To: <20230502170516.39760-1-kuniyu@amazon.com>
On Tue, May 02, 2023 at 10:05:16AM -0700, Kuniyuki Iwashima wrote:
> From: Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
> Date: Tue, 2 May 2023 13:03:24 +0000
> > The 'sched' index value must be checked before accessing an element
> > of the 'sctp_sched_ops' array. Otherwise, it can lead to buffer overflow.
>
> OOB access ?
My thought as well.
> But it's not true because it does not happen in the first place.
>
> >
> > Note that it's harmless since the 'sched' parameter is checked before
> > calling 'sctp_sched_set_sched'.
> >
> > Found by InfoTeCS on behalf of Linux Verification Center
> > (linuxtesting.org) with SVACE.
> >
> > Fixes: 5bbbbe32a431 ("sctp: introduce stream scheduler foundations")
> > Reviewed-by: Simon Horman <simon.horman@corigine.com>
> > Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
> > ---
> > V2:
> > - Change the order of local variables
> > - Specify the target tree in the subject
> > net/sctp/stream_sched.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/net/sctp/stream_sched.c b/net/sctp/stream_sched.c
> > index 330067002deb..4d076a9b8592 100644
> > --- a/net/sctp/stream_sched.c
> > +++ b/net/sctp/stream_sched.c
> > @@ -146,18 +146,19 @@ static void sctp_sched_free_sched(struct sctp_stream *stream)
> > int sctp_sched_set_sched(struct sctp_association *asoc,
> > enum sctp_sched_type sched)
> > {
> > - struct sctp_sched_ops *n = sctp_sched_ops[sched];
> > struct sctp_sched_ops *old = asoc->outqueue.sched;
> > struct sctp_datamsg *msg = NULL;
> > + struct sctp_sched_ops *n;
> > struct sctp_chunk *ch;
> > int i, ret = 0;
> >
> > - if (old == n)
> > - return ret;
> > -
> > if (sched > SCTP_SS_MAX)
> > return -EINVAL;
>
> I'd just remove this check instead because the same test is done
> in the caller side, sctp_setsockopt_scheduler(), and this errno
> is never returned.
>
> This unnecessary test confuses a reader like sched could be over
> SCTP_SS_MAX here.
It's actualy better to keep the test here and remove it from the
callers: they don't need to know the specifics, and further new calls
will be protected already.
>
> Since the OOB access does not happen, I think this patch should
> go to net-next without the Fixes tag after the merge window.
Yup.
>
> Thanks,
> Kuniyuki
>
>
> >
> > + n = sctp_sched_ops[sched];
> > + if (old == n)
> > + return ret;
> > +
> > if (old)
> > sctp_sched_free_sched(&asoc->stream);
> >
> > --
> > 2.30.2
next prev parent reply other threads:[~2023-05-02 17:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 8:26 [PATCH] sctp: fix a potential buffer overflow in sctp_sched_set_sched() Gavrilov Ilia
2023-05-02 11:48 ` Simon Horman
2023-05-02 11:56 ` Simon Horman
2023-05-02 13:03 ` [PATCH net v2] " Gavrilov Ilia
2023-05-02 14:23 ` Xin Long
2023-05-02 15:56 ` Marcelo Ricardo Leitner
2023-05-02 17:05 ` Kuniyuki Iwashima
2023-05-02 17:49 ` Marcelo Ricardo Leitner [this message]
2023-05-03 9:08 ` Gavrilov Ilia
2023-05-03 12:47 ` Marcelo Ricardo Leitner
2023-05-03 13:37 ` [PATCH net v4] sctp: fix a potential OOB access " Gavrilov Ilia
2023-05-03 13:44 ` Marcelo Ricardo Leitner
2023-05-04 1:49 ` Jakub Kicinski
2023-05-03 10:31 ` [PATCH net v3] sctp: remove unncessary check " Gavrilov Ilia
2023-05-02 12:24 ` [PATCH] sctp: fix a potential buffer overflow " Horatiu Vultur
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=ZFFNLtBYepvBzoPr@t14s.localdomain \
--to=marcelo.leitner@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ilia.gavrilov@infotecs.ru \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=lvc-project@linuxtesting.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=pabeni@redhat.com \
--cc=simon.horman@corigine.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