Received: by 10.223.185.116 with SMTP id b49csp826032wrg; Sat, 10 Feb 2018 21:18:42 -0800 (PST) X-Google-Smtp-Source: AH8x226AmzSGy1IiQOz8nLDyRQCoRw2XiJ8G3VMDSL6t0PteFlggGwNnvO/hPzr+d0ZrReFRJ06f X-Received: by 2002:a17:902:428:: with SMTP id 37-v6mr130815ple.63.1518326322678; Sat, 10 Feb 2018 21:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326322; cv=none; d=google.com; s=arc-20160816; b=dmjC2p4sE66T/tSdpCE1whHwacoo3xkTEwkLbGq2Sa5b11jk0z/hVzrvhak/aPPxFA dCiUOsLPN0k26xrlmuT+nZqXNfwWFj3MNj/fHdM1HHOW59M9juq3NUzs6YDHNBx2fl8r lf2ydqPlqqa9IRpnhWhfRDyuuXlQAEophQ86ZQciJZ1GOLo1hLLKlTIzxzXXRLOcyqa1 bCcCD842b3oUthBGoQcVVufsu+GLs6izJjPZvrKfPOAe8YBt+a/UKWkcj+0R1xsjbG7J GKjhpDqiUoHKln2+8CfAXSJsCW0nmxTKt+ZvB8T3zpEF2Ke47+plp8NcNy87AqB7zecJ +KJg== 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=5fdBHyPMCG2J5LaJUc0xs5Hzdd0TqYHv/MQ2ZEm68tA=; b=ibb5ghuTxb5MpOBhtRWnIEBo03EYR2iixkvLz/0bftgnd+5ZKpl2wyGPQZGfv5JazF NQ5PVR8iqJZWiz1ZWijAMiFRe3CPqqaCgeS1JWW6nIA5FmQzel5veHbHEDKZK4ijInrh N8yVrF35Sjt1Y64do8nADubBnPL0sy/51qzVNGsJxgz3DD5afpOZcrgILwzOZauAjQlw daVgx8G77mySpHIubQiQHm8bZ1VMrHqZ5Zv2h+uOZM3d8jimtczq25DfshqCvEZfynbv E6qTWM8x1HJc9Vqs+DXXDBSIOYrmwRlQVFusFMoS4hRzu0qatamd1K9CyopoJBhZDHo5 A/8w== 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 d12si2179909pgt.729.2018.02.10.21.18.29; Sat, 10 Feb 2018 21:18:42 -0800 (PST) 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 S932110AbeBKFRl (ORCPT + 99 others); Sun, 11 Feb 2018 00:17:41 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41349 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752553AbeBKEdk (ORCPT ); Sat, 10 Feb 2018 23:33:40 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (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 1ekjKd-0002hM-6g; Sun, 11 Feb 2018 04:33:39 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKY-0004Wp-P8; Sun, 11 Feb 2018 04:33:34 +0000 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, "Mohamed Ghannam" , "David S. Miller" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 67/79] RDS: Heap OOB write in rds_message_alloc_sgs() In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 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.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mohamed Ghannam commit c095508770aebf1b9218e77026e48345d719b17c upstream. When args->nr_local is 0, nr_pages gets also 0 due some size calculation via rds_rm_size(), which is later used to allocate pages for DMA, this bug produces a heap Out-Of-Bound write access to a specific memory region. Signed-off-by: Mohamed Ghannam Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/rds/rdma.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/rds/rdma.c +++ b/net/rds/rdma.c @@ -516,6 +516,9 @@ int rds_rdma_extra_size(struct rds_rdma_ local_vec = (struct rds_iovec __user *)(unsigned long) args->local_vec_addr; + if (args->nr_local == 0) + return -EINVAL; + /* figure out the number of pages in the vector */ for (i = 0; i < args->nr_local; i++) { if (copy_from_user(&vec, &local_vec[i],