From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C755C3C5833 for ; Thu, 30 Jul 2026 21:10:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785445805; cv=none; b=gLz8fsl1yt8AuN/GOPtDdk6FL6jTTrqikj3RJ/U5v0AqCYXFQEa5VI4KgS0Izg+V1XSHF1uRpBW4KtQTjGcXQkTK4mbLlCom0RKQnGdfuUylekE48R2x6YHPUR5yc8Rxsm4CoRiMJfVuegQuk14gTSZ3rUpOt2j+fvg02KNBk54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785445805; c=relaxed/simple; bh=h4gAl5X4nGE0SU+Gh3X/MeeFPIcUPYTfpNfqjtezBaA=; h=Date:Message-ID:MIME-Version:Content-Type:From:To:Cc:Subject: References:In-Reply-To; b=fMphIFiSTnxGV/99ePsjteW4ir/t6mNVjqTwumCXcCae2AzfXpCmYGBWFdV11WCPbuXwGI/P2S911JiiLuW0j8ao6QU2nePn/bLio73jiA4h/hvgg3ZZh5yE2l06hGhl2vWazhONqyxWfB7fZPUS3p9GUmViQdxEnkybMaQTYs0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=fczzRw2g; arc=none smtp.client-ip=209.85.160.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="fczzRw2g" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-51c16ac21acso1616791cf.0 for ; Thu, 30 Jul 2026 14:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1785445802; x=1786050602; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :content-type:mime-version:message-id:date:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lMLsf+LQaJK9TyVbvhOADIYNpgfmalBwRgJCFWQKWPY=; b=fczzRw2g8JaX6smDaTZ1xAWIookwAoR0D/4mwj9qfdsvrT7xHZK7cUCTG/iaRkHggR P3+FocISR0RAqycHZjKdHWOKhym2LY4kDNpJitfSn1SLsP0xJldbL6dnOQiOH+Ui8UO0 0s0iikmvOL5UJp8pwQK+3zogN5R8tgZiWKl76qP7zUMCexyqTjscuP09H47el/A5LOPQ bLAyklxxIuDg1PEhhjAUarpxLsz/dzQ2nx+5CRrhHNyoAb765r33FrSBLNFCzRh86N+G hs6CfIpW2mf0Oi0YshQ5vbz8SdmW0ePcRjHnZpBqKUUGsXip8dYktnA8REVJHQrMq9lN Y3bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785445802; x=1786050602; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :content-type:mime-version:message-id:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=lMLsf+LQaJK9TyVbvhOADIYNpgfmalBwRgJCFWQKWPY=; b=Pp+8c2fWzNSP39a3vmkkehFEqqztACg4wMfG8Z/BIjCL/FMyWNNCnqQ2KgBqkQhdFN 1kILqGyiA5PBp3WSoUj0Wkn7xcRCs4hBgW/nNX+KsXmJOJ9Z2pvbLYUsw9GnvaNOwRds M5LzGwmEU52n7BCuzWTgGfGxG51T8jJnnYy8C+HueEeM16V2HdUmSqVVmfpkAr0WduVL Uwo0UtfqwHEqIVZZISj1AtC6IzIIa/dqnC2q1efFHXqjcs+fYhXYtm7QfOudeCUu4FZj QzEOqs3Pd+1JVUZGI+1N0wZ1SNegWZg+dbZZlEaCJp7Gs7mdfvpqH3+5FcOL8PzO5Nhu 7CGg== X-Forwarded-Encrypted: i=1; AHgh+RoSPssagGoxWSJACj9e6o7GSp+2zxMd5Hithvo4Nvu3AmHqHAVd9c9+BB2V3G8zIb5s2ZG9dCeqK8nTt0E=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7GFIYgGFPCMh3FQoDwH9ZAImybGXxw8u9soNMmbcUJQ6U0zwV DTG52KPP4BLaIsE/6zhRGILk8SZl/TwA2qC2gkUUoEIXaqlQ+IzprQDRRbk80Sztvw== X-Gm-Gg: AR+sD11/N93HHyF3qPhnXDFBu2TxdGl2jAXOKZNYDJGR2Q3vBQbZ1CLYgwc7AX0QajS EEg6hlEOBIorxP0WR7NEy6J/dUX3d6W9RY82fO73ylwHdCY8roQpySV0IA+1hO4oAjV2O4Fe9jR f/LEHl05qmNJEqT9qSW52wYw2qoGcsZLzoNwWbrHcaNtwYfuZ7/lamMyVLt8RNmePtGQpy64cF+ /7J4cIcaMJi/0mK/62FjcXQwZMo7O4KuL5r3AefHGt0iE+LJMYoT+LN74p/uZa8kg19NA7Ffj7/ jbVCsazGIQKzt26Tqu5AG53HZG+wvBc80xmiunj9Nr1rZALt6i30nq/eIc7C1WGTen3oxqe/lJH raqRwHsoRIxbJjrwRM/kWJSp394wI1V6mWuggeFtxDy+mV81nsJ7VOMgk0BeE0GvtmgP9JLVEby Cv70nTPnVVZ5bjA9PPax4zC8cZlcbA3s/3Np03KOtTnC6smusSPjY509/hXUZwLO+J1tcYBs8kE xWDOccgVUVfeSZSXznw7ymFTjX66C1Acm33wvmgZuL4 X-Received: by 2002:ac8:7e81:0:b0:51c:1d18:2fe9 with SMTP id d75a77b69052e-52b3836970emr48411021cf.5.1785445802045; Thu, 30 Jul 2026 14:10:02 -0700 (PDT) Received: from localhost (pool-71-126-255-178.bstnma.fios.verizon.net. [71.126.255.178]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9083fdbc35fsm1954776d6.24.2026.07.30.14.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 14:10:00 -0700 (PDT) Date: Thu, 30 Jul 2026 17:10:00 -0400 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: pstg-pwork:20260729_1758/pstg-lib:20260730_1437/pstg-pwork:20260729_1758 From: Paul Moore To: Carlos Llamas , Stephen Smalley , Ondrej Mosnacek , "Christian Brauner (Amutable)" , Daniel Borkmann Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, Alexei Starovoitov , linux-fsdevel@vger.kernel.org, Carlos Llamas , stable@vger.kernel.org, "open list:SELINUX SECURITY MODULE" , "open list:BPF [MISC]:Keyword:(?:b|_)bpf(?:b|_)" Subject: Re: [PATCH] selinux: bpf: check SBLABEL_MNT before isec init References: <20260730181008.3654413-1-cmllamas@google.com> In-Reply-To: <20260730181008.3654413-1-cmllamas@google.com> On Jul 30, 2026 Carlos Llamas wrote: > > selinux_inode_init_security() marks the isec as initialized before > checking if mount labeling is supported (SBLABEL_MNT). This was fine > until commit 9722955b5430 ("bpf: Add simple xattr support to bpffs"), > where genfscon bpffs mounts fail the SBLABEL_MNT check as expected (no > xattrs) and yet leave the isec->initialized. This breaks subsequent > calls to inode_doinit_with_dentry(). > > Do the SBLABEL_MNT check before the inode security is initialized. > > Cc: stable@vger.kernel.org > Closes: https://lore.kernel.org/all/akWdcp6P0FkNDzBk@google.com/ > Fixes: 9722955b5430 ("bpf: Add simple xattr support to bpffs") > Signed-off-by: Carlos Llamas > Acked-by: Stephen Smalley > --- > security/selinux/hooks.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index 8d6945edae7a..09a12eb8652c 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -2980,6 +2980,10 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, > if (rc) > return rc; > > + if (!selinux_initialized() || > + !(sbsec->flags & SBLABEL_MNT)) > + return -EOPNOTSUPP; If we're moving this check, we should probably just move it to right after we assign 'sbsec' at the top of the function. The calls to inode_mode_to_security() and selinux_determine_inode_label() aren't doing anything useful in either the !selinux_initialized() or !SBLABEL_MNT cases so let's avoid the unnecessary work. > /* Possibly defer initialization to selinux_complete_init. */ > if (sbsec->flags & SE_SBINITIALIZED) { > struct inode_security_struct *isec = selinux_inode(inode); > @@ -2988,10 +2992,6 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, > isec->initialized = LABEL_INITIALIZED; > } > > - if (!selinux_initialized() || > - !(sbsec->flags & SBLABEL_MNT)) > - return -EOPNOTSUPP; > - > xattr = lsm_get_xattr_slot(xattrs, xattr_count); > if (xattr) { > rc = security_sid_to_context_force(newsid, > -- > 2.55.0.508.g3f0d502094-goog -- paul-moore.com