Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1354177imm; Tue, 2 Oct 2018 07:00:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV634KHBtGl4I6yt8oQffUTtOZtUfx12mu43FVsEwSMNokWlFdTPAZ2DmZs9kEMTGksaQ9isw X-Received: by 2002:a17:902:162:: with SMTP id 89-v6mr16726756plb.91.1538488846195; Tue, 02 Oct 2018 07:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538488846; cv=none; d=google.com; s=arc-20160816; b=k6MwlmSrTeMc7llO0fpw3W5bmQ+d2AhwaQeOC64kmifoE4H6u5zd4Oz5W3bugKXP5O rXX/ud00Ez4ZnNe1cfnTOFzUxki+oq9YauFm7LRuVnP3tlJbPGs18w5tNXMMSO0/f8HN ZbwoEb4UMt4VpkySXGGcjDjDssUb6AOTuyIjsNg3s4fh9EednBT7ZSvzR9NPaYJ+Dpza sSBpg9/WUF6PAIZ7GUAu4yYkF0EFDQ9QOz0sYWHstUl9xLmKE8sqcr/Xjya1CEK0naPw SmKc6BY9ZGhVaTCNNoo/mw6qM2htVzdRMqR+4xUjsPYNHWBMLYYolVT/jATmOZ3QXsYo BP9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=oXEfVVzNaXWMEBWqKG1QdjebcGbMteFw1jksVtGj2zA=; b=lcLXtAFhWylna16cpZPLun73zb0gb7WocZDy+XVuqGsGMb0YBAON82iUzYjzYDkzFd LyJsIyKo1dJEDPOwFcg5YmFKo0ILlA38qUjBQ+NA04UmMjBJ/zxny0cw5k3N3VWcf3gG KdCSwmXqtmzbfbKHjfH1CWRkuFnKX717k6RqndZKnkPhVy2rQIhP/XYFqyiEbJVAzUG2 BH1Kxxn0gjgtqYxQefBCqkf3m0MV+1cmr+zOX7spg4WZzOFVV8dTii8wdt3IBUqZHbYs fnfcwAQJMrbHAHP9vBwyWa09g/WUVgnfe16m59aAH1iXlv0zGrmD2z7IxJ3l6gj5YAQq jvJw== 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 u21-v6si14965778pgm.406.2018.10.02.07.00.30; Tue, 02 Oct 2018 07:00:46 -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 S1730674AbeJBUON (ORCPT + 99 others); Tue, 2 Oct 2018 16:14:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33804 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730643AbeJBUON (ORCPT ); Tue, 2 Oct 2018 16:14:13 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C4E25C3F; Tue, 2 Oct 2018 13:30:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve Wise , Jason Gunthorpe Subject: [PATCH 4.18 167/228] RDMA/uverbs: Atomically flush and mark closed the comp event queue Date: Tue, 2 Oct 2018 06:24:24 -0700 Message-Id: <20181002132510.031356150@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132459.032960735@linuxfoundation.org> References: <20181002132459.032960735@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steve Wise commit 67e3816842fe6414d629c7515b955952ec40c7d7 upstream. Currently a uverbs completion event queue is flushed of events in ib_uverbs_comp_event_close() with the queue spinlock held and then released. Yet setting ev_queue->is_closed is not set until later in uverbs_hot_unplug_completion_event_file(). In between the time ib_uverbs_comp_event_close() releases the lock and uverbs_hot_unplug_completion_event_file() acquires the lock, a completion event can arrive and be inserted into the event queue by ib_uverbs_comp_handler(). This can cause a "double add" list_add warning or crash depending on the kernel configuration, or a memory leak because the event is never dequeued since the queue is already closed down. So add setting ev_queue->is_closed = 1 to ib_uverbs_comp_event_close(). Cc: stable@vger.kernel.org Fixes: 1e7710f3f656 ("IB/core: Change completion channel to use the reworked objects schema") Signed-off-by: Steve Wise Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/uverbs_main.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -429,6 +429,7 @@ static int ib_uverbs_comp_event_close(st list_del(&entry->obj_list); kfree(entry); } + file->ev_queue.is_closed = 1; spin_unlock_irq(&file->ev_queue.lock); uverbs_close_fd(filp);