From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sonic306-27.consmr.mail.ne1.yahoo.com (sonic306-27.consmr.mail.ne1.yahoo.com [66.163.189.89]) (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 1E23B23372C for ; Tue, 14 Apr 2026 17:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.163.189.89 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776187525; cv=none; b=RE3Oi5d9XCSZ1SEGFxTju/o5c8+410vcgwvDb2ECsHfN+auIKxWiqZTowEqsObHqsGM8MMAwQKNphE5KGgado/QJ/zZAAkzlrOgNYOCx/FrpYI9qc9qym96hQvWs2NqdacvTSTbY/pslqEPVnWh+rLB/V8Knl5JNMEcR+8JEYYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776187525; c=relaxed/simple; bh=1R8ck4miS/ptVkXJyvQbxFUMSaydM6XzvJ8O7WgZWIw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=upad36lwh+9r8SjUz/IZrdGacK9uBDGYUZsnvVcmDCLR+OUTxJZyBg6AgXxoF0vPoWN+bXz9lkKY0pEdk9DWDSl4Mf2xcOBcfoFJGFtSKIPIQy6ql/G2EI0vFEC85UBR81c3mG8I1X/lf1VOjQ5a82aeW1HYUPebeWiVHDGVBMA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com; spf=none smtp.mailfrom=schaufler-ca.com; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b=Hx2ApAZA; arc=none smtp.client-ip=66.163.189.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="Hx2ApAZA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1776187523; bh=kj1sfOzHMYPt1j5hcLFkJwgzxKgQtthmIu4jaY8YNj4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=Hx2ApAZAgctlTQdFSZNc1yjJdR5ADOXygeOlKO2Xgboe5QLK/NX1foWxd+Wd8G5JT6unAA94KUwVeUM3D6Qwwkmj1Cw+2brT6aKf5PwG2UFsGzdIVa3eRiRAb/OLz7ATlaxJnV5IjAZk69unoTycp1ROKpUTlmlr28QEMXUrcrfvxuHxvsdWhTGRxFtNKfozNYo0pQEJ6dXXPZ5aspX4s7Ng/Ty0uMJ7Xt/CeM9oVWKPqyzIOVIdtUbAioe6Aik3Fi2W1EN0/7bVNYy+HvFIzzySdn30MAHDCC6QjHubw1evuv01D3q8F2+yC9/MVWv8aBTmZlYlsfN8XZPjw0FhOw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1776187523; bh=Fcx5aDR60dSLmtgzqBMi6zxF+/uWaEt75xa1ANj59pU=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=LeIjbKoQ6pePX6nSD6672KDMeN1SZbaph6/BUiwAORJH1+NI619JHWi1PU/a6dpSVuRloxEbzHQRt7RhOWA3awUr5qE3TH/Foq3rfnw+quMFq9cQWWlZspsE6dNFyL/pFCbv5L1/mjTCtWwEtaIQaiB8hlGkYUwasElJ4/z+gzC4xw0qfUlnhqPFPGW9sXw4HyK6BXqkvqJLy19jkCE0C6gWvqdTGw/PT0OQSzBH8k9Hfn+uRLIdgQjn41PR9dOEniDgRxFyoOMXqg3aWYI0HME6txtWZfxuNaP9xIUTgs0/2gHgXM1idIIsWBNO0A4QXgIp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92jOYOqAIxLiQ wFqHkyjoc1lHo_.d0LR1wbriOjl8MMRkZgR2lIhcbp_kTYyJvIHb5ROtHi8LQ3wchvHgkAormXQG iyX9GbH9wdyJRZ8P2pUhMFikVgIFb4wA7IRbHwSUYQsoNAnI8q0Oz6oJyl1Hh5lkEtIkuPdLZRSX ZEb.bUvPlcHIcCXy_tk5kTmuTiHYYR7zwQIFujMLOdr_LoexoHU5wDYhdk_Ln X-Sonic-MF: X-Sonic-ID: 30480471-503a-4ddb-98f5-de4e115036aa Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Tue, 14 Apr 2026 17:25:23 +0000 Received: by hermes--production-gq1-6dfcf9f8b-xb5j9 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 2513f61ee43f0821ef423277142ceb5b; Tue, 14 Apr 2026 17:05:04 +0000 (UTC) Message-ID: <4cf6b20b-f53b-4b5e-ba03-c7ac01bec0c2@schaufler-ca.com> Date: Tue, 14 Apr 2026 10:05:02 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/4] Firmware LSM hook To: Jason Gunthorpe , Paul Moore Cc: Leon Romanovsky , Roberto Sassu , KP Singh , Matt Bobrowski , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Saeed Mahameed , Itay Avraham , Dave Jiang , Jonathan Cameron , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org, Chiara Meiohas , Maher Sanalla , linux-security-module@vger.kernel.org, Casey Schaufler References: <20260331-fw-lsm-hook-v2-0-78504703df1f@nvidia.com> <20260409121230.GA720371@unreal> <2dd138a2ae87f90c55dbc3178d9c798294fd4450.camel@huaweicloud.com> <20260409124553.GB720371@unreal> <20260412090006.GA21470@unreal> <20260413164220.GP3694781@ziepe.ca> <20260413231920.GS3694781@ziepe.ca> Content-Language: en-US From: Casey Schaufler In-Reply-To: <20260413231920.GS3694781@ziepe.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: WebService/1.1.25495 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo On 4/13/2026 4:19 PM, Jason Gunthorpe wrote: > On Mon, Apr 13, 2026 at 06:36:06PM -0400, Paul Moore wrote: >> On Mon, Apr 13, 2026 at 12:42 PM Jason Gunthorpe wrote: >>> On Sun, Apr 12, 2026 at 09:38:35PM -0400, Paul Moore wrote: >>>>> We are not limited to LSM solution, the goal is to intercept commands >>>>> which are submitted to the FW and "security" bucket sounded right to us. >>>> Yes, it does sound "security relevant", but without a well defined >>>> interface/format it is going to be difficult to write a generic LSM to >>>> have any level of granularity beyond a basic "load firmware" >>>> permission. >>> I think to step back a bit, what this is trying to achieve is very >>> similar to the iptables fwmark/secmark scheme. >> Points for thinking outside the box a bit, but from what I've seen >> thus far, it differs from secmark in a few important areas. The >> secmark concept relies on the admin to configure the network stack to >> apply secmark labels to network traffic as it flows through the >> system, the LSM then applies security policy to these packets based on >> their label. The firmware LSM hooks, at least as I currently >> understand them, rely on the LSM hook callback to parse the firmware >> op/request and apply a security policy to the request. > That was what was proposed because the idea was to combine the > parse/clasification/decision steps into one eBPF program, but I think > it can be split up too. > >> We've already talked about the first issue, parsing the request, and >> my suggestion was to make the LSM hook call from within the firmware >> (the firmware must have some way to call into the kernel/driver code, >> no?) > No, that's not workable on so many levels. It is sort of anaologous to > asking the NIC to call the LSM to apply the secmark while sending the > packet. > > The proper flow has the kernel evaluate the packet/command *before* it > delivers it to HW, not after. > >> so that only the firmware would need to parse the request. If we >> wanted to adopt a secmark-esque approach, one could develop a second >> parsing mechanism that would be responsible for assigning a LSM label >> to the request, and then pass the firmware request to the LSM, but I >> do worry a bit about the added complexity associated with keeping the >> parser sync'd with the driver/fw. > In practice it would be like iptables, the parser would be entirely > programmed by userspace and there is nothing to keep in sync. > >> However, even if we solve the parsing problem, I worry we have >> another, closely related issue, of having to categorize all of the >> past, present, and future firmware requests into a set of LSM specific >> actions. > Why? secmark doesn't have this issue? The classifer would return the > same kind of information as secmark, some user provided label that is > delivered to the LSM policy side. > > When I talk about a classifier I mean a user programmable classifer > like iptables. secmark obviously doesn't raise future looking > questions (like what if there is httpv3?) nor should this. Secmark has already failed. As I mentioned before, you can't fit the label information from more than one LSM in a u32. There's going to have to be some performance degrading hash-magic invoked to make that happen, and when I've looked into what it would take I was very unhappy. >> The past and present requests are just a matter of code, >> that isn't too worrying, but what do we do about unknown future >> requests? Beyond simply encoding the request into a operation >> token/enum/int, what additional information beyond the action type >> would a LSM need to know to apply a security policy? Would it be >> reasonable to blindly allow or reject unknown requests? If so, what >> would break? > I am proposing something like SECMARK. > > Eg from Google: > > iptables -t mangle -A INPUT -p tcp --dport 80 -j SECMARK --selctx system_u:object_r:httpd_packet_t:s0 > > Which is 'match a packet to see that byte offset XX is 0080 and if so > tag it with the thing this string describes' > > So I'm imagining the same kind of flexability. User provides the > matching and whatever those strings are. The classifer step is fully > flexible. No worry about future stuff. > > I'm guessing when Casey talks about struct lsm_prop it is related to > the system_u string? Yeah, that would be it. Lets say your system supports SELinux and AppArmor. You'll need to be able to specify an SELinux context, an AppArmor context, or both. Iptables can't do that because of the limitations of a secmark. >>> ... Once classified we want this to work with more than SELinux >>> only, we have a particular interest in the eBPF LSM. >> One of the design requirements for the LSM framework is that it >> provides an abstraction layer between the kernel and the underlying >> security mechanisms implemented by the various LSMs. Some operations >> will always fall outside the scope of individual LSMs due to their >> nature, but as a general rule we try to ensure that LSM hooks are >> useful across multiple LSMs. > I don't know much about SECMARK but Google is telling me it doesn't > work with anything but SELinux LSM? We'd just like to avoid this > pitful and I guess that is why Casey brings up lsm_prop? Google is wrong. (Imagine that!) Smack uses secmarks. It's one of the reasons you can't use SELinux and Smack at the same time. There is code in iptables that implies it only works for SELinux, but it isn't true. That's why you want an lsm_prop instead of a secid. The limitation of a secmark is imposed by the IP stack implementation. It would be very frustrating if you introduced yet another scheme with that limitation. >>> Following the fwmark example, if there was some programmable in-kernel >>> function to convert the cmd into a SELinux label would we be able to >>> enable SELinux following the SECMARK design? >> As Casey already mentioned, any sort of classifier would need to be >> able to support multiple LSMs. The only example that comes to mind at >> the moment is the NetLabel mechanism which translates between >> on-the-wire CIPSO and CALIPSO labels and multiple LSMs (Smack and >> SELinux currently). > Ok, I think they can look into that, it is a good lead Netlabel has a similar issue to secmarks with its use of secids, and currently supports only a single CIPSO tag in the IP header, making multiple concurrent LSM support impossible. If you're defining a new mechanism you can avoid this limitation. >>> Would there be an objection if that in-kernel function was using a >>> system-wide eBPF uploaded with some fwctl uAPI? >> We'd obviously need to see patches, but there is precedent in >> separating labeling from enforcement. We've discussed SecMark and >> NetLabel in the networking space, but technically, the VFS/filesystem >> xattr implementations could also be considered as a labeling mechanism >> outside of the LSM. > Makes sense > >>> Finally, would there be an objection to enabling the same function in >>> eBPF by feeding it the entire command and have it classify and make a >>> security decision in a single eBPF program? >> Keeping in mind that from an LSM perspective we need to support >> multiple implementations, both in terms of language mechanics (eBPF, >> Rust, C) and security philosophies (Smack, SELinux, AppArmor, etc.), >> so it would be very unlikely that we would want a specific shortcut or >> mechanism that would only work for one language or philosophy. > Okay, it is good to understand the sensitivities > >>> Is there some other way to enable eBPF? >> If one develops a workable LSM hook then I see no reason why one >> couldn't write a BPF LSM to use that hook; that's what we do today. > I was thinking that too > >> However, it seems like direct reuse of secmark isn't what is needed, >> or even wanted, you were just using that as an example of separating >> labeling from enforcement, yes? > Yes, and looking for a coding example to guide implementing it, and to > recast this discussion to something more concrete. It is very helpful > to think of this a lot like deep packet inspection and > classification. > > That the packets are delivered to FW and execute commands is not > actually that important. IP packets are also delivered to remote CPUs > and execute commands there too > > At the end of the day the task is the same - deep packet inspection, > classification. labeling, policy decision, enforcement. > > Thanks, > Jason >