Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1253753imc; Mon, 11 Mar 2019 09:37:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7A6bCyiO9FtWRU+SYmy3bJ6yV+c7eTps1QEhKiNTxozYivY12gyYIbkOC4ftZc1Em0yHb X-Received: by 2002:aa7:8157:: with SMTP id d23mr33921509pfn.67.1552322231727; Mon, 11 Mar 2019 09:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552322231; cv=none; d=google.com; s=arc-20160816; b=fuZebqbSndWWndu0VO7tDWiLi48eYhPmBFYnO5+KtA0vkofSPRQ/yGj3RElo/1Sh9z 5lRvt548h5LiXWFxUyiROmaxHoskkcolTn8sOkQ3YiFPNCMU2q+/UCZrtAo2Lpcx0mNm pIWBfy7SNNUV79IucCcZWR8Lfydv+Z8m5ZRdGzvX1m/0DC+yGY6ZUh1c51/Tko0JqNqK Qh+1ppYAiWIT65dpNxUtwkZYc+EB6gQoNXxlaOJWwBsGCjXSFjYjH0wHMfe1Uov58lle nk6qJI0Ppyqv8zOrpWiVpeRjefFBokhiC7fcpIVtQIb7ed+6EtAfs3LUTgI6vHsfwbph u7rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5bujM85Y0scj/fEZwrlnYcayj7i0rZlLHknj8BGgmlQ=; b=eRSQ/Kg/I1x3Hwqy2Aw1pqfiNhgY6ltG6C7MrAV0yFy73h/3T5eZ8XZBL6LIq/+uZC QwdKzkFhLQV3tGQw76MbBrUco+9e+EkgxnNFq6XfSwgmK7QThLjK0YstLhpwuDbmCpQ1 9t/I3hlAeDe+yax+WXjsu/lU+1Js7KxsBqXWlY7mh+s/U4z5iuUz0i4s/rSme9c3T9+J bahZip6O+d5RKnVAfzhB8WzzONWg5J3lxNdUh0jVbYAS4EYks3VicITACY4C9a/hmGpi TZIj5zRX68DzH49V8bCEftn+0z5RZti4m4ZmBzk4HGb23jmv+Pk3n6DKcOFVmuN8n1Mh qEVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZxJvlV4h; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si5862230pld.87.2019.03.11.09.36.56; Mon, 11 Mar 2019 09:37:11 -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; dkim=pass header.i=@linaro.org header.s=google header.b=ZxJvlV4h; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727797AbfCKQg2 (ORCPT + 99 others); Mon, 11 Mar 2019 12:36:28 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:51891 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727643AbfCKQg1 (ORCPT ); Mon, 11 Mar 2019 12:36:27 -0400 Received: by mail-it1-f195.google.com with SMTP id e24so8319912itl.1 for ; Mon, 11 Mar 2019 09:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5bujM85Y0scj/fEZwrlnYcayj7i0rZlLHknj8BGgmlQ=; b=ZxJvlV4hegE8DN0DV3FW4178aEMDeHea8IXp0fzUZM97n9Kop92Wf2mzwL7uHNnhHb BzTTzMqzWDeeQZiRmtcN1aBt3HclJ2/oErULNL4pRjtG/MgtkTALWT7c312yZQdBPAoE B49BYNsYSCjKU2E1LGMKWXjXr8tvh3dtNBALdDSUY4nyM/AIiSX3fA6NC1YeSogrNQzI 2U3b6DBO7oCA0WNfUUGcbQNfzcNSh8ahfpLN9OJFCae+dbToC4OLhIKurpRI4PraFrQ8 Cv/TSyuoFDP/lH08wSQEwlP4OMjTyfApoeGnqeSqSnkvFJlKOUjNEPiDXLhwLERfDDJR ImdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5bujM85Y0scj/fEZwrlnYcayj7i0rZlLHknj8BGgmlQ=; b=Nube9lxKNCLBPY1TBLdvm4utkPox2cPXZSTAipvPKv/MObOIGHFF8/CvJbCdJz7O1s KFFtOq/gz9IFIjv2XCS268k8yeOzUy1WexXYoiUjiZ//eSfSrVj2zpjmmH5Lp67apvoF PUY2cbDWFF4XpclylS8ttrMiMeeawHtM0K3GYNgvamZ5JoUHrhAode+2/rnyTJEAdopa J1jasy1espw4CR7bRx67HHSAlJxYHbpeP2HEN/GGBhnXiq/ur69GM8EpqIdJMibmghq8 nNUaPjXHriQ4s1rEDCAwYdxsHmR2KbsKVpC3UT59mXS5iwPH2CjKpm/0dCrR8Jq+1B3f cmwA== X-Gm-Message-State: APjAAAWkSrhm6zG3L0WZGBl3h/qcMueWz+chm+LgHes4B7j1tJ6yudvM PExSuBkN0L4gCUfI7Jf7yf0VHWS6bVsi2zdvax1MVJAt3JU= X-Received: by 2002:a24:1947:: with SMTP id b68mr308858itb.121.1552322186149; Mon, 11 Mar 2019 09:36:26 -0700 (PDT) MIME-Version: 1.0 References: <20190307091514.2489338-1-arnd@arndb.de> <20190307091514.2489338-2-arnd@arndb.de> <20190307234850.nsbpkfcit3lnmytu@shell.armlinux.org.uk> <20190308095308.hjjrzdp4fzbbtnnv@shell.armlinux.org.uk> <20190308103429.ycasmpt6tcpsoqps@shell.armlinux.org.uk> <20190308105835.tovswk5rwxusmxdu@shell.armlinux.org.uk> In-Reply-To: From: Ard Biesheuvel Date: Mon, 11 Mar 2019 17:36:14 +0100 Message-ID: Subject: Re: [PATCH 2/2] ARM: futex: make futex_detect_cmpxchg more reliable To: Arnd Bergmann Cc: Russell King - ARM Linux admin , Mikael Pettersson , Peter Zijlstra , Nick Desaulniers , LKML , Ingo Molnar , Darren Hart , Thomas Gleixner , Dave Martin , Linux ARM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Mar 2019 at 17:30, Arnd Bergmann wrote: > > On Mon, Mar 11, 2019 at 3:36 PM Ard Biesheuvel > wrote: > > On Mon, 11 Mar 2019 at 15:34, Arnd Bergmann wrote: > > > On Fri, Mar 8, 2019 at 12:56 PM Ard Biesheuvel > > > wrote: > > > > On Fri, 8 Mar 2019 at 11:58, Russell King - ARM Linux admin wrote: > > > > > On Fri, Mar 08, 2019 at 11:45:21AM +0100, Ard Biesheuvel wrote: > > > > > > My first attempt (before finding the original patch from Mikael Pettersson) > > > was to change the probe to pass '1' as the value instead of '0', that > > > worked fine. > > > > > > > Which probe is that? > > diff --git a/kernel/futex.c b/kernel/futex.c > index c3b73b0311bc..19615ad3c4f7 100644 > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -3864,7 +3864,7 @@ static void __init futex_detect_cmpxchg(void) > * implementation, the non-functional ones will return > * -ENOSYS. > */ > - if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT) > + if (cmpxchg_futex_value_locked(&curval, NULL, 1, 1) == -EFAULT) > futex_cmpxchg_enabled = 1; > #endif > } > Ah ok. That explains a lot. Can't we just return -EFAULT if uaddr is NULL? Or does that defeat this check? Note that PA-RISC has /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is * our gateway page, and causes no end of trouble... */ if (uaccess_kernel() && !uaddr) return -EFAULT;