Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1893994imd; Sat, 27 Oct 2018 21:21:24 -0700 (PDT) X-Google-Smtp-Source: AJdET5cSAFI5sMv9VUQFDtvrWO4obMWveAIBzXxqLz5kttyoSJLNG1w/5/9pEamQQnaK6bhDQjr0 X-Received: by 2002:a62:2782:: with SMTP id n124-v6mr9964922pfn.216.1540700484572; Sat, 27 Oct 2018 21:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540700484; cv=none; d=google.com; s=arc-20160816; b=KgZkubp0JXhIzUMR9OMBy9J2D4FSZbwuOfiSeSWLuLFLvprkPBgTKIMJ7v3xmh4XFM eLx+HN0tRuAgKIUAr7CLJ2jYIsJz2XStj+CLIPK1jOmCVIZiYj0jgaj7AiTilC7xvcuZ Yhu+vxbFBZEDFc8hnFqB7t7iVcEDQJ2Igu0UXVEi63HYpUq82NXymSmzgthq3dNmv8ZP zVKcBX7cYyOtArcTzKGAMyVV2V7IuGU581g0bWYJHbDKEI4FG9QLLU7JdXDlJDosMwAi iXem40EGDhtNLTVwDqoNT1yjsCM/NPZhzORdnct5jqD8vIHDnstJMRo1dm0G0UPbGbPh qDvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=neFthfOwkGDUES53+dJ4WrhK3oID3b4zXpwURU6x+aA=; b=i/aBHbxNAUyigBsbOAiwVm56l9JK3HhrCmXMCNsZYUExOtVFdUnSeoN6ytt3ZNwKkc zDpvilvi2H9bKERbh4dsRHKfyycGKYdhIwuZKOv2tVKBsdew7mh4G24rFIuHZetv8veu fEW01yU0bVpEXM6rFJeYL5MbgFhVjuDY7H1To6f/Oe8ENx0Oq09m+TPxpYe/RPtbdx/q 7q0S37Vx69jBVaR95+wE9oE1y3JSfOA8LGGuXHBWuWC4n3rSzdvoZerb63yTW1nGHjyt gYxf+4AqZ4L1CyQSyop+tUQqCj/wI9e3MUyZZNbv7V9MdLxXIp4pTZ/GskKa/PT8y7+E pgaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N+RDlCF3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si7815157pls.437.2018.10.27.21.21.08; Sat, 27 Oct 2018 21:21:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N+RDlCF3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729171AbeJ1NBc (ORCPT + 99 others); Sun, 28 Oct 2018 09:01:32 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:54032 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbeJ1NBc (ORCPT ); Sun, 28 Oct 2018 09:01:32 -0400 Received: by mail-it1-f193.google.com with SMTP id q70-v6so5878574itb.3; Sat, 27 Oct 2018 21:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=neFthfOwkGDUES53+dJ4WrhK3oID3b4zXpwURU6x+aA=; b=N+RDlCF3v580DGGI6LeEeY/0iOloLE5qKdBMCu727mnevRPZJGbIsY7XIr38nqtw6A tj9WPR8/dk9JKIYhEcdzNaQRiqepQ+v8ZTPzAozIseNlUehsG3WE462RRgjms57nrIFG BkhDWZ4LB4fLSQxwq9UknYIKs950vHmBiok+8MdJ1P3sHt4niubA1sunCQ9ilIIYXSqR QRIQjcGEt7BJsjfF5GVEtAJ3dJHid+F+4nEIPY/FVF0etxPzmOfvpiHLTVa32CPBVqwR xtmnTIKoPnnDpjgZ0NpuT7K5/8n7LPWLxOh9DhY95clfm0NJKAF8dGuwzx9uwLfE/svX /N/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=neFthfOwkGDUES53+dJ4WrhK3oID3b4zXpwURU6x+aA=; b=bDaXqS7f9atKAb6lPWQMbFruFSoghoEIZisr+smvIDMVC334VmmNw2JWziuJMc3ulz 7yuh2KmAIg3rkAgyWhOhDJ3SNT58jHDM4dt7Z3pS/GNcwWZtetV7GyqjoTPalHXdVE61 wB0goyqWfUawDYoKkkDNQ3HIbQN/b3bo6zm2BV6X8QCRh9JbYrJbz7mC+8gRhtJpl+ao UYt1E/vfZE7CcW8JloJDBYwwPVZ8Z/ZZxqwAn7GGvrG1Ws13pzbY+CbzdiQ9P1xDgUgG t5g05yO9QG8qrfY8spY/pYjPmaKn9M6rcDClrSQe2BoFiJ3Zzuqz7Pr6+1ThrDHev0VY ZJlA== X-Gm-Message-State: AGRZ1gLU2n6DYv2Z/1QTINrTJO9sLrZzTGB9HKc0o0DBQ0qxVFvhX/kS 2depLAjerVaWNIXc2J2MLS85PGWt89sY7ToFM1o= X-Received: by 2002:a02:506:: with SMTP id e6-v6mr6879970jad.69.1540700290636; Sat, 27 Oct 2018 21:18:10 -0700 (PDT) MIME-Version: 1.0 References: <20181027205320.14975-1-tomasbortoli@gmail.com> In-Reply-To: <20181027205320.14975-1-tomasbortoli@gmail.com> From: Xin Long Date: Sun, 28 Oct 2018 13:17:56 +0900 Message-ID: Subject: Re: [PATCH v2] sctp: socket.c validate sprstat_policy To: tomasbortoli@gmail.com Cc: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner , davem , linux-sctp@vger.kernel.org, network dev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 28, 2018 at 5:54 AM 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 > --- > net/sctp/socket.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/net/sctp/socket.c b/net/sctp/socket.c > index fc0386e8ff23..14dce5d95817 100644 > --- a/net/sctp/socket.c > +++ b/net/sctp/socket.c > @@ -7083,7 +7083,9 @@ 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) || > + __SCTP_PR_INDEX(policy) < 0) > goto out; > > asoc = sctp_id2assoc(sk, params.sprstat_assoc_id); > @@ -7142,7 +7144,9 @@ 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) || > + __SCTP_PR_INDEX(policy) < 0) > goto out; This is not the correct fix. See https://lkml.org/lkml/2018/10/27/136