From: Horatiu Vultur <horatiu.vultur@microchip.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 14:24:59 +0200 [thread overview]
Message-ID: <20230502122459.inxuqa5rt3iluec4@soft-dev3-1> (raw)
In-Reply-To: <20230502082622.2392659-1-Ilia.Gavrilov@infotecs.ru>
The 05/02/2023 08:26, Gavrilov Ilia wrote:
Hi,
>
> 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'.
If the 'sched' parameter is already checked, is it not better to remove
the check from this function?
>
> Found by InfoTeCS on behalf of Linux Verification Center
> (linuxtesting.org) with SVACE.
>
> Fixes: 5bbbbe32a431 ("sctp: introduce stream scheduler foundations")
I am not sure how much this is net material because as you said, this
issue can't happen.
But don't forget to specify the target tree in the subject. You can do
that when creating the patch using:
git format-patch ... --subject-prefix "PATCH net"
> Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
> ---
> 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;
> 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
--
/Horatiu
prev parent reply other threads:[~2023-05-02 12:25 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
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 ` Horatiu Vultur [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=20230502122459.inxuqa5rt3iluec4@soft-dev3-1 \
--to=horatiu.vultur@microchip.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).