Received: by 10.223.185.116 with SMTP id b49csp4183594wrg; Mon, 26 Feb 2018 12:44:39 -0800 (PST) X-Google-Smtp-Source: AG47ELs0qDhWiMTPQJsbWdVD1623SWkW2YVhp/s/KvbZz8/TxI9z3FW2IWTJgnqMfTxBuD9BYCVR X-Received: by 10.99.55.11 with SMTP id e11mr7874878pga.237.1519677879603; Mon, 26 Feb 2018 12:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519677879; cv=none; d=google.com; s=arc-20160816; b=bQ/YcqTI0wjddtKgNjTfqXprap8ZqGCliDx6eXQ5L8/2xyLEWWY/zrI9YTHS0YGI2z Djw/UkvYmY+0UNDsdPfBWyi0HoP5gOwg3a7+7YgyIgyZNuFFL8ma0lU/gC+SvMFHLUwC vgMqCKcGOC+w7EJIXV3ikCFkwXKSqciXdzf0fKZTQfMGxFkHz6L7pqTZi00RGbMOryu2 s3VN8WKoFU66dL0cuSYG39BG8YuRQUhHBBqTmXblddVac+TaW1+ZI5PB79mxPd+EZkix R1Zt0nuIcPxa9DIt2gjgVtzVk3N5ds/Pgr36Q/E8FE85NEIC5CF1TILa8KjrG6KRlby1 FdtQ== 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=WNUJVqCZ4RhFb8aVN2TumGfjg7lS9E66mFs4tmrWe1A=; b=f3W2w8VOkXjFN8bIuk2qkm3GtEAgCU0v/j+DRiUYFORj0KoqZOSAOSM89W1uh4rTmC 3b6oV8orTwtQObmmJIRJutMeYFleGyTgJOd3RTiOxtZJ7WUbk29LjBjN1VG+8XnZo2tH gbzlZDt49aJaOdAmfUSmjGMWF99xaiGElhRCPDjaWz45cDcw1vdwTyGALOUR+8KdLwsF besmDZLW1+uf6UQaVC/+IcuZF/79iZVP848uZr0YIAuWj7lyqhNbktDWdmyeIlJbIgUW oPGAjCy0XiEjUjcpgEtA43/AROC/ADpSG+6L9d4wt7pGe+f2oNiNcUFXBpn469lyiVKL X9SQ== 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 o6-v6si7179710plh.287.2018.02.26.12.44.23; Mon, 26 Feb 2018 12:44:39 -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 S1753487AbeBZU0i (ORCPT + 99 others); Mon, 26 Feb 2018 15:26:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35774 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753389AbeBZU0h (ORCPT ); Mon, 26 Feb 2018 15:26:37 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7F7C8FAD; Mon, 26 Feb 2018 20:26:36 +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.15 19/64] RDMA/uverbs: Fix bad unlock balance in ib_uverbs_close_xrcd Date: Mon, 26 Feb 2018 21:21:56 +0100 Message-Id: <20180226202154.269947760@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202153.453363333@linuxfoundation.org> References: <20180226202153.453363333@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.15-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 @@ -601,10 +601,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;