Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1828962ybi; Sun, 16 Jun 2019 14:32:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxd9zOe0y7cVmsVLgL5WQCKzBhnYSjJEaMJTofrbitZU32CU5Eov8Sqn9T5Xar8FQw7IuTi X-Received: by 2002:a17:90a:2e87:: with SMTP id r7mr21575749pjd.112.1560720755676; Sun, 16 Jun 2019 14:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560720755; cv=none; d=google.com; s=arc-20160816; b=v3QCifcRPVIEZ/jMXTH7Tjhvgs4VVDHbKVXSPrUy06v6z7ElchADqkm5t2L2/MOLTh JZ5bOjxW7FlYW/rDfUHHvRws9lio8c+WifiotB9X1IYeZrL3bDHQYEDTOEi6idLvhxNj scv24d5dqcj9+rvQMTBpbNs6zBj6G6di5YNtFCK4JiZBt8QiutP0NUPlbkdK6YMFrhNT 2BEdxefppuHPrVDlRpdRGBC9+uNUUJjqQLJrNXoFNkbGUN2Vf8/nu8OS+Imez25D4HMO wbwzh77kb3coc+M1/pwTfN5f8fYuhhyKsSWSINFQbMz0iXUXAnq7hou5ltCraLTOCKuq hMjw== 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=7VduBeQKV5QqdjaRJMGgAlmp2IHtPHNsUVn3EFkQ16A=; b=MmO7Orkx7x/vzxubrC292oJPa7i0W+muwhDxa3ZBFTZQbY09YhTmIqP4hYoh8To1WM Uz3/pFTb/nJYNzuJ39Z3UQrkdznr9MZe8rom9pi7fNQFkxeq03L4zooTiHVF424eo2S4 vs98u6ipkcKOpErAXO8NEmaZNSw0JLkd9+js9ucHt0CvO0xb6VKZ2e9JRgO4EJjFEdBU owGlx8/ipGr35k/K19tgly+mc0FtBTBEs93P/deWBNCFdEtAvqbFlic6QSJ5JO18+ygk t32hDQBKOlul2PueCZpYjgFmErlF60UFTOpumhcC1LB2nDJ+kqBo/5TG6XdZagCiIEeF +2Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NaOJcl+y; 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 l70si8982118pgd.163.2019.06.16.14.31.32; Sun, 16 Jun 2019 14:32:35 -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=NaOJcl+y; 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 S1727410AbfFPVb1 (ORCPT + 99 others); Sun, 16 Jun 2019 17:31:27 -0400 Received: from mail-pf1-f182.google.com ([209.85.210.182]:43467 "EHLO mail-pf1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbfFPVb1 (ORCPT ); Sun, 16 Jun 2019 17:31:27 -0400 Received: by mail-pf1-f182.google.com with SMTP id i189so4509687pfg.10 for ; Sun, 16 Jun 2019 14:31:26 -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=7VduBeQKV5QqdjaRJMGgAlmp2IHtPHNsUVn3EFkQ16A=; b=NaOJcl+yzjhCeEuveWJCk+ztsn2feghCQVbaTu/DJt/zO+DaY4tFj/CMCQsela+8h+ EKmmF2vvjDrJU6JhpZFROJhfuBdfMvQrtx3BxSU/UtzB8jNzHBhvW5ji713pacfpK+ur T/RCfrXIOu2euKG9FHWvlH0SOhLRvANMeGHsY= 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=7VduBeQKV5QqdjaRJMGgAlmp2IHtPHNsUVn3EFkQ16A=; b=ZfFSf5qe5atXd9tmNFgoxwqDCbXHCfuUiQKbMNHzC8+C77lKDXxk3017l85JRskanb bLT3bw/paT25YhQPSnbV/FFZ4WkdSoA24PY2ZMpidoa8XbrA3f0Zf2olioUYMc3a2VAz Sxjfdq0Mv3zppTDIQ3LckpqUncsZ8YF9I2kC7EN+0mZuXUU+oZZ30ioyFeMIFdlbSdK9 3gsMsPZGXQrpRawrRlzh7Drs1Rs4NZVML6RozJFwDqCUlypiiI06EaYJn5Jdc9ZUHBfR k9AiG7txuDulOgnpDs+wGx5bfnDMEwMRdv0DPs2BiWdI75FiJA5Xp4vynYA6GsbPvvgg mCMA== X-Gm-Message-State: APjAAAXsM2Bg5XsKQm4t0XRjBALdM/2gyDrXtZjk3Umt7otAR382DRhm /FjzHtWOpUKmDNjGgvQJFj+CHA== X-Received: by 2002:a65:64d6:: with SMTP id t22mr43708172pgv.406.1560720686430; Sun, 16 Jun 2019 14:31:26 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id f11sm4268923pjg.1.2019.06.16.14.31.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Jun 2019 14:31:25 -0700 (PDT) Date: Sun, 16 Jun 2019 14:31:24 -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: <201906161429.BCE1083@keescook> References: <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> <201906150654.FF4400F7C8@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 04:18:21PM +0200, Ard Biesheuvel wrote: > Yes, I am using the same saturation point as x86. In this example, I > am not entirely sure I understand why it matters, though: the atomics > guarantee that the write by CPU2 fails if CPU1 changed the value in > the mean time, regardless of which value it wrote. > > I think the concern is more related to the likelihood of another CPU > doing something nasty between the moment that the refcount overflows > and the moment that the handler pins it at INT_MIN/2, e.g., > > > CPU 1 CPU 2 > > inc() > > load INT_MAX > > about to overflow? > > yes > > > > set to 0 > > > > set to INT_MIN/2 Ah, gotcha, but the "set to 0" is really "set to INT_MAX+1" (not zero) if you're using the same saturation. -- Kees Cook