Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2310282imm; Thu, 7 Jun 2018 08:34:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKhake/PqVUOnKUSHcSmPK/00yEqG+pX8Gyg6iwiwHPJud1B52buzAYoxLzDveilQwUkIj+ X-Received: by 2002:a63:744a:: with SMTP id e10-v6mr1991087pgn.275.1528385660881; Thu, 07 Jun 2018 08:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528385660; cv=none; d=google.com; s=arc-20160816; b=FUe8BmQWkQAzh2wc3BTNCEWb8jzDjnNtfh4ewTEQDKFojue3kkUabkZ8kfIzMNIR9p fpTZGrF9jbUAhVR0Fnb6tYcx8cmekvwnA5IBPqkXpF4PBt3eCVyaAAO3/Sm4NhI+RSpw VWYzNGkmOM/I3zpI9BKYk0jsUPdEsH5S+Q8cnFZoX4bOB5nuMr7eEJlLiUKUYdQM/Qyt 5M37Bi/g3VnRfl3BPlvfDx3QPDYzg5PDMPv+Pc0ZIj3GUQhN3ZOd+z1kFpcx1DVwBTbh AycQWAdyeLGCQ6gcdKO+GV62l4SVwI2i58elNxl0vx9gT8CIQqOv/+04Ef9Sg0q9O+xm +wbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=iLNm83VYAvxM4Rlv3DtPwVdowZRTapJGMUCrlUwMt+0=; b=irsOmQjFA64mHAsr05Fy6ujg5xF9VVg8/HCvDjmAga3Psz5A0tEHzQx9RO01M6OIsS Zg9T60sEDMc0PhVdfBZR8DSzy0sUBgVzdAO0ox8WqKK+stPzgtv1TMImH7qoLeGlOwXw XpuZakGSkPbC421mQvFPannegNX4hvIqM1NSrfOPQBILwf7JmJ5E8yXUgpPqDCG/nwIP 1LIgyJCD3KmL6AemUgcQ6y8y/DJ86EkAxTlv6QSQVgzCNOm5V0QbtfmHOXw8YIFYMBi/ b9a+biv7Bb8TXst/2fiUmcfCzFkLJ8W1xzMnBqgX9ILVVf4oPlyvGf8yQU4tLNNs+P9M YisA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92-v6si53273202plc.452.2018.06.07.08.34.06; Thu, 07 Jun 2018 08:34:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934885AbeFGPbw (ORCPT + 99 others); Thu, 7 Jun 2018 11:31:52 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40955 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934889AbeFGOxf (ORCPT ); Thu, 7 Jun 2018 10:53:35 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbS-0005hL-A8; Thu, 07 Jun 2018 15:09:26 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbC-0003CI-0x; Thu, 07 Jun 2018 15:09:10 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Leon Romanovsky" , "Doug Ledford" , syzbot+0df1ab766f8924b1edba@syzkaller.appspotmail.com Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 332/410] RDMA/ucma: Check that user doesn't overflow QP state In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Leon Romanovsky commit a5880b84430316e3e1c1f5d23aa32ec6000cc717 upstream. The QP state is limited and declared in enum ib_qp_state, but ucma user was able to supply any possible (u32) value. Reported-by: syzbot+0df1ab766f8924b1edba@syzkaller.appspotmail.com Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Ben Hutchings --- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -1050,6 +1050,9 @@ static ssize_t ucma_init_qp_attr(struct if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; + if (cmd.qp_state > IB_QPS_ERR) + return -EINVAL; + ctx = ucma_get_ctx(file, cmd.id); if (IS_ERR(ctx)) return PTR_ERR(ctx);