9 ms·
TLS in Linux 4.13 kernel
- rkeene2 9y agoThis looks similar to AT-TLS (application transparent TLS) on IBM mainframes.
- 0xFFC 9y agoPlease link to pdf?
- citrusui 9y agoHere you go: https://netdevconf.org/1.2/papers/ktls.pdf https://netdevconf.org/1.2/papers/ktls.pdf
- zingplex 9y agoWouldn't implementing TLS in the kernel result in a substantial increase in the exposed attack surface? This seems to me as if it would be similar to the time that Windows moved the graphics into the kernel and the havoc that ensued thereafter.
- deleted 9y ago[deleted]
- colemannugent 9y agoThis was my first thought as well. Looking through the repo [1] behind the paper the people behind it seem to have some crypto chops. A lot more can go wrong in kernel space, but the performance improvements might prompt the big players (Google, FB, etc.) to invest some time into locking it down. Also, it seems that only particular parts of the stack are handled by the kernel. Per the README: The socket does data transmission, the handshake, re-handshaking and other control messages have to be served by user space using appropriate libs such as OpenSSL or Gnu TLS. [1]: https://github.com/ktls/af_ktls https://github.com/ktls/af_ktls
- caf 9y agoThis only does the handling of TLS data frames in the kernel. All the handling of TLS control frames, including the handshake, is still done in userspace by an ordinary TLS library. This means that kernel is only doing some symmetrical encryption and simple framing (which are both the same kinds of things it was already doing in other application domains).
- topspin 9y agoIt appears the design of KTLS is intended to minimize the complexity necessary inside the kernel; the TLS handshake is handled in user space and then the TLS state is transcribed to a KTLS file descriptor which handles the traffic thereafter. This means the very complex public key part of TLS is user space. The kernel isn't involved with certificates etc. The kernel handles the symmetric cryptography once the user space handshake is complete. So yes, the net attack surface inside the kernel increases, but it isn't as though they are embedding some OpenSSL equivalent into the kernel. The paper reports a relatively small performance improvements. But I suppose if you're Facebook (they and RedHat implemented this) and performance improvements are measured in millions of dollars you care a lot about 7% less CPU utilization.
- microcolonel 9y agoThe performance gain is in latency consistency, it seems [0] though this chart is silly, since I'm guessing the X axis is time, and you can't chart a centile, that's ridiculous.. Anyway, even the throughput improvement could be worth it, but I think the main improvement is in latency. https://twitter.com/tgraf__/status/904475786622640128 https://twitter.com/tgraf__/status/904475786622640128
- vbernat 9y agoYou can chart a centile. Each point can be the centile of X measures.
- petters 9y ago> you can't chart a centile, Why? If you have servers with millions of qps, the graph would show the 99% latency over, say, a second or ten. I think this graph is pretty standard? But I'm happy for suggestions of better ones.
- user5994461 9y agoThere are constant variations in the environment that are more significant than the tiny effect you are trying to measure.
- TazeTSchnitzel 9y agoWindows Server also moved HTTP to the kernel!
- gruez 9y agoand since it was introduced (back in 2003), there were only 2 exploits discovered! (one RCE, one DoS)
- justincormack 9y agoSo did Linux, once, with the Tux in kernel webserver (now removed).
- anonacct37 9y agoShort answer, if all it does is symmetric cipher encryption/decryption it's probably not a big deal. The kernel already does crypto. Just keep the x509 parsing and handshake out of kernel.
- aseipp 9y ago> x509 Mmmm, I'm afraid I've got some unfortunate news for you :)
- anonacct37 9y agoToo bad you got downvotes. It appears that kernel and/or kernel module signatures use x509 certs. https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-signing-kernel-modules-for-secure-boot.html https://access.redhat.com/documentation/en-US/Red_Hat_Enterp... Thanks for the heads up.
- JoshTriplett 9y agoThere's actually a notable security advantage to this. A userspace process can do key negotiation, hand the symmetric keys to the kernel, and then have an ordinary file descriptor, with the kernel handling encryption. Which means you could then pass that file descriptor to a separate process, let it read and write data, and not give it access to key material at all.
- FooBarWidget 9y agoCan't you already do all of that with a userspace implementation?
- viraptor 9y agoThat's pretty much what stunnel does.
- JoshTriplett 9y agoSomewhat, if you pass a pipe around, but that also requires you to keep a separate process around, and shuttle data through two address spaces. With this, you can have a process do the negotiation, arrange a KTLS file descriptor, and then exec the new process.
- icebraining 9y agoCouldn't you open a TCP connection, do the handshake, then pass just the session key to the new process, along with the handler to the TCP connection?
- viraptor 9y agoYou could, but you lose out on a nice interface. Kernel implementation allows you to not care that you're actually using SSL. It's a normal socket and polling / waiting / data transmission works exactly the same as without SSL. Handing over a session key means you still have to include an SSL lib. This is likely to end up being supported in systemd soon (I'm guessing) to get an SSL socket activation.
- corbet 9y agoLWN's coverage of this patch: https://lwn.net/Articles/666509/ https://lwn.net/Articles/666509/
- kev009 9y agoIt's too bad KTLS was completed for FreeBSD but still not integrated.
- drewg123 9y agoWe're working on it. What we had was great for us, but pretty complex and not really upstreamable. I'm almost done with re-writing it to use the same M_NOTREADY mechanism as async sendfile, and to do all the framing in the kernel, rather than doing the sendfile() framing in-kernel and sosend() in userspace. This removes the majority of the code, and makes it quite a bit simpler. The downside is that it depends on my vectorized mbufs. Hopefully we'll have something public in the next few months.
- X86BSD 9y agoJust offering a few words of thanks and encouragement for your work regarding this. When this is ready it's ready. But thank you in advance.
- deleted 9y ago[deleted]
- BenjiWiebe 9y agoWhat's funny, is that I was just reviewing my custom built kernel's menuconfig, saw TLS, and briefly wondered why I didn't recall seeing that when I first ran the config, then figured I had just missed it. Never thought maybe it had recently been added.
- Skunkleton 9y agoI wonder why they opted not to use the existing packet transformation code that is already in the kernel? The same code is used as part of linux ipsec implementations.
- _wmd 9y agoThe layering inside the kernel is completely different... Kernel Connection Multiplexor Facebook’s primary motivation was to gain access to the un-encrypted bytes in kernel space. KCM is used to decode the framing, and make intelligent scheduling choices, before sending the frames to user space. KTLS sockets are mapped 1:N to user space sockets, where N is the number of user space threads, which are usually mapped to cores. Using this scheme, KTLS + KCM is able to reduce the total number of thread migrations of an individual request
- TheAceOfHearts 9y agoMaybe the link should be updated to use the 4.13 tag [0] instead of the master branch. [0] https://github.com/torvalds/linux/blob/v4.13/Documentation/networking/tls.txt https://github.com/torvalds/linux/blob/v4.13/Documentation/n...
- weddpros 9y agoIn these days of containers, wouldn't it allow a government to coerce a container-hosting company into using an unsecure kernel? Such a kernel would see all traffic, unencrypted... or did I miss something?
- jo909 9y agoPlease don't believe for even a second that your container host can't already extract the cleartext just because the SSL is executed in the container context. A kernel facility like that certainly makes an attack even more obvious and maybe harder to detect. But if this is a concern you can't use external hosting. This applies to VMs too, the hypervisor can see and transparently modify everything going on. There is development going on with special CPU instructions that could prevent the hypervisor from reading VM memory, but that is not state of the art and I would not trust it for a long time. You can't even be really sure that a bare metal server you are renting is not extracting the cleartext via a modified bios/efi, bootloader etc, or modified hardware at the worst.
- weddpros 9y ago"that certainly makes it even more obvious": that's what I meant... easy mass surveillance
- jo909 9y agoIf a government wants to do that, and the hosting company is not able or willing to fight it on a legal basis, it's really not about how easy or hard the actual implementation is. This makes nearly zero difference in the grand scheme of such a surveillance program.
- geofft 9y agoIf you run the kernel, mass surveillance on the processes inside the kernel (whether in a container or not) is extremely easy, whether or not TLS is implemented in the kernel. Honestly sometimes I wish we had a library of these sorts of attacks so that it's easier to believe that they're easy, but there is a vague security advantage in not having easy-to-use, well-tested implementations of these attacks available for free on the internets.
- snakeanus 9y agoThis is why we need microkernels.
- geofft 9y agoCan you explain this position? In particular, my impression is that a large reason of why microkernels failed in the '90s - see e.g. OSF/1 - was the overhead of message-passing. The two most popular kernels today that vaguely resemble microkernels, namely Darwin (Mach-based) and NT (with its subsystems), do no isolation between parts of their kernel and just have ordinary function calls. TLS exists in userspace and works extraordinarily well, but the desire to move parts into kernelspace is specifically to avoid the overhead of copying data between kernelspace and userspace and to allow using things like sendfile() that wouldn't be possible across address spaces.
- MrTonyD 9y agoI think he meant to say that we need unikernels - a lot of people (including me) sometimes make that same mistake.
- dfhgb 9y agothe real advantage is that you can pass arround your encrypted connection as a file descriptor. so when you add encryption to some service, you do not have to manually replace all calls to read/write by libssl library functions but instead you can just continue to use read()/write() calls. pass tls connection as stdin/stdout to another process ect... this is how plan9 does tls and how it really should have been in the first place. adding tls support is one function call to wrap an existing file descriptor in tls and you get another file descriptor back.
- deleted 9y ago[deleted]
- colanderman 9y agoBut you can accomplish that by simply having an external process or thread terminate the TLS connection, and connect to your process over Unix domain sockets. Of course that is inefficient. But that is what KTLS is at its core: an optimization.
- dfhgb 9y agoof course you can make a pipe and spawn a process that does the translation. why's nobody doing that? because linux is a cargo cult and nobody does the sane thing until it is provided by the infrastructure. because of fork not mixing well with multithreaded applications... now finally linux got its shit together so there is no more excuse why todo it in a covoluted way.
- ComodoHacker 9y agoNo mention of memory cleaning policy and other security guarantees. I hope this is handled properly.
- drudru11 9y agoOh man - this is great. I hate having these proxy processes just for this task. I will begin experimenting with this kernel this week.