From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomas Bortoli Subject: Re: [PATCH] sctp: socket.c validate sprstat_policy Date: Sat, 27 Oct 2018 22:43:43 +0200 Message-ID: References: <20181027202026.32157-1-tomasbortoli@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: davem@davemloft.net, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: vyasevich@gmail.com, nhorman@tuxdriver.com, marcelo.leitner@gmail.com Return-path: In-Reply-To: <20181027202026.32157-1-tomasbortoli@gmail.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On 10/27/18 10:20 PM, Tomas Bortoli wrote: > It is possible to perform out-of-bound reads on > sctp_getsockopt_pr_streamstatus() and on > sctp_getsockopt_pr_assocstatus() by passing from userspace a > sprstat_policy that overflows the abandoned_sent/abandoned_unsent > fixed length arrays. The over-read data are directly copied/leaked > to userspace. > > Signed-off-by: Tomas Bortoli > Reported-by: syzbot+5da0d0a72a9e7d791748@syzkaller.appspotmail.com > --- > v2 - added forgot || > > net/sctp/socket.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/net/sctp/socket.c b/net/sctp/socket.c > index fc0386e8ff23..5290b8bd40c8 100644 > --- a/net/sctp/socket.c > +++ b/net/sctp/socket.c > @@ -7083,7 +7083,8 @@ static int sctp_getsockopt_pr_assocstatus(struct sock *sk, int len, > } > > policy = params.sprstat_policy; > - if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL))) > + if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)) || > + __SCTP_PR_INDEX(policy) > SCTP_PR_INDEX(MAX)) > goto out; > > asoc = sctp_id2assoc(sk, params.sprstat_assoc_id); > @@ -7142,7 +7143,8 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len, > } > > policy = params.sprstat_policy; > - if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL))) > + if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)) || > + __SCTP_PR_INDEX(policy) > SCTP_PR_INDEX(MAX)) > goto out; > > asoc = sctp_id2assoc(sk, params.sprstat_assoc_id); > I just realized we also have to check for less than 0 indexes..