Received: by 10.223.185.116 with SMTP id b49csp4192136wrg; Mon, 26 Feb 2018 12:55:27 -0800 (PST) X-Google-Smtp-Source: AH8x227BNT3LdXsKuXxe122fpkk1lCzcIJJJkgGmXmjNKIG4dpsr5+veb4a9+Pz9J828moFB5pE5 X-Received: by 2002:a17:902:6ac2:: with SMTP id i2-v6mr11634180plt.368.1519678527508; Mon, 26 Feb 2018 12:55:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519678527; cv=none; d=google.com; s=arc-20160816; b=ICqi1iou1dq/pS7Z/tXvWEW7+4Ds1Z+8SkVktbf9DUDuCVGGXSeIPJ83Iil50KgaE8 4gL4d2+OfJF0VVNvbAGJQf0wMBoWpvQH6NrGYG7eXR/1nwvmg//tJ+/Vu8pT8v5rUGKd Qq8RW2R8aKOhZzEBvmMfZXSsXQQlcxKth1VqFitrcrr/757HGUSFa1VezBaGnPbjvXc4 XP9Z1LEZyvl6WjN8biuhyaiZH6jLjFU4i0HKANFtvi4HC1Z98BmydEfYzXy9UaqlJqBT eKeXt6EJ+KXwFezjSI+8+J4TEkWIlvCsdNK4GSLHHDke+h1AXjCE6c8lATrKuE+fI65R ge4g== 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=aeLHPEAGsdDSrI5SzJOEATyOYnbhnwJG2Dhr5t8StZM=; b=YhWrauf8nv1Wcs32OYXLcrJPgTXqaQp6NuLWujrW8B6nPbfD5c8dRoHBoKMmHyFn2m 0wYmLXeYIivIgO4JYtktb/jea0nxUrwuwU4U8azvZjgSu8QC9ett076+DRrcaPtemMOM STEVc0SqMJbU69oOFtOGzMKR0s+ywm05wXGTpybbCLGaO0MWhhE2jgg20gWxg1aHrW84 8XHBKm04+JKhsvCIv+C4vwxxVsoWlkLDhjBXmCO/dVq6yUgW1r+BeDhJdgNDyDzCHf0H pIHy187AsneVPfe0dDjdgg3/gYTjkMsDt6y7TMZk3vtKO/Z0Blb7pLtfDEzvoMwq6+qw akTw== 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 g7si5918430pgs.411.2018.02.26.12.55.11; Mon, 26 Feb 2018 12:55:27 -0800 (PST) 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 S1750915AbeBZUXq (ORCPT + 99 others); Mon, 26 Feb 2018 15:23:46 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34882 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752720AbeBZUXl (ORCPT ); Mon, 26 Feb 2018 15:23:41 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 03FF1F47; Mon, 26 Feb 2018 20:23:40 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzkaller , Noa Osherovich , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 4.14 18/54] RDMA/uverbs: Fix bad unlock balance in ib_uverbs_close_xrcd Date: Mon, 26 Feb 2018 21:21:55 +0100 Message-Id: <20180226202145.283400276@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202144.375869933@linuxfoundation.org> References: <20180226202144.375869933@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: Leon Romanovsky commit 5c2e1c4f926856717f3fd31932e926dc3fe77ebd upstream. There is no matching lock for this mutex. Git history suggests this is just a missed remnant from an earlier version of the function before this locking was moved into uverbs_free_xrcd. Originally this lock was protecting the xrcd_table_delete() ===================================== WARNING: bad unlock balance detected! 4.15.0+ #87 Not tainted ------------------------------------- syzkaller223405/269 is trying to release lock (&uverbs_dev->xrcd_tree_mutex) at: [<00000000b8703372>] ib_uverbs_close_xrcd+0x195/0x1f0 but there are no more locks to release! other info that might help us debug this: 1 lock held by syzkaller223405/269: #0: (&uverbs_dev->disassociate_srcu){....}, at: [<000000005af3b960>] ib_uverbs_write+0x265/0xef0 stack backtrace: CPU: 0 PID: 269 Comm: syzkaller223405 Not tainted 4.15.0+ #87 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 Call Trace: dump_stack+0xde/0x164 ? dma_virt_map_sg+0x22c/0x22c ? ib_uverbs_write+0x265/0xef0 ? console_unlock+0x502/0xbd0 ? ib_uverbs_close_xrcd+0x195/0x1f0 print_unlock_imbalance_bug+0x131/0x160 lock_release+0x59d/0x1100 ? ib_uverbs_close_xrcd+0x195/0x1f0 ? lock_acquire+0x440/0x440 ? lock_acquire+0x440/0x440 __mutex_unlock_slowpath+0x88/0x670 ? wait_for_completion+0x4c0/0x4c0 ? rdma_lookup_get_uobject+0x145/0x2f0 ib_uverbs_close_xrcd+0x195/0x1f0 ? ib_uverbs_open_xrcd+0xdd0/0xdd0 ib_uverbs_write+0x7f9/0xef0 ? cyc2ns_read_end+0x10/0x10 ? ib_uverbs_open_xrcd+0xdd0/0xdd0 ? uverbs_devnode+0x110/0x110 ? cyc2ns_read_end+0x10/0x10 ? cyc2ns_read_end+0x10/0x10 ? sched_clock_cpu+0x18/0x200 __vfs_write+0x10d/0x700 ? uverbs_devnode+0x110/0x110 ? kernel_read+0x170/0x170 ? __fget+0x358/0x5d0 ? security_file_permission+0x93/0x260 vfs_write+0x1b0/0x550 SyS_write+0xc7/0x1a0 ? SyS_read+0x1a0/0x1a0 ? trace_hardirqs_on_thunk+0x1a/0x1c entry_SYSCALL_64_fastpath+0x1e/0x8b RIP: 0033:0x4335c9 Cc: syzkaller Cc: # 4.11 Fixes: fd3c7904db6e ("IB/core: Change idr objects to use the new schema") Reported-by: Noa Osherovich Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/uverbs_cmd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -606,10 +606,8 @@ ssize_t ib_uverbs_close_xrcd(struct ib_u uobj = uobj_get_write(uobj_get_type(xrcd), cmd.xrcd_handle, file->ucontext); - if (IS_ERR(uobj)) { - mutex_unlock(&file->device->xrcd_tree_mutex); + if (IS_ERR(uobj)) return PTR_ERR(uobj); - } ret = uobj_remove_commit(uobj); return ret ?: in_len;