Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1422595ybg; Wed, 29 Jul 2020 13:55:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUmKmxbVrU5C7vmWCmmExG0PAH19BUk9nPyRkEDFhAYZWlSZYDrMf4+HCIK7Y1xKHYBojX X-Received: by 2002:a17:906:26d6:: with SMTP id u22mr194845ejc.271.1596056151778; Wed, 29 Jul 2020 13:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596056151; cv=none; d=google.com; s=arc-20160816; b=IYtmkL0ASvzlpRcYhEHbuCAtqm1f6K1Pn9IdrqwPPezO7Xzei0aMRIKmmxrWBlyGPM yHc5WO+0ewMGuC64VC5M5NV+DlULW8efS5EpcOK+sYw9tCq8lCRe8F6fc9B7G7HCQAAD ZJ63vi+jBFIPJ9kLpDNRN6sA4QH9LcpuHB//6Mp1yQJU82gy8kyOYqDBQ8/VoJQX0gcy 0dpE3dd4vnu69jRR362E1n/q51Sxepk7xM0z/PKq9OwzWrZVLsZgVA1WEcT6KUJLq/kU 9IRmosPYLaJObg1jcpeNsrH4251nqYWJEMqYzbnl4v82iZXX7roYGITTcD3ZYjML42jQ WPGA== 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=FYYNYC1JI+3c7PMAXIAqnBSfW64jRIPrERoK0UyjHJw=; b=sv/DVE+lTlF6TR1lUn+tXUA3AYMc6g8OJIciPa0lPt5lvHBFJn4TGVP3IKWojoJ2cZ 4NK/872HGlTpTbstRa8oWMbPvo7DYz17LgnjZz6rnoHxXOKq+qjJwkP5DZgFEF0b3DmH +3uFwiAea/94rjjHXXo3ynqVeKduSbyCpkR5ggJNJENYTy9ba1/xAQ4XfAEw6tQTW06E GzEFHBpRQPJY3/kMxAMvT7WWfNm2VAT5CJOpQfvXzXwfcYvpLiLAIrmiRkctUC2cSX4y zrI1oJcyfXFlDIOvxYrxGL8CkEy6ja91py06DeJzu7JTcW/NghUpfIG3a2dcg5bqwMoV 3wCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K70+QIBF; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lg12si1865113ejb.661.2020.07.29.13.55.28; Wed, 29 Jul 2020 13:55:51 -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=@chromium.org header.s=google header.b=K70+QIBF; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbgG2Uw7 (ORCPT + 99 others); Wed, 29 Jul 2020 16:52:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2Uw7 (ORCPT ); Wed, 29 Jul 2020 16:52:59 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423ADC061794 for ; Wed, 29 Jul 2020 13:52:59 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id c10so898551pjn.1 for ; Wed, 29 Jul 2020 13:52:59 -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=FYYNYC1JI+3c7PMAXIAqnBSfW64jRIPrERoK0UyjHJw=; b=K70+QIBF7bjH402KT3/Gg25N38aoogOWePxYtbSb7mfR9KEciMxR6zcBNnxoPp3kCU bzGAMy+p46E0ipO94wqJtAhqDB8924SKqVQhlhrfCOfVqxztwVZX+xOzNJ4zLlxf8Ji4 aHxMSdSUwfR8lHYb+s++irZHb1sd59oOG/79s= 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=FYYNYC1JI+3c7PMAXIAqnBSfW64jRIPrERoK0UyjHJw=; b=rSgYNqRGjvyRDEnsu8Nky0oORblYFLglM1QX9vaQT8aiLL50sbOEGPLc1aSBRD6eh3 rlByhL3j4B44uwTGO7Qp1L6IHTAhQd+wEM5PWjEjjA6QoDAUMcLWZeUo4WTSDe2Vtrq8 7F4N1JdK3FR6eUklL+5RwzGmygif5GuOBo7MfHSO6gTZdUatExS32KYTiIwcy6I7KKWn 0uW/SoV+tSurKvNVi7rYCCPleP8wrYOYbevmkPvTY4LA5nqWTRrufctg1bd1ZPoIi5iu LFdvg6lGWWZhubR0bFSqlIZKxKHYTlcTR4lKIke9ppb6miLnifXYUMM9vpMNwKWi6Sci TmUA== X-Gm-Message-State: AOAM531wmUvtgjFmdNgj2ufiHm5DZkEOnM9Q731vqdc8Shpei/DaaU/W kjDFAlsBSMnf95ls4P0jKIZhTw== X-Received: by 2002:a17:90a:cf:: with SMTP id v15mr346379pjd.14.1596055978816; Wed, 29 Jul 2020 13:52:58 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id a17sm3251985pgw.60.2020.07.29.13.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 13:52:57 -0700 (PDT) Date: Wed, 29 Jul 2020 13:52:56 -0700 From: Kees Cook To: David Howells Cc: peterz@infradead.org, Xiaoming Ni , David Windsor , Hans Liljestrand , Elena Reshetova , Paul Moore , edumazet@google.com, paulmck@kernel.org, shakeelb@google.com, James Morris , alex.huangjianhui@huawei.com, dylix.dailei@huawei.com, chenzefeng2@huawei.com, linux-kernel@vger.kernel.org, Will Deacon Subject: Re: [RFC][PATCH] locking/refcount: Provide __refcount API to obtain the old value Message-ID: <202007291352.8775B08DA@keescook> References: <20200729111120.GA2638@hirez.programming.kicks-ass.net> <20200721195132.GJ10769@hirez.programming.kicks-ass.net> <202006142054.C00B3E9C9@keescook> <20200612183450.4189588-1-keescook@chromium.org> <7be4d56b-0406-099b-e505-02e074c5173e@huawei.com> <544539.1595328664@warthog.procyon.org.uk> <202007211144.A68C31D@keescook> <3211866.1595933798@warthog.procyon.org.uk> <4041520.1596055297@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4041520.1596055297@warthog.procyon.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 29, 2020 at 09:41:37PM +0100, David Howells wrote: > peterz@infradead.org wrote: > > > I'm not entirely sure what you mean with interpret, provided you don't > > trigger a refcount fail, the number will be just what you expect and > > would get from refcount_read(). If you do trigger a fail, you'll get a > > negative value. > > That's fine. I seem to remember talk about the possibility that the number > wouldn't necessarily bottom out at zero - for instance if it was arranged such > that the overflow flag was set on an overflow or underflow so that it could be > trapped on (using INTO or TRAPV, for example). The trap is an internal detail. The saturation value will be negative, though. -- Kees Cook