Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp566798ybi; Sat, 15 Jun 2019 07:01:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz850JUH2fI2XKfkt86jOQjfuAddTx/KcJO4fpv3TukSCfySOIOJ5FKIPcTFoi+bbv2LJP2 X-Received: by 2002:a17:902:e306:: with SMTP id cg6mr67144368plb.341.1560607292925; Sat, 15 Jun 2019 07:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560607292; cv=none; d=google.com; s=arc-20160816; b=C0K8kteFqqmeA0EaI1jSAtiJp2XuISi62DTvXcDvyb6M9iZU+mtsgq2L4vI+Ei1hcF iHsThtGIrsLs40MN9CAkwoDZtR38EwB0mmR5hxpYmpwsU9UwL0YiEN5QWmoKwvgCHbKz Symctc+aSM29RnL+X223BKJv2LBqbwedpbzMd+cVbDk2tS/LInzA+iAUIg/7CeV+7j9Z GhUOXExOOwyQ71KCpkqNwQ+6BMi+ETxVlScBRsgLKUBcYTxY/6LVss/yozepWJZzkRP+ ehDJP/OYExZtvugeAZkxEjIqz8CfRaj1Ll63G2wUJQqxZZQUxNqVgl0lW6wfnmfNdFI3 /BRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=kJzT+l+OO8n7EwqnrkDiquC/ywPXGBmvTdfRsOHf0Hs=; b=TD9SWIt2IH0FI7t7c8wqL0JnUf/ZOliZwXATkaakzi48ww0L/7g9vjq5i1OySh3lMq fgVe1cvKYC/geu8OvznIyaBLy9kiAhY5BdB43KUsSSJv2M3PICXYjTceuQjP9NVt5Pf3 k5hLFg/J4pD2C/6dFs0g+8waOc4NGfgxjYP5hqBK4P/p240NzdWq7mJ0sjTYCgfSF5ku 4WabiEB8dUZEHBJa3iqwdSzFGviEE8ih8+Rg/Zx8w6ocmv5NqQZs/H3EjcgTzbAsXE+Z nsciw7MaTdZmhkOhHiJGOqn5W2J0Ou4MWQMxfTYfAwW3vAuAhz0bYHiZTDf8sZx8gnes yikw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UGeCBSBI; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si4961125pll.76.2019.06.15.07.01.17; Sat, 15 Jun 2019 07:01:32 -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=@chromium.org header.s=google header.b=UGeCBSBI; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbfFON7h (ORCPT + 99 others); Sat, 15 Jun 2019 09:59:37 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34448 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbfFON7g (ORCPT ); Sat, 15 Jun 2019 09:59:36 -0400 Received: by mail-pg1-f195.google.com with SMTP id p10so3206348pgn.1 for ; Sat, 15 Jun 2019 06:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kJzT+l+OO8n7EwqnrkDiquC/ywPXGBmvTdfRsOHf0Hs=; b=UGeCBSBInFsZbVoakbF5FAzrgs/2dJXEhyelWiWKzi5DAuY6acxFfpLNy1YCB09WqL ya7HACESBLUB2LwsNh5c1185X7xTWyGC6Rc0Q2XQWWRj41dkRfJGG+r09q96hLma0cHI 6wvqNIS7byjkB4dM18vDS/A59EiMyBk3MtoIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kJzT+l+OO8n7EwqnrkDiquC/ywPXGBmvTdfRsOHf0Hs=; b=fDO24j4AAAanWfytSuIY6rW5FZVQnsidDWy0+Qg2JF2pCW5tnibB3ijXSbNnL2MKxd 8yZH06ztElX8a3fqXX6WcwcmDTc3ThU2GA9IZyxndkUCFah3rOpz0rwTUOPyMvIvvchL d+eZnINc03lgvTE9RryAXUVotDh8FpAk/s5Sz7ZEIfQWSPImQ08I27u5rzeN6aMALMVC rCKFRZ6iMrsbNXEbBfbN1E/eOL7UJ5vjPktqqwffaaMqYmwyjOEpH+qUjk+PceMVtl1s fvEmYxxXyqVsxO3wSmU3mUnK9WRKHnLQdWM3s/IhqYy1yCEqx3VbcborJ131yjdnodV7 LVlA== X-Gm-Message-State: APjAAAX6mURB+OfjsJ8YTFovf/vBHvVisQ1jefjLwAZrD9RDneTFUzMo P/6M3IGwmPFmEbtTTdxxmKNw3w== X-Received: by 2002:a65:63d2:: with SMTP id n18mr29109647pgv.278.1560607175951; Sat, 15 Jun 2019 06:59:35 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s12sm5323358pji.30.2019.06.15.06.59.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jun 2019 06:59:35 -0700 (PDT) Date: Sat, 15 Jun 2019 06:59:33 -0700 From: Kees Cook To: Ard Biesheuvel Cc: Will Deacon , Jayachandran Chandrasekharan Nair , "catalin.marinas@arm.com" , Jan Glauber , Linus Torvalds , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [RFC] Disable lockref on arm64 Message-ID: <201906150654.FF4400F7C8@keescook> References: <20190522160417.GF7876@fuggles.cambridge.arm.com> <20190612040933.GA18848@dc5-eodlnx05.marvell.com> <20190612093151.GA11554@brain-police> <20190614070914.GA21961@dc5-eodlnx05.marvell.com> <20190614095846.GC10506@fuggles.cambridge.arm.com> <20190614103850.GG10659@fuggles.cambridge.arm.com> <201906142026.1BC27EDB1E@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 15, 2019 at 10:47:19AM +0200, Ard Biesheuvel wrote: > remaining question Will had was whether it makes sense to do the > condition checks before doing the actual store, to avoid having a time > window where the refcount assumes its illegal value. Since arm64 does > not have memory operands, the instruction count wouldn't change, but > it will definitely result in a performance hit on out-of-order CPUs. What do the races end up looking like? Is it possible to have two threads ordered in a way that a second thread could _un_saturate a counter? CPU 1 CPU 2 inc() load INT_MAX-1 about to overflow? yes dec() load INT_MAX-1 set to INT_MAX set to INT_MAX-2 Or would you use the same INT_MIN/2 saturation point done on x86? As for performance, it should be easy to measure with the LKDTM test to find out exactly the differences. -- Kees Cook