Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1626311imd; Sat, 27 Oct 2018 13:21:36 -0700 (PDT) X-Google-Smtp-Source: AJdET5eMHHcx6+XKT3mWJguTbNZtvW8hGnT6f1LqsImPeXgJ5Yh0wrA2x7PB49kZdD9aRMx2tk5k X-Received: by 2002:a17:902:bcc4:: with SMTP id o4-v6mr8175348pls.66.1540671696356; Sat, 27 Oct 2018 13:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540671696; cv=none; d=google.com; s=arc-20160816; b=UKNWe/AAiEvkqkWw4hVst7U7AKzl4DwwyPxpd6es4eljgc+dFr9YDQs7VQY38lgPlr G76pYokfZEJSr4RuHt6S/3x092eZEmNsB8gge8CWV0ibsTxvoSOQF2jhNTlE4IYufPjM GbVhsMMHDqaEJeHINQxvzRk9CsyJuHdUQewAjmhr0/Hd775b1N0Xgb1wDbYwSMQa4Iql tnvGobHKpJMGJR31EHKKwYgQ/Q4VgDqIjcAelf1UmmnVcs7sOOxDzCee95BOiT+W6rEl 4hh0Sd+iaAwqAqcMVgqVBysmWwA8mnZVUKz9fpqDftqenAr3OLLltZ13VcRD1Lh/vkhq vMfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=EWMUqs6CaHzLIxKw/s30cfrMD8CaJcuQBftfn1gEFGk=; b=Lr/O84O05IbRuL/wXtbEWGkuiiXg5RdV3G4HgPyzsNy79o42IbHqYuXst+biwAK+ui Nt+4JO9QAGmb+n6wdEyjyE3dXcyZ8COhWzdI2cQsmlFkWpuMXmXsAlrqTqGHvvSRBlxo XbUHmMeGZE9m5DRYpONu/680QwPAMCUVGez1HssvudErVfcRA87sfPg2B4RATfPI92d+ VG0az/OUUlfCCTugKdK+1pABuCG4Das1XyG/O2/66mywZHcC705hfh89VuF6fgYxyRbt cywSW1MbMtRIpq7i6ZAx/VO+rYC7gxLzkDPlRCnbcIpSDJrmfgZWo5lqXDjWWFpzi9E5 /ujw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p2KJ2hIo; 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 r75-v6si12751683pgr.429.2018.10.27.13.21.20; Sat, 27 Oct 2018 13:21:36 -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=p2KJ2hIo; 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 S1728472AbeJ1FDF (ORCPT + 99 others); Sun, 28 Oct 2018 01:03:05 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41387 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbeJ1FDF (ORCPT ); Sun, 28 Oct 2018 01:03:05 -0400 Received: by mail-lf1-f66.google.com with SMTP id c16so3310754lfj.8; Sat, 27 Oct 2018 13:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=EWMUqs6CaHzLIxKw/s30cfrMD8CaJcuQBftfn1gEFGk=; b=p2KJ2hIoEpPZL/XynATC31xOqWgwqYGiVrAig40gdWiKnqkrKKG7ylqYY8Au/GwG3v WuKwh2l5iJx0zQ+wUdCyQd4auLeH5OknI/VICF2kOdQ/ATX8XcS22PPf/z0KFa4BMt0b nq/1XmWp1fBahJelOLero2mIWzvVqYtfhJVkLNoReBaMs3qSTtm4loSR7ClMGfspXfBf q1Nc3xsQNyd7Yi759ZuAS6z3tIVZWdqpBzO0tPngKLXxv919SZoNOpGgZ2wliY/6zqPJ y69CxYqfEY9gu+ZLWU6OAD//RXKAA68ihlkn1REhkDTE/4Ga+cYl6a4y+ATrrPr3c/lZ uKfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EWMUqs6CaHzLIxKw/s30cfrMD8CaJcuQBftfn1gEFGk=; b=M/YmiBDtH1BAvjtvLzIQp9GckR5PPPP+PtlezXTPUuseVv2BJDBg6bm7FejjWvckO/ ZC0DFqi8ZHqS9hO1VfpPF2fw60eb6UdV/FGj/lON1qJO+uRsp6N+E5FmCHoai8k+HCq+ cTAZGI5BmhUsCzGCK6qrx1+wG2XV87pHMvhE7KjZ+ySElbNV+9zc7rC3s7wNr8k1T6Vw 4KVqCANjQh/F1fepBYHiIgNkKdtOh5FXOARtZ/EOiiOKMMYMhPITuThI41BJovcbZQ4P gXGy4P1ClzkmJTBOb6Gm1tLOs5BY1FaocH5lFLAtZHaEZYZMlt06KaX4Cx8nKwqbSZJK SeNw== X-Gm-Message-State: AGRZ1gIA4sdDU3e8lWkJ4QlxgBD4l/fexMMXxEzmNPhFHmnzouhSLBtY h/wZQ6ZmFBspwHvL2NPj8Oo= X-Received: by 2002:a19:cb94:: with SMTP id b142mr5141435lfg.117.1540671655451; Sat, 27 Oct 2018 13:20:55 -0700 (PDT) Received: from localhost.localdomain ([95.174.65.6]) by smtp.gmail.com with ESMTPSA id d13-v6sm2216147ljc.25.2018.10.27.13.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 13:20:54 -0700 (PDT) From: Tomas Bortoli 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, Tomas Bortoli Subject: [PATCH] sctp: socket.c validate sprstat_policy Date: Sat, 27 Oct 2018 22:20:26 +0200 Message-Id: <20181027202026.32157-1-tomasbortoli@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.11.0