From patchwork Wed Oct 23 06:53:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 3086161 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C1351BF924 for ; Wed, 23 Oct 2013 06:53:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DC5F202C3 for ; Wed, 23 Oct 2013 06:53:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3796B202E5 for ; Wed, 23 Oct 2013 06:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751375Ab3JWGxd (ORCPT ); Wed, 23 Oct 2013 02:53:33 -0400 Received: from mail-ea0-f173.google.com ([209.85.215.173]:41544 "EHLO mail-ea0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751051Ab3JWGxd (ORCPT ); Wed, 23 Oct 2013 02:53:33 -0400 Received: by mail-ea0-f173.google.com with SMTP id g10so169472eak.32 for ; Tue, 22 Oct 2013 23:53:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V3Su7HEPIS4GFdVHgFID/7GAXxBfIUWoWjeaTJWOZKY=; b=OzqL9/1o6x7hR2j9Wm4pdEMnQwNiGqYA1iEabYhfek2KSXweyeQ4FB/z6TMkCGJGmm Ma3nHYIyBTLqSaScHeqH/jc3oDyMpvvXP3cv0Dxwz6RSRgjaGwhHg06z6k/364QSZnzF 98TiR+0uoLIzeHLU01wgN40h1NtUBAcp8jT2Vb5sC2jhQ2+2I8aqxo5yzN/+FutUaBED Mp8jXdTUocdC/Y7Mj38SDhXJfrd2jYOAtsovAK8EQJUnkqKmebpetrxF7EyPr0tbfKo4 HFKANYZn5TevUqOjYfi2w+02yBPQbp3XnMNQGCzSzsHU79QNwapChfL3oSkPPiZs3/cb 7Pig== X-Gm-Message-State: ALoCoQk3Rt/x/32w6cUR0qzHQbUfSTrR02baKdSHCP1s44mHEA8iBP/Nre5bJX2bPwXOjE1ucu1T X-Received: by 10.15.98.9 with SMTP id bi9mr17262eeb.67.1382511212002; Tue, 22 Oct 2013 23:53:32 -0700 (PDT) Received: from localhost (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id h45sm66249531eeg.5.2013.10.22.23.53.31 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Oct 2013 23:53:31 -0700 (PDT) From: Eli Cohen To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, amirv@mellanox.com, ogerlitz@mellanox.com, yevgenyp@mellanox.com, Eli Cohen Subject: [PATCH for-next 3/9] IB/mlx5: Fix overflow check in IB_WR_FAST_REG_MR Date: Wed, 23 Oct 2013 09:53:15 +0300 Message-Id: <1382511201-7061-4-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1382511201-7061-1-git-send-email-eli@mellanox.com> References: <1382511201-7061-1-git-send-email-eli@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure not to overflow when reading the page list from struct ib_fast_reg_page_list. Signed-off-by: Eli Cohen --- drivers/infiniband/hw/mlx5/qp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index e388143..8a36fd7 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -1915,6 +1915,10 @@ static int set_frwr_li_wr(void **seg, struct ib_send_wr *wr, int *size, if (unlikely((*seg == qp->sq.qend))) *seg = mlx5_get_send_wqe(qp, 0); if (!li) { + if (unlikely(wr->wr.fast_reg.page_list_len > + wr->wr.fast_reg.page_list->max_page_list_len)) + return -ENOMEM; + set_frwr_pages(*seg, wr, mdev, pd, writ); *seg += sizeof(struct mlx5_wqe_data_seg); *size += (sizeof(struct mlx5_wqe_data_seg) / 16);