Received: by 10.192.165.148 with SMTP id m20csp2486622imm; Sun, 22 Apr 2018 08:02:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx48YUOfNGBhpnYetwbq+UBkRQZyAw1Qrnq7mY+v/ltkxWNjZmMWEGjpd+LPCfFojn6qr6QOr X-Received: by 10.99.2.202 with SMTP id 193mr14586488pgc.117.1524409370546; Sun, 22 Apr 2018 08:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409370; cv=none; d=google.com; s=arc-20160816; b=ncQ3QN2l7l+8lFzukUaKSMKA+8C+eu313Eb/USP5g2wLvNqFOHnFeb05kdHKtjcolx lKSaoEvRiBoCbYHruxg+gJcjre3AIBWQuoEhkDLOK7CcqXYtg608gnqTMrTz7lpL5uHr A6dum6th/vIgOUkP3ysfYa1rsODyQm/e2JByMzWmkhocIt1sfRogJlERPw175YrcVzwd DusZtl7dJSA4TSws68fe7Gs47Aqfo9RODaF4gPHiQKRzCvvKBjrrn0Mh9Q0ztQ1LUChC 3WNLcll5y1KPB7qRS4nCaFR0EX4rjoPpkxMaLe6Ls/XemYFuC7AmyAlBXNm9RDsZTU3v 7N+w== 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=KPPjpkGaF5uhXN4k/fO90ky+OVQA/lF6e1+NGpj8rpA=; b=Hf3QUan13eTcLSMkjxfnTgsnPVP0Vf0LJ1GRd4hLAU+2qqL9/fJbfUXir5cUrE3qZg T0+zey9200fDF97t8BmwkyfGmdh2cmT7U+SgwSETyDxYXVTNuUAZ8aKagjrTmvNOa56M q3jjqKvBlqJACWveq9FH2/zWZMHE080zfC1V/YpCvNJn3IESe+d2GUAyrb1HnIWW+FfV PB9xGiqL6hB2plkSSjydbKCanSG/+yBkUyhALdmj6P/FILDRbOfpy2eWB1tdfbZNItOm DD+dxrfxeTz9uS3WlPgc3mVGqyfFbHj5tl1aUkB9jxZAziTa7K50yG2BGpakTLEFC0ed 3Grw== 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 z79si9854368pfa.120.2018.04.22.08.02.36; Sun, 22 Apr 2018 08:02:50 -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 S1756737AbeDVOMr (ORCPT + 99 others); Sun, 22 Apr 2018 10:12:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55102 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755657AbeDVOMb (ORCPT ); Sun, 22 Apr 2018 10:12:31 -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 D9194C97; Sun, 22 Apr 2018 14:12:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Moni Shoua , Jason Gunthorpe Subject: [PATCH 4.9 40/95] RDMA/rxe: Fix an out-of-bounds read Date: Sun, 22 Apr 2018 15:53:09 +0200 Message-Id: <20180422135212.060555766@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche commit a6544a624c3ff92a64e4aca3931fa064607bd3da upstream. This patch avoids that KASAN reports the following when the SRP initiator calls srp_post_send(): ================================================================== BUG: KASAN: stack-out-of-bounds in rxe_post_send+0x5c4/0x980 [rdma_rxe] Read of size 8 at addr ffff880066606e30 by task 02-mq/1074 CPU: 2 PID: 1074 Comm: 02-mq Not tainted 4.16.0-rc3-dbg+ #1 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+0x5c4/0x980 [rdma_rxe] srp_post_send.isra.16+0x149/0x190 [ib_srp] srp_queuecommand+0x94d/0x1670 [ib_srp] scsi_dispatch_cmd+0x1c2/0x550 [scsi_mod] scsi_queue_rq+0x843/0xa70 [scsi_mod] blk_mq_dispatch_rq_list+0x143/0xac0 blk_mq_do_dispatch_ctx+0x1c5/0x260 blk_mq_sched_dispatch_requests+0x2bf/0x2f0 __blk_mq_run_hw_queue+0xdb/0x160 __blk_mq_delay_run_hw_queue+0xba/0x100 blk_mq_run_hw_queue+0xf2/0x190 blk_mq_sched_insert_request+0x163/0x2f0 blk_execute_rq+0xb0/0x130 scsi_execute+0x14e/0x260 [scsi_mod] scsi_probe_and_add_lun+0x366/0x13d0 [scsi_mod] __scsi_scan_target+0x18a/0x810 [scsi_mod] scsi_scan_target+0x11e/0x130 [scsi_mod] srp_create_target+0x1522/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:ffffea0001998180 count:0 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0x4000000000000000() raw: 4000000000000000 0000000000000000 0000000000000000 00000000ffffffff raw: dead000000000100 dead000000000200 0000000000000000 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff880066606d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 ffff880066606d80: f1 00 f2 f2 f2 f2 f2 f2 f2 00 00 f2 f2 f2 f2 f2 >ffff880066606e00: f2 00 00 00 00 00 f2 f2 f2 f3 f3 f3 f3 00 00 00 ^ ffff880066606e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff880066606f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ================================================================== Fixes: 8700e3e7c485 ("Soft RoCE driver") Signed-off-by: Bart Van Assche Cc: Moni Shoua Cc: stable@vger.kernel.org Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/rxe/rxe_verbs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -747,9 +747,8 @@ static int init_send_wqe(struct rxe_qp * memcpy(wqe->dma.sge, ibwr->sg_list, num_sge * sizeof(struct ib_sge)); - wqe->iova = (mask & WR_ATOMIC_MASK) ? - atomic_wr(ibwr)->remote_addr : - rdma_wr(ibwr)->remote_addr; + wqe->iova = mask & WR_ATOMIC_MASK ? atomic_wr(ibwr)->remote_addr : + mask & WR_READ_OR_WRITE_MASK ? rdma_wr(ibwr)->remote_addr : 0; wqe->mask = mask; wqe->dma.length = length; wqe->dma.resid = length;