Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp719741pxb; Tue, 2 Feb 2021 16:37:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+9finzz3diScDODSmDxp+dojKnv2yt0y02khQa+zc23dqrS2exMduJHZdKIiq/XY1+gD4 X-Received: by 2002:aa7:c3cf:: with SMTP id l15mr631974edr.98.1612312652631; Tue, 02 Feb 2021 16:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612312652; cv=none; d=google.com; s=arc-20160816; b=BmDN5WeHOYkIUUWSJhyWY0ySEDqlgehI0rnKQqL+HwggMbbU2XQKZI81lFHBAsC295 05vMOq9CtWjrZv8eB7atqBCL4fwq68XCe/90HVtNUJLqSNmwKPCDXiE5O8TiWLTqwK+Z whmdFZOiYMI4Uqv4jiVoeAPnGouLbl6w0Hmvv0SOcce4W7Trmjd0BTaiw5d3gKgp8X4c cRVJ1dOfmGMVDdN0M1INj7UhgcR7JrVLpQ5saGA5WjJxsrssAT4ueppJlA17hvp4Jkf1 zG1vaIJke8qGOO2V+3gywT8raiSBIY9X1F+lSyrGwBIZQztri8ucuT2Az++DS4mYzhF8 aMPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UYDOS53hs8HzCTinab7geQLhmawcgHgTvS4RgOPnRL0=; b=akt+J4MSZYGTinuwsKDnJ5biLSymfslsO/KXH5KVBUoqBdQCU/5e0mftiw/M5SJ8x3 8Msf510U04eK9/O/GB/mbyodIX9F5lR1vDN19uFYqU9x9TPqyz2Qw3GMD+SZzg7tMcNl 7Lt49kyYWe7R88pM5FHNSvXHZwJk8w09mTMqXTakuS06zG5kCgDhAXz7yFKpJAfD6OVv qj15fYOZb6Y/wHVldyTc4r0eTDERXiSpe3K0WlhvjjgTr0eKFw8i9CIr97kxh6O8OsBV HNfx6i1a8Dc+xx0Dr/qDZ1pbzroHcV0ydJ1tLU49vFaLdt/foQak/JSqFn9OBqucdtFW 0/tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gLm9Heee; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si249103edr.533.2021.02.02.16.37.08; Tue, 02 Feb 2021 16:37:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gLm9Heee; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbhBBSWp (ORCPT + 99 others); Tue, 2 Feb 2021 13:22:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:48062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233656AbhBBOGR (ORCPT ); Tue, 2 Feb 2021 09:06:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B00D86501C; Tue, 2 Feb 2021 13:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273752; bh=5Kc68jgGpp2v6m5yFO3qY47FpUvQ3a1gekEUHnUOkD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gLm9HeeehJzEeUT2DQwc7tV8QgzrrNr5qsw4JReAY84hx7SgninxIGmrQGZDPzslw lbQNlQlffCaKzQ6TKlr0HIRIoAwHA9kbLk/OAgj2+k1l4r8eviXjt5g1LnoUaHlcYA Ltd8Cc4u6DiTu2Om2yz93XdIEhDqn944Y+IhBotM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Thomas Gleixner , Ingo Molnar , "Peter Zijlstra (Intel)" , Lee Jones Subject: [PATCH 4.4 17/28] futex: Provide distinct return value when owner is exiting Date: Tue, 2 Feb 2021 14:38:37 +0100 Message-Id: <20210202132941.878964984@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132941.180062901@linuxfoundation.org> References: <20210202132941.180062901@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit ac31c7ff8624409ba3c4901df9237a616c187a5d upstream. attach_to_pi_owner() returns -EAGAIN for various cases: - Owner task is exiting - Futex value has changed The caller drops the held locks (hash bucket, mmap_sem) and retries the operation. In case of the owner task exiting this can result in a live lock. As a preparatory step for seperating those cases, provide a distinct return value (EBUSY) for the owner exiting case. No functional change. Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Acked-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20191106224556.935606117@linutronix.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- kernel/futex.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1909,12 +1909,13 @@ retry_private: if (!ret) goto retry; goto out; + case -EBUSY: case -EAGAIN: /* * Two reasons for this: - * - Owner is exiting and we just wait for the + * - EBUSY: Owner is exiting and we just wait for the * exit to complete. - * - The user space value changed. + * - EAGAIN: The user space value changed. */ free_pi_state(pi_state); pi_state = NULL; @@ -2580,12 +2581,13 @@ retry_private: goto out_unlock_put_key; case -EFAULT: goto uaddr_faulted; + case -EBUSY: case -EAGAIN: /* * Two reasons for this: - * - Task is exiting and we just wait for the + * - EBUSY: Task is exiting and we just wait for the * exit to complete. - * - The user space value changed. + * - EAGAIN: The user space value changed. */ queue_unlock(hb); put_futex_key(&q.key);