From patchwork Mon Feb 1 15:12:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 374268 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1383191jah; Mon, 1 Feb 2021 07:16:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzezvLxxk6/OUiB4hofP5ijTx/d2Y42PN0BMoo7drFqMntxc+G3cnsOQuTtzz02/wnh8NvU X-Received: by 2002:a17:906:a453:: with SMTP id cb19mr18258391ejb.459.1612192573309; Mon, 01 Feb 2021 07:16:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612192573; cv=none; d=google.com; s=arc-20160816; b=pQSIQRqz2iffkuGi5JGJuonn64rCCjE9yJ0lGz2YPPyPxsu+w9kSoaiifta5drqyAK EE1QVhYfp3yAZ9graQNW7ySyhyEdguJ/PzlkoaePq9ivSNsIhg9c6aCtgbgD8mKud1UY srdzw8BmV9NhH5AkkQL2yyiqm3oKRv4xg/VfNJvLXuxhKoZJU42P5pskDrFe8FmqA/k+ 20HAWGAB/8N1lKwNA6jixxgPSQFDLReO85nNk8+w0qpYtwvH129eBgKMc0RajHdtYFOk geGlnoHt4zSTIGoy4tF4/OJN7XTlY8BJWkwZe6WaaDxPkhW29TQgiz9SDc623z9VUyhW RyGQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xELEKrhqhTmDdRYtgPgdfO9RZGP1Kih4SIlHlfBN9xk=; b=BMfsCin8xAonK3ReUoqwje7163sKOvQQVLMSJfEhtRHoQImuVK/lRLJUtX8yqyGGkd WVgzUKBxaUOLuE4axR85uM0b3A8VeyGSVz7MjOpVOg3DXq64F7w6y/o9BzWEh8EIWuej +12d4lOaNotyXjik93HBn+fWN7vvFZfXQXRJO+fsQgO4A8mIjyjga5DzhO3FZhlsBuO9 heBGxSC5cYuB8/T+LrCJe/fT3JIjfWWL9yVzKZ7Go15qOPHoAqJTMo6ovzXdYyu0FEMS yJM9/v3TntC4tFijBuxmV8I1tORk0hpD7EPfSwpbENPKxKqI5bqjWbWW0Hf5mwatLy4H pRxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xvHNKVH5; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f29si11574766edj.297.2021.02.01.07.16.11; Mon, 01 Feb 2021 07:16:13 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=@linaro.org header.s=google header.b=xvHNKVH5; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231440AbhBAPPD (ORCPT + 13 others); Mon, 1 Feb 2021 10:15:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231352AbhBAPPA (ORCPT ); Mon, 1 Feb 2021 10:15:00 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2E6DC061797 for ; Mon, 1 Feb 2021 07:13:47 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id m1so10220915wml.2 for ; Mon, 01 Feb 2021 07:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xELEKrhqhTmDdRYtgPgdfO9RZGP1Kih4SIlHlfBN9xk=; b=xvHNKVH52mIQidJjuSVbHHFtT7epo7ypTi7PBlUXI0RYeeNUQ9swqA5YUA8xrTCXTK 32DIeKf4AlJhiotmKXi277YWUR3W4GGQ26+ZSueMiRIXq3nUFbR/+pb5CJjYfZE46zPT XOiwEZa2839QI/lm5UhF5iQ80MQmbYhLViDa5kbfRIEqFJFDr6J4SXTa886EmT4GqMGQ qf0P4cb5m4Ud6BxAMi0g3t4xl0yvgjLDc1q2mSUMn7zmoWbfAVNGqvDjXvOitefM3YkT cPJ4KpciJiz1AGWuXZThiWA8XRkKYgVmlW580BuWKyzFUeWajN4u7kitz/mxxvEXnww9 Y7dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xELEKrhqhTmDdRYtgPgdfO9RZGP1Kih4SIlHlfBN9xk=; b=VjqNHRnrKvrCisuYZI6y4qTYPCD6X9PdJpIVDEkIP+aRiEUGwV4W/W1OkfKXDDJoiV 7nQNPaATOLM3t5RME+zvCdfXv25RCyyFnM9HOXoYgO4jHcNIPtjvh+/txKMMf6AAa6w7 nYEIOyNsy5SgB1LOknGJRpx7vMb6xL1enCj7qc5MxWumS8cPg27bnrv3lfE7Z1AbIxrP ijJ1WydmjgIgVMzZely5v0ewP1hD22cpH9BSbE1m59wmsLgGivLL5pIXt1RHXN4Ltg5O bd99Ieoxe1WmFux3ih9+jftnW0GC839KVvSbABnGCZRKFRfT32KFRXgZo2JsB+rXl7jW u99A== X-Gm-Message-State: AOAM532waEPhBjpj+rHF3Uu/4pQ/w/dPvxRSl2YSBeWMcfWdEakIhi1E +SrLgiQV1IK7hAgUBRqIipKX6W3XVcsfesIv X-Received: by 2002:a05:600c:35d6:: with SMTP id r22mr15430041wmq.44.1612192426025; Mon, 01 Feb 2021 07:13:46 -0800 (PST) Received: from dell.default ([91.110.221.188]) by smtp.gmail.com with ESMTPSA id 192sm23323381wme.27.2021.02.01.07.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 07:13:45 -0800 (PST) From: Lee Jones To: stable@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Greg Kroah-Hartman , Lee Jones Subject: [PATCH 11/12] futex: Provide distinct return value when owner is exiting Date: Mon, 1 Feb 2021 15:12:13 +0000 Message-Id: <20210201151214.2193508-12-lee.jones@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210201151214.2193508-1-lee.jones@linaro.org> References: <20210201151214.2193508-1-lee.jones@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 --- kernel/futex.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/kernel/futex.c b/kernel/futex.c index d21b151216aa3..32d799b9bd205 100644 --- 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);