Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1150884imm; Wed, 1 Aug 2018 11:02:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdGkBtX5KSbxKUHozQkBGVYjECZxpHW1CgT3OVEZFTkk10L/1IIxRYtgaE0W5FFNedOKh0a X-Received: by 2002:a63:1015:: with SMTP id f21-v6mr25825828pgl.354.1533146525543; Wed, 01 Aug 2018 11:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146525; cv=none; d=google.com; s=arc-20160816; b=PJ3JtvkGnz1MgNoaUg/Yab0Ld3cBmG2lDKEprvMKK8SV1OTCeAthp/K6owyH/RuLs0 WxsKoo1qBXsjJH+FP43HOGIxhaeEI2qzGNyOxBBHngjDkXBHSY90766zaVh9N2fIKIoL bFN4wjbr9NCh2R6+MbQ6AJHo3CAh8gE7eBxmscQtMOD/Tm3HpijsYqpMlVEmvv3f1KJT QrPFuh2z1zMMFG8wHsEd+yTdA/LjusbZWz2VxhqQQ+7QTO/4ZagdTrigrlhYx2c5FRIg rdUhPEfFjBNOdx7FLWDukXJvrW1oFYAIyoQfjd+D8CimJZiDhLuAScrz80Zb2wFSeEB5 RxIA== 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=B0WTaSSZBez7BTu2Q8iUMBV0ATUGjShTvovl0mVJDzc=; b=Fp4sEq9ndG1S0ypb0NE2Qi2LB+9nt08aXGs0eIacA5cUgYu2EBA0o7T/nR4ZI/VBbi PwfwPrgQCsDIo8o5CsiEC5p2bF5uipfK9MZZlHItxNfR2qiUYSP9PQe2Um1U3QuQUgMd tkqeAHkWj/9W7ACmLczeMCkh35rmRgoGM+GspZ3znrY0Rfm5dL9lMALf9t0Kb0lpWjjS ahpEybFPDUBALYNcuVYn/xeCmK3fFkYBlQhs3JMqvhwo08fOV63PMnb673Q+R1vm+M5z JZpEIfMLAEVs0b3TBQSGLMMp2qEbpzFlEI11SMipqnB6oDeeFSctCLsuHGbJpbo/5+pZ AyPw== 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 j85-v6si18307336pfa.232.2018.08.01.11.01.51; Wed, 01 Aug 2018 11:02:05 -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 S2405909AbeHATIi (ORCPT + 99 others); Wed, 1 Aug 2018 15:08:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50216 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405728AbeHATIf (ORCPT ); Wed, 1 Aug 2018 15:08:35 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C58831340; Wed, 1 Aug 2018 17:12:29 +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 , Sudip Mukherjee Subject: [PATCH 4.14 005/246] IB/srpt: Fix an out-of-bounds stack access in srpt_zerolength_write() Date: Wed, 1 Aug 2018 18:48:35 +0200 Message-Id: <20180801165011.956055366@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@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.14-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: Sudip Mukherjee 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 @@ -787,13 +787,16 @@ 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, + } + }; - 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)