Received: by 10.192.165.148 with SMTP id m20csp2529209imm; Sun, 22 Apr 2018 08:57:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+y+CkWxt4PStbP3qXxJVYbaFURuQb4KAorwVylPdteyhe2B2Wdh+ixu7z4Sm/XqNocUidN X-Received: by 10.98.4.133 with SMTP id 127mr16977602pfe.26.1524412632938; Sun, 22 Apr 2018 08:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412632; cv=none; d=google.com; s=arc-20160816; b=oOI0R52JCy9ZAsHw9lDcmG3a8Xdy5VLdOYLdYBOqB6RQFz6wn+nmhcLJ9+Xd1fgXD8 ITFEq0CtiEx01ABVhJfRt1uRRmIwTOQaaPD0LZ2YTRdWXtZ/sPpM9Yzn2jdQ33cbLoiH fJ3cRJQixBordqU7l+phpWzJ47kQ/Z4Is9+/Pu880DUmnnpjuML3y1c06Hqi70qaU/xq P8Lgitv1MlCSDUO2dOqJaUSqMeu7REbWdpEzfgGe9ezZ1O3zgS6m8gPv2G5Ha5URwY+s 0kyaHxVglDHxKhjCCoOx8J1ykff5LoL9wLwPGj6G7rGeSSZ64xOvfvGUu7cnppr3PH96 qivQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mAPnNuH3+5SCX3L4yChw/Iu0jQ8+KYI9P4QXmFfyO5s=; b=UvIVJ3zAI0z3I8AsdYgB5gH9Ga7n80hSKAs7SToZPKCupm9GqUruGj9weW/6G6rj7W KF4x5XPun9eiMAgO0LiUQmgRkLsQ1Jvby2WK9gd1676RRZWzLlmu8iOU1Z41yymd2U6g lRFZBFzsYQzmcnV2DKgo9XAi6FqBi4zrgQJjd2Q0CNhroMrImkM/ICMSdfwFnzPDp0IN NGjgDUFuidQD9Wkg1n4hokW6rYF92WVkUlV6oUdmtER4BJVe/EFwQBWpMNwMyd6J8JaL 58zEFJ9jv3DXTmgFfvpuQxDvFdgpoTFtvj/HKmarw0odQiZFB32KlA/aWyXCi4W7WI2K K58Q== 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 n6-v6si10135457pla.12.2018.04.22.08.56.58; Sun, 22 Apr 2018 08:57:12 -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 S1754403AbeDVN7l (ORCPT + 99 others); Sun, 22 Apr 2018 09:59:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46924 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753720AbeDVN7c (ORCPT ); Sun, 22 Apr 2018 09:59:32 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BC33E412; Sun, 22 Apr 2018 13:59:31 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Christoph Hellwig , Jason Gunthorpe Subject: [PATCH 4.16 115/196] IB/srpt: Fix an out-of-bounds stack access in srpt_zerolength_write() Date: Sun, 22 Apr 2018 15:52:15 +0200 Message-Id: <20180422135110.211098751@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche commit 2a78cb4db487372152bed2055c038f9634d595e8 upstream. Avoid triggering an out-of-bounds stack access by changing the type of 'wr' from ib_send_wr into ib_rdma_wr. This patch fixes the following KASAN bug report: BUG: KASAN: stack-out-of-bounds in rxe_post_send+0x7a9/0x9a0 [rdma_rxe] Read of size 8 at addr ffff880068197a48 by task kworker/2:1/44 Workqueue: ib_cm cm_work_handler [ib_cm] Call Trace: dump_stack+0x8e/0xcd print_address_description+0x6f/0x280 kasan_report+0x25a/0x380 __asan_load8+0x54/0x90 rxe_post_send+0x7a9/0x9a0 [rdma_rxe] srpt_zerolength_write+0xf0/0x180 [ib_srpt] srpt_cm_rtu_recv+0x68/0x110 [ib_srpt] srpt_rdma_cm_handler+0xbb/0x15b [ib_srpt] cma_ib_handler+0x1aa/0x4a0 [rdma_cm] cm_process_work+0x30/0x100 [ib_cm] cm_work_handler+0xa86/0x351b [ib_cm] process_one_work+0x475/0x9f0 worker_thread+0x69/0x690 kthread+0x1ad/0x1d0 ret_from_fork+0x3a/0x50 Fixes: aaf45bd83eba ("IB/srpt: Detect session shutdown reliably") Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: stable@vger.kernel.org Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/ulp/srpt/ib_srpt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -838,16 +838,19 @@ static int srpt_post_recv(struct srpt_de */ static int srpt_zerolength_write(struct srpt_rdma_ch *ch) { - struct ib_send_wr wr, *bad_wr; + struct ib_send_wr *bad_wr; + struct ib_rdma_wr wr = { + .wr = { + .opcode = IB_WR_RDMA_WRITE, + .wr_cqe = &ch->zw_cqe, + .send_flags = IB_SEND_SIGNALED, + } + }; pr_debug("%s-%d: queued zerolength write\n", ch->sess_name, ch->qp->qp_num); - memset(&wr, 0, sizeof(wr)); - wr.opcode = IB_WR_RDMA_WRITE; - wr.wr_cqe = &ch->zw_cqe; - wr.send_flags = IB_SEND_SIGNALED; - return ib_post_send(ch->qp, &wr, &bad_wr); + return ib_post_send(ch->qp, &wr.wr, &bad_wr); } static void srpt_zerolength_write_done(struct ib_cq *cq, struct ib_wc *wc)