Commit 059fa492 authored by Ilia.Gavrilov's avatar Ilia.Gavrilov Committed by David S. Miller
Browse files

sctp: fix a potential OOB access in sctp_sched_set_sched()



The 'sched' index value must be checked before accessing an element
of the 'sctp_sched_ops' array. Otherwise, it can lead to OOB access.

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.

Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarIlia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6096bc05
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -148,18 +148,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;

	n = sctp_sched_ops[sched];
	if (old == n)
		return ret;

	if (old)
		sctp_sched_free_sched(&asoc->stream);