From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E545FCD4F24 for ; Tue, 12 May 2026 17:49:33 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4gFPHJ4LNdz2xjQ; Wed, 13 May 2026 03:49:32 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.105.4.254 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1778608172; cv=none; b=CGGkRzYIcF/RWs43bxn8fi6PeWE+sUkPvZf9xzVX+CseTOVAcZ9Y0i6CVs1J5fAIiTTtKh7pQ+r/9KMFXWs5yL0eSpKYWGumur4Ptf0VDMW3jLhwcUW9txuoCW/7piWNGaXVch2cLXTxrVrr8vtKZ3/u3qd8ehM2tOtj3YqIPCTnVoDvuRtBYBxBdkEhbb/xGimy90DgB/osohkKQUm331NPFFf41WHnJam/vdfVtNEy/vgIH2Mox9aTh6uLE4KhZXr9o1zMy845a8t7ySqTIR8p2xLkRMrALANTqgqhbvf0yQH0kIPLJE3OjZYqbDakzV/w5HQI9IQjCkv23jOb4A== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1778608172; c=relaxed/relaxed; bh=05ATtaj5Nh47boMKVuEC/AaNxrFWV3ENlKLTMOVJjgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lwexW+YHepatMu4nfq3aXwpAVWIdQbATWv7z5XFpqfiheKj0UGyF1jp8WpuxOWxq5LfN0hsw3p2g/nPHk9P+3KnUyGsBRFQFVmPF3OpDjmTeH5HDV+Qe4ewqjw1cBWSZlqPl0L/At3Pclw5u9nvNXEiLnudR5YUtamvsn7eW1Hfwhz1nbGkl0WFMEQHVYvcaLtjomIWFDn2bBvdnu8/y/Xe9aQmmHSPCRKPvXFCavQuhWFUzdPHNz4YQY6GwkcCnn6JBWgnlTi34BKp8IqX/jUL6Z4YekkYZhy1qfGcx44dkCEkX4p6mmZuKI4FQ1dKngI1pcfgtL0KQrLPk6F3wtw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; dkim=pass (1024-bit key; unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qAo7GGzb; dkim-atps=neutral; spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=gregkh@linuxfoundation.org; receiver=lists.ozlabs.org) smtp.mailfrom=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qAo7GGzb; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=gregkh@linuxfoundation.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4gFPHG6QTnz2xb3 for ; Wed, 13 May 2026 03:49:30 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 2230A600CB; Tue, 12 May 2026 17:49:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E6C1C2BCB0; Tue, 12 May 2026 17:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778608167; bh=kWtPhROQqPhgoX3k0skKuZmLauLRMJdtRbw6LdrvqoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAo7GGzbW6tm2Y0FCwrSa8In5SHBjj1nb705/70h7atPe8vP79CFXgn04InnyenHI khwrl9Dm4ejH+ITWzNdgbGHgL2Q2UlQm0Tulwxi6lBfFxVvpZJGUaLOQ43UMgsp4vh VGg0z0mgLbLlWBbta93/4W97tau/LwT5GXmXyduw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, Amir Goldstein , Serge Hallyn , Paul Moore , Sasha Levin Subject: [PATCH 6.12 180/206] fs: prepare for adding LSM blob to backing_file Date: Tue, 12 May 2026 19:40:32 +0200 Message-ID: <20260512173936.672348670@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173932.810559588@linuxfoundation.org> References: <20260512173932.810559588@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: linux-erofs@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein [ Upstream commit 880bd496ec72a6dcb00cb70c430ef752ba242ae7 ] In preparation to adding LSM blob to backing_file struct, factor out helpers init_backing_file() and backing_file_free(). Cc: stable@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-unionfs@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Signed-off-by: Amir Goldstein Reviewed-by: Serge Hallyn [PM: use the term "LSM blob", fix comment style to match file] Signed-off-by: Paul Moore [ Used kfree() instead of kmem_cache_free(bfilp_cachep, ff) ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/file_table.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) --- a/fs/file_table.c +++ b/fs/file_table.c @@ -60,6 +60,12 @@ struct path *backing_file_user_path(stru } EXPORT_SYMBOL_GPL(backing_file_user_path); +static inline void backing_file_free(struct backing_file *ff) +{ + path_put(&ff->user_path); + kfree(ff); +} + static inline void file_free(struct file *f) { security_file_free(f); @@ -67,8 +73,7 @@ static inline void file_free(struct file percpu_counter_dec(&nr_files); put_cred(f->f_cred); if (unlikely(f->f_mode & FMODE_BACKING)) { - path_put(backing_file_user_path(f)); - kfree(backing_file(f)); + backing_file_free(backing_file(f)); } else { kmem_cache_free(filp_cachep, f); } @@ -255,6 +260,12 @@ struct file *alloc_empty_file_noaccount( return f; } +static int init_backing_file(struct backing_file *ff) +{ + memset(&ff->user_path, 0, sizeof(ff->user_path)); + return 0; +} + /* * Variant of alloc_empty_file() that allocates a backing_file container * and doesn't check and modify nr_files. @@ -277,7 +288,14 @@ struct file *alloc_empty_backing_file(in return ERR_PTR(error); } + /* The f_mode flags must be set before fput(). */ ff->file.f_mode |= FMODE_BACKING | FMODE_NOACCOUNT; + error = init_backing_file(ff); + if (unlikely(error)) { + fput(&ff->file); + return ERR_PTR(error); + } + return &ff->file; }