Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1643756imd; Sat, 27 Oct 2018 13:53:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5dD0gp9+b0JwRFV86lSDBJ7HU7RgdamVB3Kmmmwyxlvm1UlheA08R+FMl9QdzxYOaVe0brU X-Received: by 2002:a63:2019:: with SMTP id g25-v6mr8209512pgg.235.1540673631294; Sat, 27 Oct 2018 13:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540673631; cv=none; d=google.com; s=arc-20160816; b=V5LEgBvItzbyYDfv7/irZ22arsLLgMk2EFOZxBWGbjHuQIiTwr0l/+MXjmWj6iCjnc osIanFuNQ3Jr+OI9DwovqdzkGaW7GoAhfx2OFAZtsmkGKBsXzvoYzELtATW/GWlNJtkp ssZvs6eJ19k+1tO9md7JQGj5pkK6qmAYT6gEMBJIt9V0Xd8Vu4H3rW59fznkG9cjY8GD faI6KoMxt+v3WmNMplL04MHDST2U1ctN2DRumzCydFRrTcpjgQtDWE9VMXCQ65FGTVsk LQfH0miXto07KSG+nMqnDcm0SEG1zO9jUa64O3Aw905EG48dhyoFgG4FI6WlPae3dURb 1eXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=ToB/6AtwOgUo6U/eXlfKQEESM5Ncu3pDbQVZ2OHSpaU=; b=UAGdgbHzy1RIDU0C2/Z9uwvWOzNcu5zhapbUdRbXUqGuqS9nAzxjH2E7XGnJItJARC qBSn4r08jR83Bry0Me7Zz/LU7ughge6N2hUH1McnxBAuVAIJ+sydDUb30XUUiqwt8ogn /BJyGw3fk2Mp8M9ufedXBVLiOZT5MuMQKujS8om/BXo0Yaz2D+6zrZoVdz84uBqtijWO gp8PSRPOJ5a36NvtU8w1ipqpNpTGa8fgcXptApQFHHrLVZkDOOap/NeIwTzK3DQSF77+ Cmy228mA2kmXYcKKKxBG3hEUNphtThVbou+97tNRnV2+mRYZ0ak1JW/fdl/tkzphZCNs ZfSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iMxBj5j2; 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 14-v6si15637814pgl.157.2018.10.27.13.53.33; Sat, 27 Oct 2018 13:53:51 -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=iMxBj5j2; 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 S1728841AbeJ1F0C (ORCPT + 99 others); Sun, 28 Oct 2018 01:26:02 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:38469 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbeJ1F0B (ORCPT ); Sun, 28 Oct 2018 01:26:01 -0400 Received: by mail-lf1-f65.google.com with SMTP id p86so1124160lfg.5; Sat, 27 Oct 2018 13:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ToB/6AtwOgUo6U/eXlfKQEESM5Ncu3pDbQVZ2OHSpaU=; b=iMxBj5j2+hy/eVu8crLlo2dvF8KGGhNIYZOqaYQG6BnTPR1mQwgbzkqr4OpSzPUgty extPmmd4DEFvcLdCbs0Rzt13irZ8BQ0/07jq6uV8ir5HnKA/PsI6YaDjSU69J6CRV1/L s+VBVscbDZSua6xserF3SWwOtX3Ek4rf20KvqpNFs1ili8+YhqFbNvGoHcCZnQ3ArcDI YAM4jkGm3WgUfWEvgXPsXLm5Dl/fTq2ncDJ7VfYCkMsGM+CahxY+QTBlmrmHICxxGJkR 498t666omimJAxwhBo87rCGueqKi143rlg4UX2nyRXJIQ4xiOb2vopA7ShTEDfydc/q6 EkXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ToB/6AtwOgUo6U/eXlfKQEESM5Ncu3pDbQVZ2OHSpaU=; b=RYgBzLCEteaC3GR4bRgajPPGgv/ZUl0CxJuFKEggRk9bqKTPvQQq9NvSHz4NJ+xOSY EOCloAunMUFppTmC4NgmHToV8OGoKjzWaj655mUHhhsAEZuKJWc9UsBnTHimyKRk/azx xFEFRC81qCpbPZZNZ/3s/li73xkuqOBmRCy+0nRXP/yIHxxMtYS2CekJZjOTER4Meb8u mAIIVfjI5cTx1ZRe+lOnzCuXdlOzs6OGiDVDsW8Vxlj62P3bJxFmztq07V/1ALGuhJhq LomT/q1tzKrHxlms4AuDWjH/0kQReeymYRdM1z9MCABSkD9shSDul7Ie6QH4jzXX6qks Skmw== X-Gm-Message-State: AGRZ1gKpLMA+aSIRSIl05PDepQltjhha/MkhWBkXtoBOjCS7NIxUNOlv 4bsZLYav8Ih04VRdbtOGBMFkxGcvc/+nbg== X-Received: by 2002:a19:6803:: with SMTP id d3-v6mr5164617lfc.45.1540673026649; Sat, 27 Oct 2018 13:43:46 -0700 (PDT) Received: from [192.168.1.227] ([95.174.65.6]) by smtp.gmail.com with ESMTPSA id m16-v6sm2341810lfh.19.2018.10.27.13.43.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 13:43:45 -0700 (PDT) Subject: Re: [PATCH] sctp: socket.c validate sprstat_policy To: vyasevich@gmail.com, nhorman@tuxdriver.com, marcelo.leitner@gmail.com Cc: davem@davemloft.net, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20181027202026.32157-1-tomasbortoli@gmail.com> From: Tomas Bortoli Openpgp: preference=signencrypt Autocrypt: addr=tomasbortoli@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFpCTZMBEADNZ1+Ibh0Z4pgGRcd1aOUMbe/YfHktmajjcoTnKmZZunjoUVAl8waeLITd BC2c8i1wHzHcnthrmb1izs5XlG6PZnl8n5tjysSNbwggzS1NcEK1qgn5VjNlHQ5aRMUwCC51 kicBiNmlQk2UuzzWwdheRGnaf+O1MNhC0GBeEDKQAL5obOU92pzflv6wWNACr+lHxdnpyies mOnRMjH16NjuTkrGbEmJe+MKp0qbjvR3R/dmFC1wczniRMQmV5w3MZ/N9wRappE+Atc1fOM+ wP7AWNuPvrKg4bN5uqKZLDFH7OFpxvjgVdWM40n0cQfqElWY9as+228Sltdd1XyHtUWRF2VW O1l5L0kX0+7+B5k/fpLhXqD3Z7DK7wRXpXmY59pofk7aFdcN97ZK+r6R7mqrwX4W9IpsPhkT kUyg3/Dx/khBZlJKFoUP325/hoH684bSiPEBroel9alB7gTq2ueoFwy6R3q5CMUw3D+CZWHA 3xllu46TRQ/Vt2g0cIHQNPoye2OWYFJ6kSEvaLpymjNDJ9ph2EuHegonDfOaYSq34ic2BcdB JkCgXRLP5K7KtRNJqqR+DM8xByeGmQv9yp6S97el+SiM9R53RhHawJZGz0EPl+2Q6+5mgh3u wXOlkmGrrSrlB8lc567l34ECl6NFtUPI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pV3xM4wMSJOuqVMOz jYpWKYxDTpvsZ0ginUUY993Gb8k/CxjABEMUGVHhQPZ0OzjHIKS6cTzN6ue8bB+CGOLCaQp1 C0NRT5Tn9zpLxtf5nBExFd/zVENY5vAV2ZbKQdemO54O7j6B9DSgVRrm83GCZxbL4d+qTYBF 3tSCWw/6SG1F3q9gR9QrSC2YRjCmhijUVEh6FhZwB58TNZ1sEEttrps8TDa5tUd9 Message-ID: Date: Sat, 27 Oct 2018 22:43:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181027202026.32157-1-tomasbortoli@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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..