Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4969322pxv; Tue, 27 Jul 2021 23:10:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyexD94RFNzChsUl3WLkrsKITEsuX+ffpbCsy76YDTiu4cxfjvIezV6IK7JmJGA8GSRS89C X-Received: by 2002:a17:906:3b47:: with SMTP id h7mr18426701ejf.399.1627452602378; Tue, 27 Jul 2021 23:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627452602; cv=none; d=google.com; s=arc-20160816; b=kjjPENY/CzsaO+7nPDWmBEkFCnyY5znLEfzlfbg2QwdBuaGZkzac/2XtkL5DZ07+9w B9opyT+LaiAXy8JLPev4NsahIuyURcbv465uJJWd2P2hHd2FF22ZwrClKSJODUJ2FN7H KkH4o5zdsI3I9ycIiZSpmCYi7ypDnAGtNRe+F0h4IAyLAs9k4umVJbsdTXBrHOPzHWJ1 Whl0Dkf+DT4+lYfFWi9gJbFWicefi2hYi6dYlxS0sFXvDgnZnXoiP+5G5gSen0PQ9JHb W2HIR/psLV+p4cA/XrF1TZqOndJbCtFBfP33V60QaN7BPH/wYuSHklcCDL5t/8qHsAHG FLiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6iz6VeCONBiRY1Vy2AJDJjzUbHZ+GjRCzXtoHN84o0A=; b=wL18iZm008Yc++ZZ+QJL5ztUwjY8ymgElX1opIjP+s8FsCqz0cV7Q9hAlFp36FIRQb bXrQjX+xKp4m1n27L8LB2qsJX+tigg6hM2pVLvvl2wzqLJ0GsyaGz9iYIq1oirTytP8s Ls36+Uwl95YOTunrc4TmmYGeShrOtWvdihj2P1Pg7B2kfC9TPMentAF9YlT4fPpxcxqy hZawTi+LCLPieeQyEOX15kP+BhnSpjMUWmhD2FYNxEn7XEybsVNopv7J4Ibbn65Vl7gc QAvy50EEzAjnMtdtCDaULKM6TdJfKM0JOTlBgFPEQS8Mx5QVXLYRTvTVAv4Ev7cc60cj 7iRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UiHxGMoo; 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 gg17si4815309ejb.431.2021.07.27.23.09.39; Tue, 27 Jul 2021 23:10:02 -0700 (PDT) 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=UiHxGMoo; 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 S233971AbhG1GHD (ORCPT + 99 others); Wed, 28 Jul 2021 02:07:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:55748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233574AbhG1GHD (ORCPT ); Wed, 28 Jul 2021 02:07:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 001B660F9D; Wed, 28 Jul 2021 06:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627452422; bh=76MetjlUiqpuBeufTRf7gbVrwzc6kLp4M8vJsjFmlWA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UiHxGMoohvjyi8M69RMdI2eGRy+9i5LgzYRQn1GjO5VDtRHmRenZ4o1Hu014ZKaeq icjtzvLTWq1fuCZGZg93dkOy96MPYMvxIeMnDoEYAcKypWEPVpr0c1la8Joq6kcVtQ ha5sEWfzoJl0tuaT9tQ7sMnFULmylHv3H3eya3yk= Date: Wed, 28 Jul 2021 08:07:00 +0200 From: Greg Kroah-Hartman To: Joe Korty Cc: Peter Zijlstra , Lee Jones , Steven Rostedt , Thomas Gleixner , Sebastian Andrzej Siewior , LKML , Ingo Molnar , Darren Hart , Davidlohr Bueso Subject: Re: [BUG] 4.4.262: infinite loop in futex_unlock_pi (EAGAIN loop) Message-ID: References: <20210719162418.GA28003@zipoli.concurrent-rt.com> <20210727221950.GA51120@zipoli.concurrent-rt.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210727221950.GA51120@zipoli.concurrent-rt.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 27, 2021 at 06:19:50PM -0400, Joe Korty wrote: > > [ Added missing people to the cc: as listed in MAINTAINERS ] > > On Thu, Jul 22, 2021 at 04:11:41PM +0200, Greg Kroah-Hartman wrote: > > On Mon, Jul 19, 2021 at 12:24:18PM -0400, Joe Korty wrote: > > > [BUG] 4.4.262: infinite loop in futex_unlock_pi (EAGAIN loop) > > > > > > [ replicator, attached ] > > > [ workaround patch that crudely clears the loop, attached ] > > > [ 4.4.256 does _not_ have this problem, 4.4.262 is known to have it ] > > > > > > When a certain, secure-site application is run on 4.4.262, it locks up and > > > is unkillable. Crash(8) and sysrq backtraces show that the application > > > is looping in the kernel in futex_unlock_pi. > > > > > > Between 4.4.256 and .257, 4.4 got this 4.12 patch backported into it: > > > > > > 73d786b ("[PATCH] futex: Rework inconsistent rt_mutex/futex_q state") > > > > > > This patch has the following comment: > > > > > > The only problem is that this breaks RT timeliness guarantees. That > > > is, consider the following scenario: > > > > > > T1 and T2 are both pinned to CPU0. prio(T2) > prio(T1) > > > > > > CPU0 > > > > > > T1 > > > lock_pi() > > > queue_me() <- Waiter is visible > > > > > > preemption > > > > > > T2 > > > unlock_pi() > > > loops with -EAGAIN forever > > > > > > Which is undesirable for PI primitives. Future patches will rectify > > > this. > > > > > > This describes the situation exactly. To prove, we developed a little > > > kernel patch that, on loop detection, puts a message into the kernel log for > > > just the first occurrence, keeps a count of the number of occurrences seen > > > since boot, and tries to break out of the loop via usleep_range(1000,1000). > > > Note that the patch is not really needed for replication. It merely shows, > > > by 'fixing' the problem, that it really is the EAGAIN loop that triggers > > > the lockup. > > > > > > Along with this patch, we submit a replicator. Running this replicator > > > with this patch, it can be seen that 4.4.256 does not have the problem. > > > 4.4.267 and the latest 4.4, 4.4.275, do. In addition, 4.9.274 (tested > > > w/o the patch) does not have the problem. > > > > > > >From this pattern there may be some futex fixup patch that was ported > > > back into 4.9 but failed to make it to 4.4. > > > > Odd, I can't seem to find anything that we missed. Can you dig to see > > if there is something that we need to do here so we can resolve this? > > > > thanks, > > greg k-h > > > Hi Greg, > > 4.12 has these apparently-original patches: > > 73d786b futex: Rework inconsistent rt_mutex/futex_q state > cfafcd1 futex: Rework futex_lock_pi() to use rt_mutex_*_proxy_lock() > > I have verified that the first commit, 73d786b, introduces > the futex_unlock_pi infinite loop bug into 4.12. I have > also verified that the last commit, cfafcd1, fixes the bug. > > 4.9 has had both futex patches backported into it. > Verified that 4.9.276 does not suffer from the bug. > > 4.4 has had the first patch backported, as 394fc49, but > not the last. I have verified that building a kernel at > 394fc49 and at v4.4.276, the bug is seen, and at 394fc49^, > the bug is not present. > > The missing commit, cfafcd1 in 4.12, is present in 4.9 > as 13c98b0. A visual spot-check of 13c98b0, as a patch, > with kernel/futex.c in 4.4.276 did not find any hunks of > 13c98b0 present in 4.4.276's kernel/futex.c. Ok, so what do you recommend be done to resolve this? thanks, greg k-h