🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
10 messages
10 total messages Started by Chuck Lever Fri, 13 Nov 2026 19:21
[PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#15944
Author: Chuck Lever
Date: Fri, 13 Nov 2026 19:21
116 lines
15129 bytes
NFSD controls remote access to its exports today by IP address and
hostname. Neither of these are cryptographically secure. For
instance, a MitM can replace the response to a server's plaintext
DNS query. As a result, a malicious NFS client can pretend to be a
client whose hostname matches one that has access to exports it
would otherwise be denied access to.

So instead, we want access-control decisions to be based on
cryptographically-vetted objects such as TLS peer-certificates.
In-kernel x.509 parsing would duplicate work mature userspace
libraries already do, so let's make tlshd evaluate peer certificates
in user space.

The certificates are evaluated against admin-defined policy, such
as whether the certificate's Issuer matches a particular string.
tlshd then marks NFS TLS sessions with those policy matches. Admins
also provide a set of policy names on each NFSD export (allow_tags).
Computing the intersection with these per-export tags is quick and
completely separate from the details of parsing x.509 certificates.

A yet-to-be-posted patch series introduces tag set support to the
exportfs command in nfs-utils. tlshd 1.5.0, current as of this
writing, already implements TLS session tagging.

---
Changes in v3:
- Replace the sloppy cover letter.
- Avoid a double free in the stringset capacity KUnit case (sashiko).
- Add list markers to the stringset kernel-doc Return: lists (sashiko).
- Move the duplicate session-tag KUnit changes into patch 5 (sashiko).
- Link to v2: https://patch.msgid.link/20261112-tls-session-tags-v2-0-a587a50de7fc@kernel.org

Changes in v2:
- Drop v1's 1/9, sent ahead of the set per Jeff and now merged.
- Adopt the pinned hr_file/fput lifetime model.
- Adapt to the errno-valued handshake status (hp_done takes int).
- Rename "tagset" to "stringset" throughout (Hannes)
- Warn and return false when a query precedes stringset_finalize().
- Add a patch with KUnit tests for stringset.
- Split the hp_done session-tags argument into its own patch.
- Collect the session tags before taking the completion gate.
- Pass ownership of the tag set to handshake_finish_complete().
- Add handshake_session_tag_len(), shared with the NFSD parser.
- Add KUnit tests for session-tag collection.
- Check the file reference count in the completion-gate KUnit case.
- Rename the ACCEPT cap attribute MAX_TAGS to MAX_SESSION_TAGS.
- Publish the saved tags with smp_wmb() and test_bit_acquire().
- Deny a tagged export on the non-mTLS arms of check_xprtsec_policy().
- Extract nfsd_nl_parse_allow_tags() from the netlink export parser.
- Build stringset only when a consumer selects CONFIG_STRINGSET.
- Free the session tags as soon as hp_done() returns.
- Report a rejected session tag or allow-tag through the extack.
- Show allow_tags in /proc/fs/nfsd/exports.
- Record the client address and XID in nfsd_export_tags_denied.
- Link to v1: https://patch.msgid.link/20260605-tls-session-tags-v1-0-47bd1d94d552@oracle.com

---
Chuck Lever (10):
      handshake: Add tags to "done" downcall
      lib: Add a "stringset" data structure
      lib: Add KUnit tests for the stringset data structure
      handshake: Add a session-tags argument to the TLS done callback
      handshake: Pick up session tags passed during the DONE downcall
      handshake: Add a kunit test for the completion gate
      handshake: Advertise the session-tag cap to user space
      SUNRPC: Copy the TLS session tags when they are available
      NFSD: Implement export tagging
      NFSD: Add allow_tags to the netlink export interface

 Documentation/core-api/index.rst           |   1 +
 Documentation/core-api/stringset.rst       | 243 ++++++++++++++++++++++
 Documentation/netlink/specs/handshake.yaml |  19 ++
 Documentation/netlink/specs/nfsd.yaml      |  10 +
 Documentation/networking/tls-handshake.rst |  62 +++++-
 MAINTAINERS                                |   8 +
 drivers/nvme/host/tcp.c                    |   3 +-
 drivers/nvme/target/tcp.c                  |   3 +-
 fs/nfsd/Kconfig                            |   1 +
 fs/nfsd/export.c                           | 194 +++++++++++++++++-
 fs/nfsd/export.h                           |   9 +
 fs/nfsd/netlink.c                          |   4 +-
 fs/nfsd/netlink.h                          |   3 +-
 fs/nfsd/trace.h                            |  27 +++
 include/linux/stringset.h                  | 191 ++++++++++++++++++
 include/linux/sunrpc/svc_xprt.h            |   7 +-
 include/net/handshake.h                    |  50 ++++-
 include/uapi/linux/handshake.h             |   4 +
 include/uapi/linux/nfsd_netlink.h          |   1 +
 lib/Kconfig                                |  12 ++
 lib/Kconfig.debug                          |   6 +
 lib/Makefile                               |   1 +
 lib/stringset.c                            | 190 ++++++++++++++++++
 lib/tests/Makefile                         |   1 +
 lib/tests/stringset_kunit.c                | 311 +++++++++++++++++++++++++++++
 net/Kconfig                                |   1 +
 net/handshake/genl.c                       |   5 +-
 net/handshake/handshake-test.c             | 307 ++++++++++++++++++++++++++++
 net/handshake/handshake.h                  |   9 +
 net/handshake/netlink.c                    | 110 +++++++++-
 net/handshake/request.c                    |  61 +++++-
 net/handshake/tlshd.c                      |  10 +-
 net/sunrpc/Kconfig                         |   1 +
 net/sunrpc/svc_xprt.c                      |  11 +-
 net/sunrpc/svcauth_unix.c                  |  14 +-
 net/sunrpc/svcsock.c                       |  63 +++++-
 net/sunrpc/xprtsock.c                      |   4 +-
 tools/net/ynl/Makefile.deps                |   3 +-
 38 files changed, 1914 insertions(+), 46 deletions(-)
---
base-commit: d1f4b7c6b997c29de67ad7178ababac2328cb1b4
change-id: 20260512-tls-session-tags-9d0042583f44

Best regards,
--  
Chuck Lever <cel@kernel.org>
[PATCH net-next v3 06/10] handshake: Add a kunit test for the completion gate
#15998
Author: Chuck Lever
Date: Fri, 13 Nov 2026 19:22
141 lines
13500 bytes
The genl family runs DONE with parallel_ops, so duplicate or
concurrent DONE downcalls for the same socket can both reach the
same handshake_req. The split try/finish pair guarantees that
exactly one caller drives completion to the consumer's hp_done
callback. Ownership of the collected session tags can then pass to
the request.

Exercise the gate's exclusivity with a kunit case: only the first
handshake_try_complete() wins, and a later handshake_complete() on
the same request leaves hp_done fired exactly once.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 net/handshake/handshake-test.c | 82 ++++++++++++++++++++++++++++++++++++++++++
 net/handshake/request.c        |  2 ++
 2 files changed, 84 insertions(+)

diff --git a/net/handshake/handshake-test.c b/net/handshake/handshake-test.c
index b4a56c4350bd..b6992d1fa4ce 100644
--- a/net/handshake/handshake-test.c
+++ b/net/handshake/handshake-test.c
@@ -465,6 +465,84 @@ static void handshake_req_cancel_test3(struct kunit *test)
 	fput(filp);
 }
 
+static int handshake_try_complete_done_count;
+
+static void test_done_count_func(struct handshake_req *req, int status,
+				 struct genl_info *info)
+{
+	handshake_try_complete_done_count++;
+}
+
+static struct handshake_proto handshake_req_alloc_proto_count = {
+	.hp_handler_class	= HANDSHAKE_HANDLER_CLASS_TLSHD,
+	.hp_accept		= test_accept_func,
+	.hp_done		= test_done_count_func,
+};
+
+static void handshake_try_complete_test1(struct kunit *test)
+{
+	unsigned long fcount_before;
+	struct handshake_req *req, *next;
+	struct handshake_net *hn;
+	struct socket *sock;
+	struct file *filp;
+	struct net *net;
+	bool first, second;
+	int err;
+
+	/* Arrange */
+	handshake_try_complete_done_count = 0;
+
+	req = handshake_req_alloc(&handshake_req_alloc_proto_count, GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, req);
+
+	err = __sock_create(&init_net, PF_INET, SOCK_STREAM, IPPROTO_TCP,
+			    &sock, 1);
+	KUNIT_ASSERT_EQ(test, err, 0);
+
+	filp = sock_alloc_file(sock, O_NONBLOCK, NULL);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, filp);
+	KUNIT_ASSERT_NOT_NULL(test, sock->sk);
+	sock->file = filp;
+
+	fcount_before = file_count(filp);
+	err = handshake_req_submit(sock, req, GFP_KERNEL);
+	KUNIT_ASSERT_EQ(test, err, 0);
+	KUNIT_EXPECT_EQ(test, file_count(filp), fcount_before + 1);
+
+	net = sock_net(sock->sk);
+	hn = handshake_pernet(net);
+	KUNIT_ASSERT_NOT_NULL(test, hn);
+
+	/* Pretend to accept this request */
+	next = handshake_req_next(hn, HANDSHAKE_HANDLER_CLASS_TLSHD);
+	KUNIT_ASSERT_PTR_EQ(test, req, next);
+	/* Simulate FD_PREPARE() consuming the file reference handed
+	 * off by handshake_req_next(); see handshake_nl_accept_doit().
+	 */
+	fput(filp);
+
+	/* Act */
+	first = handshake_try_complete(req);
+	second = handshake_try_complete(req);
+	handshake_finish_complete(req, 0, NULL, NULL);
+	/* handshake_finish_complete() drops the request's pin on the file. */
+	KUNIT_EXPECT_EQ(test, file_count(filp), fcount_before);
+	/* handshake_complete() re-enters the gate via
+	 * handshake_try_complete(). With the gate already taken,
+	 * hp_done must not fire a second time.
+	 */
+	handshake_complete(req, 0, NULL);
+
+	/* Assert */
+	KUNIT_EXPECT_TRUE(test, first);
+	KUNIT_EXPECT_FALSE(test, second);
+	KUNIT_EXPECT_EQ(test, handshake_try_complete_done_count, 1);
+	KUNIT_EXPECT_EQ(test, file_count(filp), fcount_before);
+
+	fput(filp);
+}
+
 static struct handshake_req *handshake_req_destroy_test;
 
 static void test_destroy_func(struct handshake_req *req)
@@ -751,6 +829,10 @@ static struct kunit_case handshake_api_test_cases[] = {
 		.name			= "req_cancel after done",
 		.run_case		= handshake_req_cancel_test3,
 	},
+	{
+		.name			= "try_complete gate is exclusive",
+		.run_case		= handshake_try_complete_test1,
+	},
 	{
 		.name			= "req_destroy works",
 		.run_case		= handshake_req_destroy_test1,
diff --git a/net/handshake/request.c b/net/handshake/request.c
index 72515e5e8cc2..31a81b7cb7e9 100644
--- a/net/handshake/request.c
+++ b/net/handshake/request.c
@@ -340,6 +340,7 @@ bool handshake_try_complete(struct handshake_req *req)
 {
 	return !test_and_set_bit(HANDSHAKE_F_REQ_COMPLETED, &req->hr_flags);
 }
+EXPORT_SYMBOL_IF_KUNIT(handshake_try_complete);
 
 /**
  * handshake_finish_complete - Deliver completion to the consumer
@@ -372,6 +373,7 @@ void handshake_finish_complete(struct handshake_req *req, int status,
 
 	fput(file);
 }
+EXPORT_SYMBOL_IF_KUNIT(handshake_finish_complete);
 
 void handshake_complete(struct handshake_req *req, int status,
 			struct genl_info *info)

-- 
2.56.0
[PATCH net-next v3 10/10] NFSD: Add allow_tags to the netlink export interface
#15969
Author: Chuck Lever
Date: Fri, 13 Nov 2026 19:22
271 lines
19144 bytes
The legacy exportfs cache path accepts an allow_tags clause that
restricts an export to mTLS sessions carrying at least one matching
session tag. The netlink-based svc_export interface had no such
attribute, so administrators configuring exports via netlink could
not request tag enforcement. nfsd_nl_parse_one_export() left
ex_allow_tags empty, and check_xprtsec_policy() then granted access
to any authenticated peer.

Extend the svc-export attribute set with allow-tags and parse it in
nfsd_nl_parse_one_export(). Apply the same xprtsec=mtls consistency
check as svc_export_parse() so the netlink path rejects a
contradictory security policy with an explicit error at
configuration time rather than caching an export that can never
grant access.

A bare -EINVAL does not tell an administrator which tag in a
request was malformed, or that the export's xprtsec setting
conflicts with allow-tags. Pass the request's extended ACK into
nfsd_nl_parse_one_export(). The parser reports a malformed tag as the
bad attribute, and too many tags or an xprtsec setting other than mtls
alone as an error message.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 Documentation/netlink/specs/nfsd.yaml | 10 +++++
 fs/nfsd/export.c                      | 80 +++++++++++++++++++++++++++++++++--
 fs/nfsd/netlink.c                     |  4 +-
 fs/nfsd/netlink.h                     |  3 +-
 include/uapi/linux/nfsd_netlink.h     |  1 +
 tools/net/ynl/Makefile.deps           |  3 +-
 6 files changed, 94 insertions(+), 7 deletions(-)

diff --git a/Documentation/netlink/specs/nfsd.yaml b/Documentation/netlink/specs/nfsd.yaml
index 9ae37bf3ea71..e58856b34b02 100644
--- a/Documentation/netlink/specs/nfsd.yaml
+++ b/Documentation/netlink/specs/nfsd.yaml
@@ -7,6 +7,10 @@ uapi-header: linux/nfsd_netlink.h
 doc: NFSD configuration over generic netlink.
 
 definitions:
+  -
+    name: handshake-session-tag-max-len
+    type: const
+    header: linux/handshake.h
   -
     type: flags
     name: cache-type
@@ -297,6 +301,12 @@ attribute-sets:
       -
         name: fsid
         type: s32
+      -
+        name: allow-tags
+        type: string
+        checks:
+          max-len: handshake-session-tag-max-len
+        multi-attr: true
   -
     name: svc-export-reqs
     attributes:
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index b171cc625c9a..c4ecf884157e 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -832,11 +832,66 @@ static struct svc_export *svc_export_update(struct svc_export *new,
 static struct svc_export *svc_export_lookup(struct svc_export *);
 static int check_export(const struct path *path, int *flags,
 			unsigned char *uuid);
+static int check_allow_tags(const struct svc_export *exp);
+
+/**
+ * nfsd_nl_parse_allow_tags - parse allow-tags from netlink
+ * @exp: svc_export to fill in
+ * @attr: nested svc-export attribute holding the allow-tags entries
+ * @extack: extended ACK that reports the rejected attribute, or NULL
+ *
+ * On success @exp->ex_allow_tags is populated and finalized; on
+ * failure it can hold a partial set. The caller releases it with
+ * stringset_destroy() either way.
+ *
+ * Return: 0 on success or a negative errno.
+ */
+static int nfsd_nl_parse_allow_tags(struct svc_export *exp,
+				    struct nlattr *attr,
+				    struct netlink_ext_ack *extack)
+{
+	struct nlattr *tag_attr;
+	unsigned int count = 0;
+	int rem;
+
+	nla_for_each_nested_type(tag_attr, NFSD_A_SVC_EXPORT_ALLOW_TAGS,
+				 attr, rem) {
+		if (handshake_session_tag_len(nla_data(tag_attr),
+					      nla_len(tag_attr)) < 0) {
+			NL_SET_BAD_ATTR(extack, tag_attr);
+			return -EINVAL;
+		}
+		count++;
+	}
+	if (count > NFSD_MAX_ALLOW_TAGS) {
+		NL_SET_ERR_MSG(extack, "too many allow-tags");
+		return -EINVAL;
+	}
+	if (!stringset_alloc(&exp->ex_allow_tags, count, GFP_KERNEL))
+		return -ENOMEM;
+
+	nla_for_each_nested_type(tag_attr, NFSD_A_SVC_EXPORT_ALLOW_TAGS,
+				 attr, rem) {
+		char *tag;
+
+		tag = nla_strdup(tag_attr, GFP_KERNEL);
+		if (!tag)
+			return -ENOMEM;
+		if (!stringset_add(&exp->ex_allow_tags, tag)) {
+			kfree(tag);
+			return -ENOMEM;
+		}
+	}
+	stringset_finalize(&exp->ex_allow_tags);
+
+	return 0;
+}
 
 /**
  * nfsd_nl_parse_one_export - parse one svc_export entry from a netlink message
  * @cd: cache_detail for the svc_export cache
  * @attr: nested attribute containing svc-export fields
+ * @extack: extended ACK for error reporting, or NULL
  *
  * Parses one svc-export entry from a netlink message and updates the
  * cache. Mirrors the logic in svc_export_parse().
@@ -844,16 +899,17 @@ static int check_export(const struct path *path, int *flags,
  * Returns 0 on success or a negative errno.
  */
 static int nfsd_nl_parse_one_export(struct cache_detail *cd,
-				    struct nlattr *attr)
+				    struct nlattr *attr,
+				    struct netlink_ext_ack *extack)
 {
-	struct nlattr *tb[NFSD_A_SVC_EXPORT_FSID + 1];
+	struct nlattr *tb[NFSD_A_SVC_EXPORT_ALLOW_TAGS + 1];
 	struct auth_domain *dom = NULL;
 	struct svc_export exp = {}, *expp;
 	struct nlattr *secinfo_attr;
 	struct timespec64 boot;
 	int err, rem;
 
-	err = nla_parse_nested(tb, NFSD_A_SVC_EXPORT_FSID, attr,
+	err = nla_parse_nested(tb, NFSD_A_SVC_EXPORT_ALLOW_TAGS, attr,
 			       nfsd_svc_export_nl_policy, NULL);
 	if (err)
 		return err;
@@ -994,6 +1050,20 @@ static int nfsd_nl_parse_one_export(struct cache_detail *cd,
 			}
 		}
 
+		/* allow-tags (multi-attr string) */
+		if (tb[NFSD_A_SVC_EXPORT_ALLOW_TAGS]) {
+			err = nfsd_nl_parse_allow_tags(&exp, attr, extack);
+			if (err)
+				goto out_uuid;
+		}
+
+		err = check_allow_tags(&exp);
+		if (err) {
+			NL_SET_ERR_MSG(extack,
+				       "allow-tags needs xprtsec=mtls only");
+			goto out_uuid;
+		}
+
 		err = check_export(&exp.ex_path, &exp.ex_flags,
 				   exp.ex_uuid);
 		if (err)
@@ -1028,6 +1098,7 @@ static int nfsd_nl_parse_one_export(struct cache_detail *cd,
 	}
 
 out_uuid:
+	stringset_destroy(&exp.ex_allow_tags);
 	kfree(exp.ex_uuid);
 out_fslocs:
 	nfsd4_fslocs_free(&exp.ex_fslocs);
@@ -1068,7 +1139,8 @@ int nfsd_nl_svc_export_set_reqs_doit(struct sk_buff *skb,
 
 	nlmsg_for_each_attr_type(attr, NFSD_A_SVC_EXPORT_REQS_REQUESTS,
 				 info->nlhdr, GENL_HDRLEN, rem) {
-		ret = nfsd_nl_parse_one_export(cd, (struct nlattr *)attr);
+		ret = nfsd_nl_parse_one_export(cd, (struct nlattr *)attr,
+					       info->extack);
 		if (ret)
 			break;
 	}
diff --git a/fs/nfsd/netlink.c b/fs/nfsd/netlink.c
index 88a4a4ffcb7f..146c65575741 100644
--- a/fs/nfsd/netlink.c
+++ b/fs/nfsd/netlink.c
@@ -10,6 +10,7 @@
 #include "netlink.h"
 
 #include <uapi/linux/nfsd_netlink.h>
+#include <linux/handshake.h>
 
 /* Common nested types */
 const struct nla_policy nfsd_auth_flavor_nl_policy[NFSD_A_AUTH_FLAVOR_FLAGS + 1] = {
@@ -41,7 +42,7 @@ const struct nla_policy nfsd_sock_nl_policy[NFSD_A_SOCK_TRANSPORT_NAME + 1] = {
 	[NFSD_A_SOCK_TRANSPORT_NAME] = { .type = NLA_NUL_STRING, },
 };
 
-const struct nla_policy nfsd_svc_export_nl_policy[NFSD_A_SVC_EXPORT_FSID + 1] = {
+const struct nla_policy nfsd_svc_export_nl_policy[NFSD_A_SVC_EXPORT_ALLOW_TAGS + 1] = {
 	[NFSD_A_SVC_EXPORT_SEQNO] = { .type = NLA_U64, },
 	[NFSD_A_SVC_EXPORT_CLIENT] = { .type = NLA_NUL_STRING, },
 	[NFSD_A_SVC_EXPORT_PATH] = { .type = NLA_NUL_STRING, },
@@ -55,6 +56,7 @@ const struct nla_policy nfsd_svc_export_nl_policy[NFSD_A_SVC_EXPORT_FSID + 1] =
 	[NFSD_A_SVC_EXPORT_XPRTSEC] = NLA_POLICY_MASK(NLA_U32, 0x7),
 	[NFSD_A_SVC_EXPORT_FLAGS] = NLA_POLICY_MASK(NLA_U32, 0x3ffff),
 	[NFSD_A_SVC_EXPORT_FSID] = { .type = NLA_S32, },
+	[NFSD_A_SVC_EXPORT_ALLOW_TAGS] = { .type = NLA_STRING, .len = HANDSHAKE_SESSION_TAG_MAX_LEN, },
 };
 
 const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED + 1] = {
diff --git a/fs/nfsd/netlink.h b/fs/nfsd/netlink.h
index 027e2953db26..098514e7d1bf 100644
--- a/fs/nfsd/netlink.h
+++ b/fs/nfsd/netlink.h
@@ -11,6 +11,7 @@
 #include <net/genetlink.h>
 
 #include <uapi/linux/nfsd_netlink.h>
+#include <linux/handshake.h>
 
 /* Common nested types */
 extern const struct nla_policy nfsd_auth_flavor_nl_policy[NFSD_A_AUTH_FLAVOR_FLAGS + 1];
@@ -18,7 +19,7 @@ extern const struct nla_policy nfsd_expkey_nl_policy[NFSD_A_EXPKEY_PATH + 1];
 extern const struct nla_policy nfsd_fslocation_nl_policy[NFSD_A_FSLOCATION_PATH + 1];
 extern const struct nla_policy nfsd_fslocations_nl_policy[NFSD_A_FSLOCATIONS_LOCATION + 1];
 extern const struct nla_policy nfsd_sock_nl_policy[NFSD_A_SOCK_TRANSPORT_NAME + 1];
-extern const struct nla_policy nfsd_svc_export_nl_policy[NFSD_A_SVC_EXPORT_FSID + 1];
+extern const struct nla_policy nfsd_svc_export_nl_policy[NFSD_A_SVC_EXPORT_ALLOW_TAGS + 1];
 extern const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED + 1];
 
 int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,
diff --git a/include/uapi/linux/nfsd_netlink.h b/include/uapi/linux/nfsd_netlink.h
index c125af0cc6a5..e4bd1fe69fff 100644
--- a/include/uapi/linux/nfsd_netlink.h
+++ b/include/uapi/linux/nfsd_netlink.h
@@ -185,6 +185,7 @@ enum {
 	NFSD_A_SVC_EXPORT_XPRTSEC,
 	NFSD_A_SVC_EXPORT_FLAGS,
 	NFSD_A_SVC_EXPORT_FSID,
+	NFSD_A_SVC_EXPORT_ALLOW_TAGS,
 
 	__NFSD_A_SVC_EXPORT_MAX,
 	NFSD_A_SVC_EXPORT_MAX = (__NFSD_A_SVC_EXPORT_MAX - 1)
diff --git a/tools/net/ynl/Makefile.deps b/tools/net/ynl/Makefile.deps
index f8850444d240..3a3fc10a77d6 100644
--- a/tools/net/ynl/Makefile.deps
+++ b/tools/net/ynl/Makefile.deps
@@ -33,7 +33,8 @@ CFLAGS_netdev:=$(call get_hdr_inc,_LINUX_NETDEV_H,netdev.h)
 CFLAGS_nl80211:=$(call get_hdr_inc,__LINUX_NL802121_H,nl80211.h)
 CFLAGS_nlctrl:=$(call get_hdr_inc,__LINUX_GENERIC_NETLINK_H,genetlink.h) \
 	$(call get_hdr_inc,__LINUX_NETLINK_H,netlink.h)
-CFLAGS_nfsd:=$(call get_hdr_inc,_LINUX_NFSD_NETLINK_H,nfsd_netlink.h)
+CFLAGS_nfsd:=$(call get_hdr_inc,_LINUX_NFSD_NETLINK_H,nfsd_netlink.h) \
+	$(call get_hdr_inc,_LINUX_HANDSHAKE_H,handshake.h)
 CFLAGS_ovpn:=$(call get_hdr_inc,_LINUX_OVPN_H,ovpn.h)
 CFLAGS_ovs_datapath:=$(call get_hdr_inc,__LINUX_OPENVSWITCH_H,openvswitch.h)
 CFLAGS_ovs_flow:=$(call get_hdr_inc,__LINUX_OPENVSWITCH_H,openvswitch.h)

-- 
2.56.0
Re: [PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#19248
Author: Simon Horman
Date: Thu, 19 Nov 2026 16:35
38 lines
9923 bytes
On Fri, Nov 13, 2026 at 02:21:58PM -0500, Chuck Lever wrote:
> NFSD controls remote access to its exports today by IP address and
> hostname. Neither of these are cryptographically secure. For
> instance, a MitM can replace the response to a server's plaintext
> DNS query. As a result, a malicious NFS client can pretend to be a
> client whose hostname matches one that has access to exports it
> would otherwise be denied access to.
> 
> So instead, we want access-control decisions to be based on
> cryptographically-vetted objects such as TLS peer-certificates.
> In-kernel x.509 parsing would duplicate work mature userspace
> libraries already do, so let's make tlshd evaluate peer certificates
> in user space.
> 
> The certificates are evaluated against admin-defined policy, such
> as whether the certificate's Issuer matches a particular string.
> tlshd then marks NFS TLS sessions with those policy matches. Admins
> also provide a set of policy names on each NFSD export (allow_tags).
> Computing the intersection with these per-export tags is quick and
> completely separate from the details of parsing x.509 certificates.
> 
> A yet-to-be-posted patch series introduces tag set support to the
> exportfs command in nfs-utils. tlshd 1.5.0, current as of this
> writing, already implements TLS session tagging.

Hi Chuck, all,

FYI, while looking over this patchset I noticed that CI flags
shadow len variables in ynl generated C code.

I believe this is a bug in ynl-gen and have posted a patch to try to
address it.

- [PATCH net-next] tools: ynl-gen: avoid shadow local variable declarations
  https://lore.kernel.org/netdev/20261119-ynl-scope-v1-1-d3b0c964d4cb@kernel.org/

...
Re: [PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#20306
Author: Jakub Kicinski
Date: Sun, 22 Nov 2026 00:13
45 lines
10543 bytes
On Fri, 13 Nov 2026 14:21:58 -0500 Chuck Lever wrote:
> NFSD controls remote access to its exports today by IP address and
> hostname. Neither of these are cryptographically secure. For
> instance, a MitM can replace the response to a server's plaintext
> DNS query. As a result, a malicious NFS client can pretend to be a
> client whose hostname matches one that has access to exports it
> would otherwise be denied access to.
> 
> So instead, we want access-control decisions to be based on
> cryptographically-vetted objects such as TLS peer-certificates.
> In-kernel x.509 parsing would duplicate work mature userspace
> libraries already do, so let's make tlshd evaluate peer certificates
> in user space.
> 
> The certificates are evaluated against admin-defined policy, such
> as whether the certificate's Issuer matches a particular string.
> tlshd then marks NFS TLS sessions with those policy matches. Admins
> also provide a set of policy names on each NFSD export (allow_tags).
> Computing the intersection with these per-export tags is quick and
> completely separate from the details of parsing x.509 certificates.
> 
> A yet-to-be-posted patch series introduces tag set support to the
> exportfs command in nfs-utils. tlshd 1.5.0, current as of this
> writing, already implements TLS session tagging.

I submitted this for AI review now, I think due to the problem
Simon flagged CI didn't just gobble it up automatically.
The AI review will not be emailed to the list automatically but
hopefully it will be ready here by the time you read this:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-tls-session-tags-v3-3-91271964cdb0@kernel.org

The patches look reasonable to me, overall. At a high level tho - 
I don't have any familiarity with "tag" based policies.
Are you confident it's flexible and convenient enough to survive
as uAPI?

Naively I'd think it creates unnecessarily wide API on both ends
(handshake and server). My knee jerk design would be to populate
the full policy in the server, and only carry some "policy ID"
thru the handshake. Number of policy IDs would equal to the number
of tag combinations (which result in different behavior).

Any examples of APIs like the one you're adding working well?
Anyone willing to review this series, please??
Re: [PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#20579
Author: "Chuck Lever"
Date: Mon, 23 Nov 2026 00:27
18 lines
10955 bytes
On Sat, Nov 21, 2026, at 4:13 PM, Jakub Kicinski wrote:
> Naively I'd think it creates unnecessarily wide API on both ends
> (handshake and server). My knee jerk design would be to populate
> the full policy in the server, and only carry some "policy ID"
> thru the handshake. Number of policy IDs would equal to the number
> of tag combinations (which result in different behavior).

How is a tag much different than a policy ID?

It wouldn’t be impossible to impose another layer here that makes
a specific set of tags into a single policy, but I’m not seeing
that doing such adds a lot of value.


-- 
Chuck Lever
Re: [PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#20620
Author: "Chuck Lever"
Date: Mon, 23 Nov 2026 00:59
47 lines
12483 bytes

On Sat, Nov 21, 2026, at 7:13 PM, Jakub Kicinski wrote:
> On Fri, 13 Nov 2026 14:21:58 -0500 Chuck Lever wrote:
>> NFSD controls remote access to its exports today by IP address and
>> hostname. Neither of these are cryptographically secure. For
>> instance, a MitM can replace the response to a server's plaintext
>> DNS query. As a result, a malicious NFS client can pretend to be a
>> client whose hostname matches one that has access to exports it
>> would otherwise be denied access to.
>> 
>> So instead, we want access-control decisions to be based on
>> cryptographically-vetted objects such as TLS peer-certificates.
>> In-kernel x.509 parsing would duplicate work mature userspace
>> libraries already do, so let's make tlshd evaluate peer certificates
>> in user space.
>> 
>> The certificates are evaluated against admin-defined policy, such
>> as whether the certificate's Issuer matches a particular string.
>> tlshd then marks NFS TLS sessions with those policy matches. Admins
>> also provide a set of policy names on each NFSD export (allow_tags).
>> Computing the intersection with these per-export tags is quick and
>> completely separate from the details of parsing x.509 certificates.
>> 
>> A yet-to-be-posted patch series introduces tag set support to the
>> exportfs command in nfs-utils. tlshd 1.5.0, current as of this
>> writing, already implements TLS session tagging.
>
> I submitted this for AI review now, I think due to the problem
> Simon flagged CI didn't just gobble it up automatically.
> The AI review will not be emailed to the list automatically but
> hopefully it will be ready here by the time you read this:
> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-tls-session-tags-v3-3-91271964cdb0@kernel.org

There are some drips and drabs here. I can re-roll, and think more
about higher level policy-based access control.


> Any examples of APIs like the one you're adding working well?

I found one or two while developing these a year ago. Nothing
is leaping to mind at the moment, though.


-- 
Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)
Re: [PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#21399
Author: Jakub Kicinski
Date: Tue, 24 Nov 2026 00:34
28 lines
9720 bytes
On Sun, 22 Nov 2026 16:27:08 -0800 Chuck Lever wrote:
> On Sat, Nov 21, 2026, at 4:13 PM, Jakub Kicinski wrote:
> > Naively I'd think it creates unnecessarily wide API on both ends
> > (handshake and server). My knee jerk design would be to populate
> > the full policy in the server, and only carry some "policy ID"
> > thru the handshake. Number of policy IDs would equal to the number
> > of tag combinations (which result in different behavior).  
> 
> How is a tag much different than a policy ID?
> 
> It wouldn’t be impossible to impose another layer here that makes
> a specific set of tags into a single policy, but I’m not seeing
> that doing such adds a lot of value.

My thinking was that we have two user space components (TLS handshake
handler and the storage server stack) which are required to render
their decision in the language of tags, and upload the result
to the kernel via independent APIs. The policy ID limits the kernel
to mechanical enforcement. The components resolve all decisions in user
space, and give the kernel full list of policy ID -> allowed resources.

Could be purely a subjective preference, I won't insist. Tho an ack
from someone experienced with building kernel (security?) policies
would be awesome.

BTW someone marked the patches as changes requested, so repost will be
needed.
Re: [PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#21906
Author: "Chuck Lever"
Date: Tue, 24 Nov 2026 15:27
80 lines
13242 bytes
On Mon, Nov 23, 2026, at 7:34 PM, Jakub Kicinski wrote:
> On Sun, 22 Nov 2026 16:27:08 -0800 Chuck Lever wrote:
>> On Sat, Nov 21, 2026, at 4:13 PM, Jakub Kicinski wrote:
>> > Naively I'd think it creates unnecessarily wide API on both ends
>> > (handshake and server). My knee jerk design would be to populate
>> > the full policy in the server, and only carry some "policy ID"
>> > thru the handshake. Number of policy IDs would equal to the number
>> > of tag combinations (which result in different behavior).  
>> 
>> How is a tag much different than a policy ID?
>> 
>> It wouldn’t be impossible to impose another layer here that makes
>> a specific set of tags into a single policy, but I’m not seeing
>> that doing such adds a lot of value.
>
> My thinking was that we have two user space components (TLS handshake
> handler and the storage server stack) which are required to render
> their decision in the language of tags, and upload the result
> to the kernel via independent APIs. The policy ID limits the kernel
> to mechanical enforcement.

That is basically the structure I have planned.

- tlshd parses the x.509 certificate and assigns matching tags to
  TLS sessions

- The exportfs command assigns tags to NFS exports and passes the
  tags to the kernel as part of its usual downcall

- Kernel NFSD grants access to an NFS export only when there is a
  non-empty intersection between the tags on the TLS session and
  the tags on the export being accessed.

This might be more helpful than the scant series cover letter:

  https://github.com/linux-nfs/ktls-utils/blob/main/man/man7/tls-session-tags.7

It describes the configuration of tlshd's tagging policies. The man
page actually describes how these things are stored in YAML; to
make it easier for humans, we could build a bespoke editing tool. 

The exportfs command will get an "allow-tags=" option that specifies
the set of tags that are granted access. I have some prototype
patches in a private tree, so nothing publishable here yet.


> The components resolve all decisions in user
> space, and give the kernel full list of policy ID -> allowed resources.

Yes, exactly so.


> Could be purely a subjective preference, I won't insist.

I will do another survey of policy mechanisms, as you suggested, at
least for reviewer reference.


> Tho an ack
> from someone experienced with building kernel (security?) policies
> would be awesome.

Agreed, review welcome. I'm open to suggestion on modifying the Cc:
list.


> BTW someone marked the patches as changes requested, so repost will be
> needed.

Yes, I plan a re-roll to address the sashiko review findings you
referred me to.


-- 
Chuck Lever
Re: [PATCH net-next v3 00/10] Deliver TLS session tags to upper-layer consumers (NFSD)
#23647
Author: "Chuck Lever"
Date: Fri, 27 Nov 2026 16:30
116 lines
15918 bytes
On Sat, Nov 21, 2026, at 7:13 PM, Jakub Kicinski wrote:
> On Fri, 13 Nov 2026 14:21:58 -0500 Chuck Lever wrote:
>> NFSD controls remote access to its exports today by IP address and
>> hostname. Neither of these are cryptographically secure. For
>> instance, a MitM can replace the response to a server's plaintext
>> DNS query. As a result, a malicious NFS client can pretend to be a
>> client whose hostname matches one that has access to exports it
>> would otherwise be denied access to.
>> 
>> So instead, we want access-control decisions to be based on
>> cryptographically-vetted objects such as TLS peer-certificates.
>> In-kernel x.509 parsing would duplicate work mature userspace
>> libraries already do, so let's make tlshd evaluate peer certificates
>> in user space.
>> 
>> The certificates are evaluated against admin-defined policy, such
>> as whether the certificate's Issuer matches a particular string.
>> tlshd then marks NFS TLS sessions with those policy matches. Admins
>> also provide a set of policy names on each NFSD export (allow_tags).
>> Computing the intersection with these per-export tags is quick and
>> completely separate from the details of parsing x.509 certificates.
>> 
>> A yet-to-be-posted patch series introduces tag set support to the
>> exportfs command in nfs-utils. tlshd 1.5.0, current as of this
>> writing, already implements TLS session tagging.

> The patches look reasonable to me, overall. At a high level tho - 
> I don't have any familiarity with "tag" based policies.
> Are you confident it's flexible and convenient enough to survive
> as uAPI?
>
> Naively I'd think it creates unnecessarily wide API on both ends
> (handshake and server). My knee jerk design would be to populate
> the full policy in the server, and only carry some "policy ID"
> thru the handshake. Number of policy IDs would equal to the number
> of tag combinations (which result in different behavior).
>
> Any examples of APIs like the one you're adding working well?

Here are a few similar mechanisms that are deployed and working.

1. OpenSSH certificate principals. A CA-signed certificate carries
   a set of principal names. AuthorizedPrincipalsFile lists the
   names a target accepts, and access is granted if any principal
   in the certificate matches a line. That is exactly the
   non-empty-intersection rule. AuthorizedPrincipalsCommand
   computes the set in user space, which is the role tlshd plays
   here. The difference is that principals are minted when the
   certificate is issued, not mapped by a local policy at handshake
   time. [3]

2. AWS IAM Roles Anywhere. It maps X.509 Subject/Issuer/SAN fields
   into session principal tags, such as aws:PrincipalTag/x509Subject/OU,
   through a per-profile attribute mapping. Resource and trust policies
   then condition on those tags. It even uses the name "session tags",
   and the certificate-to-tags step is configured separately from the
   resource policy, as in your design. The differences: AWS tags are
   key/value pairs, and the policy language is richer than set
   intersection. [1], [2]

3. Kerberos PAC group SIDs (AD, Samba, SMB). The KDC, a separate
   component, resolves identity into a set of group SIDs carried in
   the ticket. The file server grants access by intersecting that set
   with the resource ACL and never sees how membership was decided.
   Linux credentials already work this way: supplementary groups and
   the AUTH_SYS gid list are a set of IDs in the credential checked
   against the object. The kernel already enforces
   "set in the session ∩ set on the resource".

The policy-ID model you mentioned looks a lot like labeled IPsec
(XFRMA_SEC_CTX). The IKE daemon puts a single security context on
the SA, and an LSM enforces it.

The kernel already does only mechanical enforcement (intersection).

Policy IDs make the problem bigger, not smaller, IMHO. One ID per
combination of tags that behaves differently, the combinations grow
combinatorially. Policy IDs also force one compiler that knows both
the certificate rules and every export, which joins together the two
independently managed configs that tags keep apart.

So, we could:

- Rename tags "group memberships" in the cover letter and documentation,
  since that is the term PAC, SSH and AWS deployments use.

- Pin the string format in the uAPI by specifying a character set,
  maximum length and the existing cap, with any other format rejected
  at the DONE downcall. Optionally, reserve a prefix: namespace so other
  upper-layer protocols (NVMe) can't collide with NFS tags.

- Clarify in the series cover letter that the kernel only intersects and
  group/tag policy is handled in user space.


Lastly, I haven't found a perfect fit for security policy reviewers, but
these come close:

  Cc: linux-security-module@vger.kernel.org
  Cc: Paul Moore <paul@paul-moore.com>


-- 
Chuck Lever

[1] IAM Roles Anywhere: certificate attribute mapping (https://docs.aws.amazon.com/rolesanywhere/latest/userguide/attribute-mapping.html)
[2] IAM Roles Anywhere: attribute mapping and trust policy
    (https://docs.aws.amazon.com/rolesanywhere/latest/userguide/attribute-mapping-and-trust-policy.html)
[3] openssh-unix-dev: AuthorizedPrincipalsFile (2010) (https://lists.mindrot.org/pipermail/openssh-unix-dev/2010-October/029012.html)
  - GitLab: AuthorizedPrincipalsCommand (https://docs.gitlab.com/administration/operations/ssh_certificates/)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads