From patchwork Wed Feb 20 05:40:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10821371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2227117E9 for ; Wed, 20 Feb 2019 05:42:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B322D20B for ; Wed, 20 Feb 2019 05:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9FDB2D241; Wed, 20 Feb 2019 05:42:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BF1E2D20B for ; Wed, 20 Feb 2019 05:42:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbfBTFmX (ORCPT ); Wed, 20 Feb 2019 00:42:23 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:53934 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbfBTFmX (ORCPT ); Wed, 20 Feb 2019 00:42:23 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1K5XU5W108482; Wed, 20 Feb 2019 05:42:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=OtU0nPu5tplMNI87m3PEgv5h1nittP5KV8AyXTtzD54=; b=0UiaAPIKp8uk2j+1N0SMGbw5ZWwcF8ispJj7EQ5HFuv0/FGN/lMl17RlUH/gQwDHjKoq oY4hUGT1TKDYieSJlcFjp6zIQ0h9aw3U3wGbbil4/FFMBNTVu7QTgGpXPTR1K7s9mnUv bxmgVVc80R2zmUY7BKiyH5iDNB0zq3D6emsnNW0bXUMvFCqxhJ16PEA6SBxpl8xM1Uhl xoKX53OwpRfJ3SA91vmrhY1piHFRyFPoy34+xn69nZdIh3kmhrGguEtyExUwtCcucAEr 0dEfAvQXkpvcUBEh/Yrh1ASqU/3mVQi0yKncExz4TaZRNPKk4I+DyCLcsk2QXZXar4h/ gQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2qp9xtyc1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 05:42:09 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x1K5g9sA003741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 05:42:09 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1K5g72n019908; Wed, 20 Feb 2019 05:42:08 GMT Received: from kadam (/197.157.0.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 19 Feb 2019 21:42:07 -0800 Date: Wed, 20 Feb 2019 08:40:41 +0300 From: Dan Carpenter To: Sagi Grimberg , Israel Rukshin Cc: Max Gurtovoy , Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] IB/iser: Fix some error handling in iser_fast_reg_fmr() Message-ID: <20190220054041.GB25196@kadam> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9172 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902200039 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ib_sg_to_pages() function can return negative error codes. The problem with the error handling is that mem->dma_nents is a u32 so the comparison is type promoted to unsigned int. A negative error code thus becomes a large positive value and is treated as valid. Fixes: 57b26497fabe ("IB/iser: Pass the correct number of entries for dma mapped SGL ") Signed-off-by: Dan Carpenter Acked-by: Sagi Grimberg --- drivers/infiniband/ulp/iser/iser_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index 2ba70729d7b0..04a9b8f118df 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c @@ -240,7 +240,7 @@ int iser_fast_reg_fmr(struct iscsi_iser_task *iser_task, page_vec->fake_mr.page_size = SIZE_4K; plen = ib_sg_to_pages(&page_vec->fake_mr, mem->sg, mem->dma_nents, NULL, iser_set_page); - if (unlikely(plen < mem->dma_nents)) { + if (plen < 0 || plen < mem->dma_nents) { iser_err("page vec too short to hold this SG\n"); iser_data_buf_dump(mem, device->ib_device); iser_dump_page_vec(page_vec);