Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966916AbcKXPgH (ORCPT ); Thu, 24 Nov 2016 10:36:07 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58406 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966976AbcKXPcm (ORCPT ); Thu, 24 Nov 2016 10:32:42 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Bloch , Maor Gottlieb , Leon Romanovsky , Doug Ledford Subject: [PATCH 4.8 61/67] IB/core: Avoid unsigned int overflow in sg_alloc_table Date: Thu, 24 Nov 2016 16:27:55 +0100 Message-Id: <20161124145500.449658582@linuxfoundation.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161124145457.061710350@linuxfoundation.org> References: <20161124145457.061710350@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1023 Lines: 35 4.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Bloch commit 3c7ba5760ab8eedec01159b267bb9bfcffe522ac upstream. sg_alloc_table gets unsigned int as parameter while the driver returns it as size_t. Check npages isn't greater than maximum unsigned int. Fixes: eeb8461e36c9 ("IB: Refactor umem to use linear SG table") Signed-off-by: Mark Bloch Signed-off-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/umem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -174,7 +174,7 @@ struct ib_umem *ib_umem_get(struct ib_uc cur_base = addr & PAGE_MASK; - if (npages == 0) { + if (npages == 0 || npages > UINT_MAX) { ret = -EINVAL; goto out; }