From patchwork Mon Feb 1 10:01:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 374228 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1120369jah; Mon, 1 Feb 2021 02:05:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9o64wR3FYYYsonfkepFkFiXcsRppT3ui7n+JAVuFUTYqgf2QGeF9JtKvWLa5cEu+PTbx+ X-Received: by 2002:a17:906:708f:: with SMTP id b15mr17172467ejk.267.1612173900988; Mon, 01 Feb 2021 02:05:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612173900; cv=none; d=google.com; s=arc-20160816; b=ku6BncWBbjzPwUP39orCXlaB+WdiGIKo0jUp7YfNHLDa4GXyD6h0WM5hi5y6D07yDf I2ws/wZQDmQqb+dTLrdnFGGhVa2OYKSH7JH7S5Uu+FDLf30dR4Q6ZeaqHkJKuSoDHtkV dVkOVmolOL4lKfHMHLUNSnWWOOO4tznE2NhybG8JxzW3N15DF4jJHuR+boXdG0IvbkS4 27NpMyi1itg7H4HVYDlTMcenTri7QzV95/uOv+jC9y1INHtTO8vcZU50X6PRrROeK1Z8 kxR1ZT72LDXSzr0cLagrUXWb0ptLPPkFk6bniCWojfFoenCcu+Sio2IckSl7b0017I++ frQw== 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=YvIosSfqayR6zcFHOY8c0x/JdWmP1VyW0c+N7TdenS0=; b=M3HeYltmzjSnYwE0YWE52/UytAcBh5Om+kMAOAVO7AR7SWwb+7ZJGnXZ7HWw29oj1s YOCHvIogtgw+aNVYELJmZF5urWs9GmHNzLZNzCxwY15nn+8McmS9prjIH3xpoXzfn/b8 IS/BtuYCI8R/t2uZpTk/TsZ+ghFKYT7q5Y9f2UM+EY/ZE+3uiEfldKlRAzWHe7V0nMS1 9iVov9+iPqL1JFUwk5ypDwDhCrVYHCXqalzsEDHHd+5Me9KNugbJ31liM+4OZFuTe7ri X7Qnj8sjIux+bNkiMJojDe9qi8ZTsAjIu2lDlWf8Gvq3oTh5Eiuto9VFFtwJeloHb6Nl whcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dEO9Jyac; 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 m6si13120787ejl.643.2021.02.01.02.05.00; Mon, 01 Feb 2021 02:05:00 -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=dEO9Jyac; 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 S233020AbhBAKDn (ORCPT + 13 others); Mon, 1 Feb 2021 05:03:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233011AbhBAKDm (ORCPT ); Mon, 1 Feb 2021 05:03:42 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CC22C0617A7 for ; Mon, 1 Feb 2021 02:02:25 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id s7so12882436wru.5 for ; Mon, 01 Feb 2021 02:02:25 -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=YvIosSfqayR6zcFHOY8c0x/JdWmP1VyW0c+N7TdenS0=; b=dEO9JyacwmaNh722rkMqymWjpemauzfTZo9g6zy6O3h0+aVdJI0fT0egpN0lkOapR4 dEbSVoXXQLVegZrXuhI0JW/mzj/vGy1TE0lf9YVPfvApAkUO7AnULl3X0QkLmwnLgI5D 0QGKjd2uWNOTg5j3ll5of6xK00r5v3uEkqS1Ki3nN5VaaeHKL7Pr2UtiBvH1urnskihx bu0lC9kBMyiVCMLtXel/iNjToeKnGtQmoDPpnBK8wtGKuOCrmnQPVekKCn2zvVcPwFhs 9V3tUg2xpFZq89ABmzrKo2ZTkbdbsod2B4ULRnyA7qFX6yEUcsGpiR6vckmzpMD7+NrI 4fsQ== 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=YvIosSfqayR6zcFHOY8c0x/JdWmP1VyW0c+N7TdenS0=; b=SR9E4uEZxOkVROZNfQsoANmhP+4K2f0Aa1dqGluGeOvl3g1yA0HovX+zWVdpZxXdyv YxAY2GF9BLr+3u0xV7eNCn+R0vqSv2PF7y8lVHfPHCej3UzlokvIJYv7+Y0rfB3ly9Yb yJrVANA+iYoEPFvIYIqz/ejLoOhDYj3NPArmUU/aiMJR0m5sC3qqk1ORLIRuRATkue1M rWMCG6VyJDgXOwh46GhTb8KmL7TGu9ovWeFM7CID1PSpmR7+1Z5TJP2DIOTlOYGHfCoQ hvW1PxbfL1agEqcs7LVsmNXV91FNNmWaB9O5uuffLfWJjD0YZmCx8UHJSlYt7sN+mQOs gXiQ== X-Gm-Message-State: AOAM533icZ0gHSwb4BSbzATSAlnWXwOgx7c2JcV5mLZTr/gFQahoObpr +ki8H3hQ2IMJ83MNiDf9MOiyQZ5IeDfglojF X-Received: by 2002:a5d:4f84:: with SMTP id d4mr16951524wru.374.1612173743342; Mon, 01 Feb 2021 02:02:23 -0800 (PST) Received: from dell.default ([91.110.221.188]) by smtp.gmail.com with ESMTPSA id p15sm26151387wrt.15.2021.02.01.02.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 02:02:22 -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 10:01:42 +0000 Message-Id: <20210201100143.2028618-12-lee.jones@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210201100143.2028618-1-lee.jones@linaro.org> References: <20210201100143.2028618-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 e7798ef3b4b71..cc4590d9fe645 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1918,12 +1918,13 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, 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. */ double_unlock_hb(hb1, hb2); hb_waiters_dec(hb2); @@ -2615,12 +2616,13 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags, 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);