Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1342414imm; Tue, 2 Oct 2018 06:49:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV62XGO8emHNTXMMMSf6M6o0tKw6lQvTV9bPmdLDpSJ4efN6QGPKsJi880Gwpnrien252IWNw X-Received: by 2002:a17:902:6ac7:: with SMTP id i7-v6mr17111735plt.268.1538488177371; Tue, 02 Oct 2018 06:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538488177; cv=none; d=google.com; s=arc-20160816; b=NNAd1u1vd9OtASuET9bL7RffH8/gVwxwRPt1Zw45YnIKXh6+uTl8EZfCD6DWqxViCV FHEbfmin3hfeW2PQqMyueGo2tdYotZCUleb6KYvlHGYCt75PGPFKlFzb5jTt6eenGjEY fAiv54oMRCm3E+K26hzHl+FMHxL9sf+CwiR5BGoj9mpB/veGzbjFnm2QKfcWllrJF3UH a77bXNS5572q6JsfU5N23N1TVxpAc//5sQtTPhmnBaWo6lipZctRxflqulmhqpRjDJxn 9oDxrSmZKfKpomlSVlYJ086dkolDRrGp/aAwUenx7I5hOV2ca4LVdXWCCQLpsaEraG8R XRvA== 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=R0oDILEfMxtK05dFMJXuJ8unvPv7bU47cb7swJt67dU=; b=PBEytlkBv5ya03R8y6AT8sl4/ru6Nb/h1oWnFifA0l9S5OqXwZuCCgO6j6plIC0FuF oPE0roHpfrG10/+268g4OSeIABM/+Gkz7aXyp6URYlUpx5WiS0PGwAzEvN5ytowGAnb6 cCCo3HqPmmLx10xeQiNatJESlUP6j4YTDcY0+qX3Szt2db5yaKHt9vzwSV8xg/XaRv3M nLLu9AzIHXboo6EBGxMVEbOBRCeTprku6C+C2B41B6YzRoVCYzR751ulgizV1dLQKDOY wKkyFm+cHUv2NUBSM5OGO6y+1hgNWFQOKxCXbHU2+FDyJsl4gd7E2Ynx86GyoiY2jO7R mVWA== 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 d41-v6si15898592pla.172.2018.10.02.06.49.23; Tue, 02 Oct 2018 06:49:37 -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 S1732250AbeJBURo (ORCPT + 99 others); Tue, 2 Oct 2018 16:17:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35270 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729661AbeJBURn (ORCPT ); Tue, 2 Oct 2018 16:17:43 -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 AFFDCB2F; Tue, 2 Oct 2018 13:34:19 +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.14 108/137] RDMA/uverbs: Atomically flush and mark closed the comp event queue Date: Tue, 2 Oct 2018 06:25:09 -0700 Message-Id: <20181002132506.066559052@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132458.446916963@linuxfoundation.org> References: <20181002132458.446916963@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.14-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 @@ -424,6 +424,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);