From: Simon Horman <simon.horman@corigine.com>
To: Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
Cc: Neil Horman <nhorman@tuxdriver.com>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Xin Long <lucien.xin@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] sctp: fix a potential buffer overflow in sctp_sched_set_sched()
Date: Tue, 2 May 2023 13:56:02 +0200 [thread overview]
Message-ID: <ZFD6UgOFeUCbbIOC@corigine.com> (raw)
In-Reply-To: <20230502082622.2392659-1-Ilia.Gavrilov@infotecs.ru>
On Tue, May 02, 2023 at 08:26:30AM +0000, Gavrilov Ilia wrote:
> The 'sched' index value must be checked before accessing an element
> of the 'sctp_sched_ops' array. Otherwise, it can lead to buffer overflow.
>
> 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")
> Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
> ---
> 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..a339917d7197 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 *n;
nit: reverse xmas tree - longest line to shortest - for local variable
declarations in networking code.
> struct sctp_sched_ops *old = asoc->outqueue.sched;
> struct sctp_datamsg *msg = NULL;
> struct sctp_chunk *ch;
> int i, ret = 0;
>
> - if (old == n)
> - return ret;
> -
> if (sched > SCTP_SS_MAX)
> return -EINVAL;
>
> + 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 11:56 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 [this message]
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
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=ZFD6UgOFeUCbbIOC@corigine.com \
--to=simon.horman@corigine.com \
--cc=Ilia.Gavrilov@infotecs.ru \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=lvc-project@linuxtesting.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=pabeni@redhat.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).