Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1143400imm; Wed, 1 Aug 2018 10:54:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe3XEUpK3D59MMelsPNgWxt/3/AauBTWSDzA1DrmeiccScN98/T8dxluy+oSyXVO9eRfCo/ X-Received: by 2002:a62:384:: with SMTP id 126-v6mr27718873pfd.11.1533146085772; Wed, 01 Aug 2018 10:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146085; cv=none; d=google.com; s=arc-20160816; b=ilO6yzwWBlJB7OfvwEnaw+9+VtWod6Iw+RquLRwlVIUMt2nPsWWZWEIvJs7Y8CUU/L 7Ifqg2w1MKa5Zs8h7RdwmqaUWTXtWqSNC8UHQXEdamP7mAB2jy4ygQ0316vFVKbDI1ow dhCIkNWfgJRM6MVtJjlDz6E8L8S/dvo33H/9qfHAJJOpBHyKkhWj5s/3gMw383Rl8gwe NJRPeGaRUwNgUympuhBHg3CUOLTXsoCp9B8Fuy8TJgDkjlA5Lf16yfONj36IQC7Z4O4C nIbxegEdZOYidqK1xgXjdVuRdifzGtMYgaY50fZ2GKYa7Z1x+YCTDHkLFot8FPyE+siD YNNw== 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=elzIDdXZLdxoq0fd0ZRFPsjYqpgzUKMXmUQxJTnd+8I=; b=XTtof8pIlsy+B9GCHBsUx90qdYrsxHbJxqp+PCrgH35GSv6NhI1JVUgpZ8jC3ru+ZM PT2rdL8g7czEKYRNREcOp4S8BOBrCZKohBx3AopqwksTqWYl6xlMoNEHXuQ3hY8i45y/ 4PjLa4dslU+dOHNrwqeGTDcm5tTpWBS1vFcGjf8XaaITS3U4ksZv26xYpSw9NWXgoO5x wRwH1T53cU/f9hh5ci3gMB0NnQKGmKn2+ovY13V9Zh8E1SrP2eEQr07S28YJyhXQTFMw MIhzfkEw2L7GOrnYFURr+085Y/eFdICS0r3Y3+hM7R7ykB2hc070gy0v9z71LuoPjNYI 3vPw== 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 s23-v6si16867305pgs.499.2018.08.01.10.54.31; Wed, 01 Aug 2018 10:54:45 -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 S2406030AbeHATIl (ORCPT + 99 others); Wed, 1 Aug 2018 15:08:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50156 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405941AbeHATIj (ORCPT ); Wed, 1 Aug 2018 15:08:39 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 839EF133D; Wed, 1 Aug 2018 17:12:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Steve Wise , Sagi Grimberg , Jason Gunthorpe , Sudip Mukherjee Subject: [PATCH 4.14 003/246] RDMA/core: Avoid that ib_drain_qp() triggers an out-of-bounds stack access Date: Wed, 1 Aug 2018 18:48:33 +0200 Message-Id: <20180801165011.873241917@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 a1ae7d0345edd593d6725d3218434d903a0af95d upstream. This patch fixes the following KASAN complaint: ================================================================== BUG: KASAN: stack-out-of-bounds in rxe_post_send+0x77d/0x9b0 [rdma_rxe] Read of size 8 at addr ffff880061aef860 by task 01/1080 CPU: 2 PID: 1080 Comm: 01 Not tainted 4.16.0-rc3-dbg+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 Call Trace: dump_stack+0x85/0xc7 print_address_description+0x65/0x270 kasan_report+0x231/0x350 rxe_post_send+0x77d/0x9b0 [rdma_rxe] __ib_drain_sq+0x1ad/0x250 [ib_core] ib_drain_qp+0x9/0x30 [ib_core] srp_destroy_qp+0x51/0x70 [ib_srp] srp_free_ch_ib+0xfc/0x380 [ib_srp] srp_create_target+0x1071/0x19e0 [ib_srp] kernfs_fop_write+0x180/0x210 __vfs_write+0xb1/0x2e0 vfs_write+0xf6/0x250 SyS_write+0x99/0x110 do_syscall_64+0xee/0x2b0 entry_SYSCALL_64_after_hwframe+0x42/0xb7 The buggy address belongs to the page: page:ffffea000186bbc0 count:0 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0x4000000000000000() raw: 4000000000000000 0000000000000000 0000000000000000 00000000ffffffff raw: 0000000000000000 ffffea000186bbe0 0000000000000000 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff880061aef700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff880061aef780: 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 >ffff880061aef800: f2 f2 f2 f2 f2 f2 f2 00 00 00 00 00 f2 f2 f2 f2 ^ ffff880061aef880: f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 f2 f2 ffff880061aef900: f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00 00 ================================================================== Fixes: 765d67748bcf ("IB: new common API for draining queues") Signed-off-by: Bart Van Assche Cc: Steve Wise Cc: Sagi Grimberg Cc: stable@vger.kernel.org Signed-off-by: Jason Gunthorpe Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/verbs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -2115,10 +2115,15 @@ static void __ib_drain_sq(struct ib_qp * struct ib_cq *cq = qp->send_cq; struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR }; struct ib_drain_cqe sdrain; - struct ib_send_wr swr = {}, *bad_swr; + struct ib_send_wr *bad_swr; + struct ib_rdma_wr swr = { + .wr = { + .opcode = IB_WR_RDMA_WRITE, + .wr_cqe = &sdrain.cqe, + }, + }; int ret; - swr.wr_cqe = &sdrain.cqe; sdrain.cqe.done = ib_drain_qp_done; init_completion(&sdrain.done); @@ -2128,7 +2133,7 @@ static void __ib_drain_sq(struct ib_qp * return; } - ret = ib_post_send(qp, &swr, &bad_swr); + ret = ib_post_send(qp, &swr.wr, &bad_swr); if (ret) { WARN_ONCE(ret, "failed to drain send queue: %d\n", ret); return;