Allow ioctl TUNSETIFF without CAP_NET_ADMIN via seccomp?

From: Zach Walton
Date: Tue Sep 17 2024 - 00:31:39 EST


I was debugging a seccomp profile that attempts to allow TUNSETIFF in
a container, relevant bits:

...
{
"names":[
"ioctl"
],
"action":"SCMP_ACT_ALLOW",
"args":[
{
"index":1,
"value":1074025674,
"op":"SCMP_CMP_EQ"
},
{
"index":1,
"value":2147767498,
"op":"SCMP_CMP_EQ"
}
]
},
...

...but I get:

Tuntap IOCTL TUNSETIFF failed [0], errno operation not permitted

Looking at the code, it seems that there's an explicit check for
CAP_NET_ADMIN, which I'd prefer not to grant the container because the
permissions are excessive (yes, I can lock it down with seccomp but
still...): https://github.com/torvalds/linux/blob/3352633ce6b221d64bf40644d412d9670e7d56e3/drivers/net/tun.c#L2758-L2759

Is it possible to update this check to allow TUNSETIFF operations if a
seccomp profile allowing it is in place? (I am not a kernel developer
and it's unlikely I could safely contribute this)