From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 E0A333054CB for ; Thu, 25 Sep 2025 16:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758817544; cv=none; b=gTIG0nNDtl/s8tfH4XCGwn84zKfD0v24h+IkQANdNnt7zlq3INOFul9QDYjjSBPdlHF/p/7JEzjurkerkoJLF/3b6U1g81AgcPAWUj5Zeure9rK1pcyMuIde8w6kUW0TiDKe9voSySrvd6W6h4zDKOJh+mrcI30eL2dKY/GB6ig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758817544; c=relaxed/simple; bh=e2zTOUXdFrzwKW6u+2BZRJvKLeVeKwka9WRmiQrAMKE=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=gY4iBI57t0nmRDt4khTNGzujhIypzxopQ3q76iLsf5iE34MjVEHJ9N0dfo5iuZoFgNKl4F0SM0pYY0TZbzh8kEGgHdvFHXDtMOiiFQIlL8lW1sWiKfjItUTiALSEKwOnivyjsq13JImXkAwfQ5gUF+SN0c/JqfsVdZZecfBFjjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KPGQOCdC; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KPGQOCdC" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-46e2e363118so11917745e9.0 for ; Thu, 25 Sep 2025 09:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758817541; x=1759422341; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=sp90x0HI2604VafoUtGiosJXSBDN/QH7OATIlIgLDsg=; b=KPGQOCdC5XPB1/J8eD/D2m2IQe9ey4w1pU0lFDgu0rBjbdlsLfTMCcW8gjxup3EE2d vwGRuphi2MRe65mp4c6zCM5ooqfYNJWJl+jm03jOAuzAAQf3aRS5YMhmvPJzobwkev4D ujytbH4Xd6O6hXctlcBK6KF62ZdfC13ozys4wdm0r8zBtLDBaZsqcDgCLZd+2DF05oc3 C82AGnfGksYADjMFOCk2MfC+HJ7C2D9vhEzmkTlJnGCluskTEPpuM7UV0A3H9ygKRdMS S1f84YsVcBTeryfm35SuXmfDuEFO4wYv9erN4eylrXd4XGdWdCI6leP+jdBV3z99jk+f +uBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758817541; x=1759422341; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sp90x0HI2604VafoUtGiosJXSBDN/QH7OATIlIgLDsg=; b=gxu3Cj7dpZ5ByijXSaOABqdD0xr3XDzcti8XY1E9REczmP21u3Gmd7vD9dzghz0tvE bzvQcCEfWGmoEx2c5XHmJuZ75wq9cPgavcLnXkP8oGb/af7tquw3IbHoBooXgzhTelNT Gq/seJWC6p8nCP08f6iMlbqXmtXRzfvB6zl85TJSXwbhRt0Q8IvJ8Bikof+WyAJqOFTd 1ErJLJE2jwyONgCPRpQ97pQMW18Bdvi+epY+UjvlJK7NvanJ188jbAcvyUE3Ez/Byqwt t7XJRN2iVZ1T0j/h64wkDfTubvsp8shdNhxPbHJpIG8jcsVlpCJtshxi5VmsgmDCf/Gb phxA== X-Gm-Message-State: AOJu0Yw012DrcdcssV+VBmS1npQsheYnjGSmX8H7gnO+jb/65AoXMErB YhhOH7I66skEtaQMH8vdR9NwuSFkiiZ9CZQJCJgp3QiKoQz1ufWN+T9n X-Gm-Gg: ASbGncu/cGFiwGgHXXHcI7sChhOcQfKzPlezIJNMj/07gGSuiw+sQMA1Wy1I3eT/gRN Ywkt6Ff4p81noiXl9Vdg5mOT8bFv94joyWflUEfZ2USaI/LzKHVFi9CLgiOSoGVAXUV/cvl5XXB damxTwlGsPB/pVkJMzrKlQMJpX7CHUTNIgrFM54UQFPJyXeB6NNWzr3yqn2WFqpZ7CyxXll+EZU 2Az21pHYgNm5nktkMbz9t7vpmIz0V+sFQmow3AnoPoI/CNJDgssn+UHq0aKVkT8gfRGPz2b/hlW CTR+8E1VGGxrhZUkl89iUhraoYOogRHGCJ9eV7khtlrK9smXnbZzHXelta/n+3kql0IPl+YWq1F lo/miDPckYGomaRPbqgBx/hlO/CYT3Jgfl6i03LChfP2tYnv2LunzKkMMfw== X-Google-Smtp-Source: AGHT+IE6mWeX6t2AH8HBB+UpOYdjBBRGFMRn/aYCb3judhabM8SWtsPgFs4uiI3dBuK0IPElmXVzNA== X-Received: by 2002:a05:6000:4387:b0:3ec:1fff:3b25 with SMTP id ffacd0b85a97d-40e3a2eef9emr4065514f8f.0.1758817541137; Thu, 25 Sep 2025 09:25:41 -0700 (PDT) Received: from [10.33.80.40] (mem-185.47.220.165.jmnet.cz. [185.47.220.165]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-40fac4a5e41sm3950563f8f.0.2025.09.25.09.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Sep 2025 09:25:40 -0700 (PDT) Message-ID: <9df66167c205e341bd5896376e06950aa7bd7240.camel@gmail.com> Subject: Re: [bug report] [regression?] bpf lsm breaks /proc/*/attr/current with security= on commandline From: Filip Hejsek To: Paul Moore Cc: linux-security-module@vger.kernel.org, James Morris , "Serge E. Hallyn" , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, regressions@lists.linux.dev Date: Thu, 25 Sep 2025 18:25:39 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2025-09-25 at 11:28 -0400, Paul Moore wrote: > On Thu, Sep 25, 2025 at 10:56=E2=80=AFAM Filip Hejsek wrote: > > On Wed, 2025-09-24 at 17:24 -0400, Paul Moore wrote: > > > On Sat, Sep 13, 2025 at 1:01=E2=80=AFPM Filip Hejsek wrote: > > > >=20 > > > > Hello, > > > >=20 > > > > TLDR: because of bpf lsm, putting security=3Dselinux on commandline > > > > results in /proc/*/attr/current returning errors. > > > >=20 > > > > When the legacy security=3D commandline option is used, the specifi= ed lsm > > > > is added to the end of the lsm list. For example, security=3Dapparm= or > > > > results in the following order of security modules: > > > >=20 > > > > capability,landlock,lockdown,yama,bpf,apparmor > > > >=20 > > > > In particular, the bpf lsm will be ordered before the chosen major = lsm. > > > >=20 > > > > This causes reads and writes of /proc/*/attr/current to fail, becau= se > > > > the bpf hook overrides the apparmor/selinux hook. > > >=20 > > > What kernel are you using? > >=20 > > I'm using Arch Linux kernel, which is very close to mainline. I have > > also tested my own build from git sources (I used a stripped down > > config which I based on config from Arch). Example in QEMU: > >=20 > > $ qemu-system-x86_64 -nodefaults -accel kvm -cpu host -smp cpus=3D2 -m = 1G -display none -kernel ~/git/linux/arch/x86/boot/bzImage -initrd ./initra= mfs.img -serial mon:stdio -append 'console=3DttyS0 security=3Dselinux' > > :: mounting '' on real root > > mount: /new_root: no valid filesystem type specified. > > ERROR: Failed to mount '' on real root > > You are now being dropped into an emergency shell. > > sh: can't access tty; job control turned off > > [rootfs ~]# uname -a > > Linux archlinux 6.17.0-rc7-00020-gcec1e6e5d1ab #3 SMP PREEMPT_DYNAMIC T= hu Sep 25 16:28:02 CEST 2025 x86_64 GNU/Linux > > [rootfs ~]# mount -t securityfs securityfs /sys/kernel/security > > [rootfs ~]# cat /proc/cmdline > > console=3DttyS0 security=3Dselinux > > [rootfs ~]# cat /sys/kernel/security/lsm; echo > > capability,landlock,lockdown,yama,bpf,selinux > > [rootfs ~]# cat /proc/self/attr/current > > cat: read error: Invalid argument > >=20 > > (Note: In this example, uname reports archlinux, but that's only > > because I based the config on Arch config, it's not actually an Arch > > kernel.) > >=20 > > Maybe the different behavior is caused by a different config? You can > > find the Arch config at [1]. Based on Fedora package sources, I think > > their config has > >=20 > > CONFIG_LSM=3D"lockdown,yama,integrity,selinux,bpf,landlock,ipe" > >=20 > > while the Arch config has > >=20 > > CONFIG_LSM=3D"landlock,lockdown,yama,integrity,bpf" >=20 > That's interesting, you're running a LSM that isn't normally run in > your distro and you're not properly initializing it (no policy load). > Both are acceptable, but you're definitely operating in the > corner-iest of corner cases ;) >=20 > I'd have to look at the relevant code, but I suspect that with > "selinux" missing from the CONFIG_LSM list and you manually specifying > it on the kernel command line with "security=3Dselinux" you are getting > it placed at the very end as opposed to what I saw (I have "selinux" > in my CONFIG_LSM list). It's further complicated by the fact that the > procfs call into the LSM's security_getprocattr() hook is going to > pass a 0/zero into the hook as the @lsmid which means "first > available". >=20 > Considering that the "security=3D" parameter is a legacy option, I'd > encourage you to try the "lsm=3D" parameter (make sure you specify the > full list of LSMs you want, in order) to see if that works. Yes, that works. The problem isn't that there wouldn't be any working configuration. The problem is that a userspace program (in my case CRIU) was broken and I had to spend time figuring out what the cause of the issue was. I'm not the only one who encountered this issue [1]. I know that at least Manjaro Linux used to ship a grub config with security=3Dapparmor at some point (and maybe still does). I no longer use Manjaro Linux, but I still had this parameter left in my grub config. [1]: https://github.com/checkpoint-restore/criu/issues/2033 So in reporting this issue, I was just hoping to help future users avoid the same problem. If you think this is a waste of time, feel free to ignore this (and sorry I didn't make this clear in the first email). Lastly, I will offer a few thoughts: * The fact that the security parameter can break programs like this is highly non-obvious and undocumented. * The BPF LSM hook which causes this breakage is useless, because a BPF program cannot be attached to it. I think it would make sense to just remove it. * Switching to using /proc/*/attr//* solves the problem from the userspace side. Unfortunately, selinux does not have its subdirectory in attr. Kind regards, Filip Hejsek