Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp14473567ybl; Mon, 30 Dec 2019 10:44:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwrYs3Uj0PnTeYKK++SRPU/ZhqwVmy6GQoQ6PBGWYYQVxyyan32Ii5EgsmaY98oqXuIS7Z/ X-Received: by 2002:a05:6830:1047:: with SMTP id b7mr78324903otp.77.1577731467170; Mon, 30 Dec 2019 10:44:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577731467; cv=none; d=google.com; s=arc-20160816; b=MNJUaVi4wKcim+FOk7Sr9q91aX2tmm3fh+wyt7k0YXImMV/uZlCgVqgaX0YE+Ytyym D2T/J/Fr/ncaTpgKvmvwpocpcNZRC1y1C4/GVBdwRn7WVQPaMA6tv8EXevHCfbkpYR9t oc/KX6DmzWsJbi81kvpe1ybfxVni821LJhCKFmSxQQ5H18zxMzbY+7kZ10P1QGrTNnQW gaIexUD1EMrGPMoGoxMuuHXHyPoQCbMSO0AkLxty383HkFmZpmQz4IL8obHQiFNhqPI/ Dd6KdDGqNhNiuwXz/f9wpC+iApr7OzgfSEyH+8Kj2gnNLfv4YRtjkr9KvdMii2e0eQqR dChA== 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=0adwBdSRSa0FPlcHU/hDxd1UBJTeWDvsTu8kZ2SuRTE=; b=TKRRJAaABTbgRondRmeHwBG7wLGG/kY0SvN2YPc86IWm64kE8kEH+MI9p+diPwV+Qr H0XtWopIIcapco2uMnrYRX76GuRjrpS04grkX0tcycPNQwB8N2o3daQEI7QYnhrXXS5T 8tbOI9/VJMS9Lkl6Rh5hMe43LLxxLVVsbB0rUMzYncyWwVmHFMqCWkFUSM7kY60GW7xV ZtbwTWLF3ENHjc7l/ydZ8fJkSq6u7JSXmjbPb1ayCESBXyljuX4cC7ee8ZFV2OFq+npp F/xADf2TqaFHjnss4hl1SSlOqFHTPqMCOBjbGd22i5z92hcpcKI0216j/NdWImDb7IvL Vb0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=miQbznhX; 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 13si15748649oiy.28.2019.12.30.10.44.14; Mon, 30 Dec 2019 10:44:27 -0800 (PST) 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=miQbznhX; 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 S1727558AbfL3SnX (ORCPT + 99 others); Mon, 30 Dec 2019 13:43:23 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:40943 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727511AbfL3SnX (ORCPT ); Mon, 30 Dec 2019 13:43:23 -0500 Received: by mail-oi1-f195.google.com with SMTP id c77so10889590oib.7 for ; Mon, 30 Dec 2019 10:43:22 -0800 (PST) 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=0adwBdSRSa0FPlcHU/hDxd1UBJTeWDvsTu8kZ2SuRTE=; b=miQbznhXk4hpJLs9TcBUiYHUMqvyBjkzSpnTZ/iMbNqkp3pk8S0SXEYs64hBCJ+Sr7 sXpKy0oPmtnQD08YMpJc3AdzAGrQ8OyyBzMVjAocsuaSrzYLGLgI63lFnojCFn7PhF76 GP6X/TpOvGbiKF8fUbGuazgouU5seKq+5aaRc= 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=0adwBdSRSa0FPlcHU/hDxd1UBJTeWDvsTu8kZ2SuRTE=; b=VsN8BH+N9Wz03mO2123q2E77W5aLJL4YN3lH4ePKY/57cJksL39eKHUjWghgjHNLCh lBXzXPT4fKuwbSJWGknPJw3meEIra1N17uTmLOZlOKY9lJPHdEHIh2XBDyeS06RkDdbK qxNlfzBiKvQ1/uLk3j7jLQRq/IJUdGCPvNWEapEVP1I9CjqeWsiZQ30lnc3DimNG15t0 Z2PWAqIN63qQ7CydQijRTYeELoOgZSLb/Hdxja2iOAUXXMVk/GHfjsq7ZicMERnt2XmS iRhpMV5yihgmNYOOe4B2+BD3sImNDJwgwDrGGtt4uI6D2II2DXVJV920SNFelhicDg30 S32Q== X-Gm-Message-State: APjAAAW47h+0I9x4+kKfBsdoFmdZvSXtWtqxR1WTkGWkq7wnCP2lISFv xWFvirgJQOavJa5RpNzp/JcVJ3erJxA= X-Received: by 2002:aca:33d5:: with SMTP id z204mr233710oiz.120.1577731402330; Mon, 30 Dec 2019 10:43:22 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 17sm15966152oty.48.2019.12.30.10.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 10:43:21 -0800 (PST) Date: Mon, 30 Dec 2019 10:43:20 -0800 From: Kees Cook To: Peter Zijlstra Cc: Eric Biggers , linux-kernel@vger.kernel.org, Ingo Molnar , Will Deacon , Elena Reshetova , Thomas Gleixner , Anna-Maria Gleixner , Sebastian Andrzej Siewior Subject: Re: [PATCH] locking/refcount: add sparse annotations to dec-and-lock functions Message-ID: <201912301042.FB806E1133@keescook> References: <20191226152922.2034-1-ebiggers@kernel.org> <20191228114918.GU2827@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191228114918.GU2827@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 28, 2019 at 12:49:18PM +0100, Peter Zijlstra wrote: > On Thu, Dec 26, 2019 at 09:29:22AM -0600, Eric Biggers wrote: > > From: Eric Biggers > > > > Wrap refcount_dec_and_lock() and refcount_dec_and_lock_irqsave() with > > macros using __cond_lock() so that 'sparse' doesn't report warnings > > about unbalanced locking when using them. > > > > This is the same thing that's done for their atomic_t equivalents. > > > > Don't annotate refcount_dec_and_mutex_lock(), because mutexes don't > > currently have sparse annotations. > > I so f'ing hate that __cond_lock() crap. Previously I've suggested > fixing sparse instead of making such an atrocious trainwreck of the > code. Ew, I never noticed these before. That is pretty ugly. Can't __acquire() be used directly in the functions instead of building the nasty wrappers? -- Kees Cook