Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1887616rdb; Sat, 2 Dec 2023 13:34:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8T+RKfnEP1laXXrh1Tfk8561yYjm4+E6HEU3zXEa/MFIdLk1SQCcPdahuHXwUeyIooGkR X-Received: by 2002:a05:6a00:2383:b0:6ce:2731:e876 with SMTP id f3-20020a056a00238300b006ce2731e876mr2141756pfc.61.1701552887853; Sat, 02 Dec 2023 13:34:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701552887; cv=none; d=google.com; s=arc-20160816; b=Gch40E9nETdf/cd6BX1hDBE6JrLt/WvyNYdoJxS/RhBlSsLsd5qHw+DHWOFaMHhEIq HQrhzZBDoUZsDn/aRb89302V9P8wTThLXOGEyOF+PKiSOxj9LjGfgIhMNjjUmhK4ilsu 4j9irO1JpIEDE5sBzGgE0EK0PLdGSaMRCKVmu2IZ7pZR8bFWXMtDYQBHN5BA/YkY6kWq Al66BdRtnELtCsKCOvYKOqCH6rPuzsnpJkDCjBh4pmh5A+APPsrDdtggYFuc+2Ezrzs4 wmMkR2n2eS82IxMshaudkdE3wpS6yr8DM+hr+D3skqzDC7VR9R+xUpm5ITn93iW9kqjT 0SwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZLyDJvxTAas36YBBDf/PjaQIfAeNkr7hpF36GzNdMaw=; fh=R1OtVe86eJmD9by0q0A0YYvm+vvf5c6kUtMfFt1w66o=; b=A5e/o5PYj341oXtkNiBXX8q7T9QKxmkL7skdQZWEvCcopls6mQeMgQ7AygbwVI2WUz PmJiZWTxf0nW0IDwLJUFaGhWCVxEWLavgkKeRADs11rpoC2I5o0vifaj37t2L8qh9axm D2YoV5mO+eLvM5d6ju9Xkb2gAHYf2xRsvwgTwwIx8/JhaOJShngygu58f3AaUpDMA1y9 YuQy+7l7Zcjz4ag/TErgry2bVxeGAEzZj6XzJIDQzCVzAmBYrYTlaOcEwJVl5Tf/HEGF 0kTzLUOqtHoKe8TotWx5WjIs87GY489nKdJ8fVDKNPh/P5sL/b80m6/b7tDViNgArKUW z3eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HhHWXOEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id c2-20020a631c42000000b005bd641c3614si5203293pgm.769.2023.12.02.13.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 13:34:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HhHWXOEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7F95C807C743; Sat, 2 Dec 2023 13:34:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbjLBVe2 (ORCPT + 99 others); Sat, 2 Dec 2023 16:34:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLBVe1 (ORCPT ); Sat, 2 Dec 2023 16:34:27 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6BAEE5 for ; Sat, 2 Dec 2023 13:34:33 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so1439574a12.1 for ; Sat, 02 Dec 2023 13:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701552873; x=1702157673; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZLyDJvxTAas36YBBDf/PjaQIfAeNkr7hpF36GzNdMaw=; b=HhHWXOEgmkx+Lle4PbqTWAgE0KdG45JToNHkLdsGrjdGZqNbxqw8kJrHygouAcqV+d owZ53Q5cVNkeHjlamz2xSsLdmrm4Dtg/GD9KPs8fVl/ZoW+uWRmfVtqde8T4aanFdzhp FQBhZJxkxPT/I7q2DI/ix+HmsiigJ4epjSp+M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701552873; x=1702157673; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZLyDJvxTAas36YBBDf/PjaQIfAeNkr7hpF36GzNdMaw=; b=DStVQdzbhPuc+nhj6i7L24ObuDMcXvtAR48zz+4c92kifK5mG9XtEX0UgIZmyuZsnp fPM6b9WXCiq5zPD6SfPgGIKOim69NSu8NSTnu29wyLPBwHgPzQ7+a5LaWl28sOGQH+Qe kphO6L/nUSJ2tQWbATYsdwAC5W6uoSC1aNkz+f0kZTqyoi/cIxf2LfJ7QG8i5VzOHgsA a0JgbNHeVPHZvgiXPPSNhFbGBpCZxeLAWWssCjELR/BFQu4ka4JMDdVmldiN8uEjvakx G9kkLjTm5GlPxAUlR6Pm1SSe4Ll1lZiKrs29S5bz3YnDSy8Iy+YfMsv8xl6uQ4L6zsB8 FLgQ== X-Gm-Message-State: AOJu0Yy5FBfiQ0UOBgKBu3mg5L/KJUwPNOb4vU4sbKgWmvNT/7iktbWT 7Bxu3Rk+zyT99+5waqXoOEEZDw== X-Received: by 2002:a17:902:720a:b0:1d0:6ffd:e2ef with SMTP id ba10-20020a170902720a00b001d06ffde2efmr1311703plb.137.1701552873337; Sat, 02 Dec 2023 13:34:33 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id d9-20020a170902aa8900b001cfc50e5ae9sm5626968plr.78.2023.12.02.13.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 13:34:32 -0800 (PST) Date: Sat, 2 Dec 2023 13:34:32 -0800 From: Kees Cook To: Al Viro Cc: "Guilherme G. Piccoli" , Christian Brauner , Peter Zijlstra , linux-fsdevel@vger.kernel.org, Tony Luck , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 3/5] fs: Add DEFINE_FREE for struct inode Message-ID: <202312021331.D2DFBF153@keescook> References: <20231202211535.work.571-kees@kernel.org> <20231202212217.243710-3-keescook@chromium.org> <20231202212846.GQ38156@ZenIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231202212846.GQ38156@ZenIV> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 02 Dec 2023 13:34:42 -0800 (PST) On Sat, Dec 02, 2023 at 09:28:46PM +0000, Al Viro wrote: > On Sat, Dec 02, 2023 at 01:22:13PM -0800, Kees Cook wrote: > > Allow __free(iput) markings for easier cleanup on inode allocations. > > NAK. That's a bloody awful idea for that particular data type, since > 1) ERR_PTR(...) is not uncommon and passing it to iput() is a bug. Ah, sounds like instead of "if (_T)", you'd rather see "if (!IS_ERR_OR_NULL(_T))" ? > 2) the common pattern is to have reference-consuming primitives, > with failure exits normally *not* having to do iput() at all. This I'm not following. If I make a call to "new_inode(sb)" that I end up not using, I need to call "iput()" in it... How should this patch be written to avoid the iput() on failure? https://lore.kernel.org/all/20231202212217.243710-4-keescook@chromium.org/ -Kees -- Kees Cook