[systemd-devel] Antw: [EXT] Re: Creating executable device nodes in /dev?
>>> Jarkko Sakkinen schrieb am 09.12.2020 um 01:15 in >>> Nachricht <20201209001521.ga64...@kernel.org>: ... > > What's the data that supports having noexec /dev anyway? With root > access I can then just use something else like /dev/shm mount. > > Has there been out in the wild real world cases that noexec mount > of would have prevented? > > For me this sounds a lot just something that "feels more secure" > without any measurable benefit. Can you prove me wrong? I think the better question is: Why not allow it? I.e.: Why do you want to forbid it? Event though I wouldn't like it myself, I could even think of noexec /tmp. Regards, Ulrich ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Creating executable device nodes in /dev?
On Wed, Dec 09, 2020 at 02:15:28AM +0200, Jarkko Sakkinen wrote: > On Wed, Dec 09, 2020 at 01:15:27AM +0200, Topi Miettinen wrote: > > > > > As a further argument, I just did this on a Fedora system: > > > > > $ find /dev -perm /ugo+x -a \! -type d -a \! -type l > > > > > No results. So making /dev noexec doesn't seem to have any benefit. > > > > > > > > It's no surprise that there aren't any executables in /dev since > > > > removing MAKEDEV ages ago. That's not the issue, which is that > > > > /dev is a writable directory (for UID=0 but no capabilities are > > > > needed) and thus a potential location for constructing unapproved > > > > executables if it is also mounted exec (W^X). > > > > > > UID 0 can just change mount options, though, unless SELinux or similar is > > > used. And SELinux can protect /dev just fine without noexec. > > > > Well, mounting would need CAP_SYS_ADMIN in addition to UID 0. Also SELinux > > is not universal and the policies might not contain all users or services. > > > > -Topi > > What's the data that supports having noexec /dev anyway? With root > access I can then just use something else like /dev/shm mount. > > Has there been out in the wild real world cases that noexec mount > of would have prevented? Typo: "of" = "of /dev" > For me this sounds a lot just something that "feels more secure" > without any measurable benefit. Can you prove me wrong? The debate is circled around something not well defined. Of course you get theoretically more safe system when you decrease priviliges anywhere in the system. Like you could start do grazy things with stuff that unprivilged user has access, in order to prevent malware to elevate to UID 0 in the first place. I think where this go intellectually wrong is that we are talking about *default installation* of a distribution. That should have somewhat sane common sense access control settings. For like a normal desktop user noexec /dev will not do any possible favor. Then there is the case when you want to harden installation for an application, let's' say some server. In that case you will anyway fine-tune the security settings and go grazy enough with hardening. When you tailor a server, it's a standard practice to enumerate and adjust the mount points if needed. To summarize, I neither understand the intended target audience. /Jarkko ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Creating executable device nodes in /dev?
On Wed, Dec 09, 2020 at 01:15:27AM +0200, Topi Miettinen wrote: > > > > As a further argument, I just did this on a Fedora system: > > > > $ find /dev -perm /ugo+x -a \! -type d -a \! -type l > > > > No results. So making /dev noexec doesn't seem to have any benefit. > > > > > > It's no surprise that there aren't any executables in /dev since > > > removing MAKEDEV ages ago. That's not the issue, which is that > > > /dev is a writable directory (for UID=0 but no capabilities are > > > needed) and thus a potential location for constructing unapproved > > > executables if it is also mounted exec (W^X). > > > > UID 0 can just change mount options, though, unless SELinux or similar is > > used. And SELinux can protect /dev just fine without noexec. > > Well, mounting would need CAP_SYS_ADMIN in addition to UID 0. Also SELinux > is not universal and the policies might not contain all users or services. > > -Topi What's the data that supports having noexec /dev anyway? With root access I can then just use something else like /dev/shm mount. Has there been out in the wild real world cases that noexec mount of would have prevented? For me this sounds a lot just something that "feels more secure" without any measurable benefit. Can you prove me wrong? /Jarkko ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Creating executable device nodes in /dev?
On Tue, Dec 08, 2020 at 10:07:17AM -0800, Andy Lutomirski wrote: > On Thu, Nov 19, 2020 at 10:05 AM Topi Miettinen wrote: > > > > On 19.11.2020 18.32, Zbigniew Jędrzejewski-Szmek wrote: > > > On Thu, Nov 19, 2020 at 08:17:08AM -0800, Andy Lutomirski wrote: > > >> Hi udev people- > > >> > > >> The upcoming Linux SGX driver has a device node /dev/sgx. User code > > >> opens it, does various setup things, mmaps it, and needs to be able to > > >> create PROT_EXEC mappings. This gets quite awkward if /dev is mounted > > >> noexec. > > >> > > >> Can udev arrange to make a device node executable on distros that make > > >> /dev noexec? This could be done by bind-mounting from an exec tmpfs. > > >> Alternatively, the kernel could probably learn to ignore noexec on > > >> /dev/sgx, but that seems a little bit evil. > > > > > > I'd be inclined to simply drop noexec from /dev by default. > > > We don't do noexec on either /tmp or /dev/shm (because that causes > > > immediate > > > problems with stuff like Java and cffi). And if you have those two at your > > > disposal anyway, having noexec on /dev doesn't seem important. > > > > I'd propose to not enable exec globally, but if a service needs SGX, it > > could use something like MountOptions=/dev:exec only in those cases > > where it's needed. That way it's possible to disallow writable and > > executable file systems for most services (which typically don't need > > /tmp or /dev/shm either). Of course the opposite > > (MountOptions=/dev:noexec) would be also possible, but I'd expect that > > this would be needed to be used more often. > > > > I imagine the opposite would be more sensible. It seems odd to me > that we would want any SGX-using service to require both special mount > options and regular ACL permissions. > > As a further argument, I just did this on a Fedora system: > > $ find /dev -perm /ugo+x -a \! -type d -a \! -type l > > No results. So making /dev noexec doesn't seem to have any benefit. Neither does my Ubuntu installation with '-xdev' added (because of /dev/shm mount). find /dev -xdev -perm /ugo+x -a \! -type d -a \! -type l /Jarkko ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Creating executable device nodes in /dev?
On 8.12.2020 23.30, Andy Lutomirski wrote: On Dec 8, 2020, at 12:45 PM, Topi Miettinen wrote: On 8.12.2020 20.07, Andy Lutomirski wrote: On Thu, Nov 19, 2020 at 10:05 AM Topi Miettinen wrote: On 19.11.2020 18.32, Zbigniew Jędrzejewski-Szmek wrote: On Thu, Nov 19, 2020 at 08:17:08AM -0800, Andy Lutomirski wrote: Hi udev people- The upcoming Linux SGX driver has a device node /dev/sgx. User code opens it, does various setup things, mmaps it, and needs to be able to create PROT_EXEC mappings. This gets quite awkward if /dev is mounted noexec. Can udev arrange to make a device node executable on distros that make /dev noexec? This could be done by bind-mounting from an exec tmpfs. Alternatively, the kernel could probably learn to ignore noexec on /dev/sgx, but that seems a little bit evil. I'd be inclined to simply drop noexec from /dev by default. We don't do noexec on either /tmp or /dev/shm (because that causes immediate problems with stuff like Java and cffi). And if you have those two at your disposal anyway, having noexec on /dev doesn't seem important. I'd propose to not enable exec globally, but if a service needs SGX, it could use something like MountOptions=/dev:exec only in those cases where it's needed. That way it's possible to disallow writable and executable file systems for most services (which typically don't need /tmp or /dev/shm either). Of course the opposite (MountOptions=/dev:noexec) would be also possible, but I'd expect that this would be needed to be used more often. I imagine the opposite would be more sensible. It seems odd to me that we would want any SGX-using service to require both special mount options and regular ACL permissions. How common are thes SGX-using services? Will every service start using it without any special measures taken on it's behalf, or perhaps only a special SGX control tool needs access? What about unprivileged user applications, do they ever want to access SGX? Could something like Widevine deep in a browser need to talk to SGX in a DRM scheme? I honestly don’t know. Widevine is probably some unholy mess of SGX and ME crud. But regular user programs may well end up using SGX for little non-evil enclaves, e.g. storing their keys securely. It would be nice if unprivileged enclaves just work as long as the use has appropriate permissions on the device nodes. Maybe, it would be also great if the access could be limited to those users or services which actually need it, by principle of least privilege. SGX adoption has been severely hampered by the massive series of recent vulnerabilities and by Intel’s silly licensing scheme. The latter won’t be supported upstream. As a further argument, I just did this on a Fedora system: $ find /dev -perm /ugo+x -a \! -type d -a \! -type l No results. So making /dev noexec doesn't seem to have any benefit. It's no surprise that there aren't any executables in /dev since removing MAKEDEV ages ago. That's not the issue, which is that /dev is a writable directory (for UID=0 but no capabilities are needed) and thus a potential location for constructing unapproved executables if it is also mounted exec (W^X). UID 0 can just change mount options, though, unless SELinux or similar is used. And SELinux can protect /dev just fine without noexec. Well, mounting would need CAP_SYS_ADMIN in addition to UID 0. Also SELinux is not universal and the policies might not contain all users or services. -Topi ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Creating executable device nodes in /dev?
> On Dec 8, 2020, at 12:45 PM, Topi Miettinen wrote: > > On 8.12.2020 20.07, Andy Lutomirski wrote: >>> On Thu, Nov 19, 2020 at 10:05 AM Topi Miettinen wrote: >>> >>> On 19.11.2020 18.32, Zbigniew Jędrzejewski-Szmek wrote: On Thu, Nov 19, 2020 at 08:17:08AM -0800, Andy Lutomirski wrote: > Hi udev people- > > The upcoming Linux SGX driver has a device node /dev/sgx. User code > opens it, does various setup things, mmaps it, and needs to be able to > create PROT_EXEC mappings. This gets quite awkward if /dev is mounted > noexec. > > Can udev arrange to make a device node executable on distros that make > /dev noexec? This could be done by bind-mounting from an exec tmpfs. > Alternatively, the kernel could probably learn to ignore noexec on > /dev/sgx, but that seems a little bit evil. I'd be inclined to simply drop noexec from /dev by default. We don't do noexec on either /tmp or /dev/shm (because that causes immediate problems with stuff like Java and cffi). And if you have those two at your disposal anyway, having noexec on /dev doesn't seem important. >>> >>> I'd propose to not enable exec globally, but if a service needs SGX, it >>> could use something like MountOptions=/dev:exec only in those cases >>> where it's needed. That way it's possible to disallow writable and >>> executable file systems for most services (which typically don't need >>> /tmp or /dev/shm either). Of course the opposite >>> (MountOptions=/dev:noexec) would be also possible, but I'd expect that >>> this would be needed to be used more often. >>> >> I imagine the opposite would be more sensible. It seems odd to me >> that we would want any SGX-using service to require both special mount >> options and regular ACL permissions. > > How common are thes SGX-using services? Will every service start using it > without any special measures taken on it's behalf, or perhaps only a special > SGX control tool needs access? What about unprivileged user applications, do > they ever want to access SGX? Could something like Widevine deep in a browser > need to talk to SGX in a DRM scheme? I honestly don’t know. Widevine is probably some unholy mess of SGX and ME crud. But regular user programs may well end up using SGX for little non-evil enclaves, e.g. storing their keys securely. It would be nice if unprivileged enclaves just work as long as the use has appropriate permissions on the device nodes. SGX adoption has been severely hampered by the massive series of recent vulnerabilities and by Intel’s silly licensing scheme. The latter won’t be supported upstream. > >> As a further argument, I just did this on a Fedora system: >> $ find /dev -perm /ugo+x -a \! -type d -a \! -type l >> No results. So making /dev noexec doesn't seem to have any benefit. > > It's no surprise that there aren't any executables in /dev since removing > MAKEDEV ages ago. That's not the issue, which is that /dev is a writable > directory (for UID=0 but no capabilities are needed) and thus a potential > location for constructing unapproved executables if it is also mounted exec > (W^X). UID 0 can just change mount options, though, unless SELinux or similar is used. And SELinux can protect /dev just fine without noexec. > > -Topi ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Creating executable device nodes in /dev?
On 8.12.2020 20.07, Andy Lutomirski wrote: On Thu, Nov 19, 2020 at 10:05 AM Topi Miettinen wrote: On 19.11.2020 18.32, Zbigniew Jędrzejewski-Szmek wrote: On Thu, Nov 19, 2020 at 08:17:08AM -0800, Andy Lutomirski wrote: Hi udev people- The upcoming Linux SGX driver has a device node /dev/sgx. User code opens it, does various setup things, mmaps it, and needs to be able to create PROT_EXEC mappings. This gets quite awkward if /dev is mounted noexec. Can udev arrange to make a device node executable on distros that make /dev noexec? This could be done by bind-mounting from an exec tmpfs. Alternatively, the kernel could probably learn to ignore noexec on /dev/sgx, but that seems a little bit evil. I'd be inclined to simply drop noexec from /dev by default. We don't do noexec on either /tmp or /dev/shm (because that causes immediate problems with stuff like Java and cffi). And if you have those two at your disposal anyway, having noexec on /dev doesn't seem important. I'd propose to not enable exec globally, but if a service needs SGX, it could use something like MountOptions=/dev:exec only in those cases where it's needed. That way it's possible to disallow writable and executable file systems for most services (which typically don't need /tmp or /dev/shm either). Of course the opposite (MountOptions=/dev:noexec) would be also possible, but I'd expect that this would be needed to be used more often. I imagine the opposite would be more sensible. It seems odd to me that we would want any SGX-using service to require both special mount options and regular ACL permissions. How common are thes SGX-using services? Will every service start using it without any special measures taken on it's behalf, or perhaps only a special SGX control tool needs access? What about unprivileged user applications, do they ever want to access SGX? Could something like Widevine deep in a browser need to talk to SGX in a DRM scheme? As a further argument, I just did this on a Fedora system: $ find /dev -perm /ugo+x -a \! -type d -a \! -type l No results. So making /dev noexec doesn't seem to have any benefit. It's no surprise that there aren't any executables in /dev since removing MAKEDEV ages ago. That's not the issue, which is that /dev is a writable directory (for UID=0 but no capabilities are needed) and thus a potential location for constructing unapproved executables if it is also mounted exec (W^X). -Topi ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Creating executable device nodes in /dev?
On Thu, Nov 19, 2020 at 10:05 AM Topi Miettinen wrote: > > On 19.11.2020 18.32, Zbigniew Jędrzejewski-Szmek wrote: > > On Thu, Nov 19, 2020 at 08:17:08AM -0800, Andy Lutomirski wrote: > >> Hi udev people- > >> > >> The upcoming Linux SGX driver has a device node /dev/sgx. User code > >> opens it, does various setup things, mmaps it, and needs to be able to > >> create PROT_EXEC mappings. This gets quite awkward if /dev is mounted > >> noexec. > >> > >> Can udev arrange to make a device node executable on distros that make > >> /dev noexec? This could be done by bind-mounting from an exec tmpfs. > >> Alternatively, the kernel could probably learn to ignore noexec on > >> /dev/sgx, but that seems a little bit evil. > > > > I'd be inclined to simply drop noexec from /dev by default. > > We don't do noexec on either /tmp or /dev/shm (because that causes immediate > > problems with stuff like Java and cffi). And if you have those two at your > > disposal anyway, having noexec on /dev doesn't seem important. > > I'd propose to not enable exec globally, but if a service needs SGX, it > could use something like MountOptions=/dev:exec only in those cases > where it's needed. That way it's possible to disallow writable and > executable file systems for most services (which typically don't need > /tmp or /dev/shm either). Of course the opposite > (MountOptions=/dev:noexec) would be also possible, but I'd expect that > this would be needed to be used more often. > I imagine the opposite would be more sensible. It seems odd to me that we would want any SGX-using service to require both special mount options and regular ACL permissions. As a further argument, I just did this on a Fedora system: $ find /dev -perm /ugo+x -a \! -type d -a \! -type l No results. So making /dev noexec doesn't seem to have any benefit. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] mkosi question: third party repos + dnf modules
Hi Daan, Daan De Meyer wrote on 07/12/2020 20:41: > --repositories in mkosi is currently a bit limited. For Fedora and > CentOS, we only support passing names of existing repositories that > should be enabled. https://github.com/systemd/mkosi/issues/536 > reported a similar problem. We should definitely make this work better > than it does now but it's going to require a bit of thinking on how to > properly support this in a way that works for all major supported > distros. For now, I think postinst is the best solution. Thanks for the pointer to the issue. At least I'm not going insane. I suspect supporting the modules system in DNF would be a bit tricky too, so I'm happy enough going with an mkosi.prepare script for now. Slightly annoyingly it means I have to actually install dnf and it's deps inside the container built to run that, but I can always remove it again after. Have subscribed to the issue. Cheers Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited http://www.tribalogic.net/ Open Source: Mageia Contributor http://www.mageia.org/ PulseAudio Hacker http://www.pulseaudio.org/ Trac Hacker http://trac.edgewall.org/ ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] mkosi question: third party repos + dnf modules
Reindl Harald wrote on 07/12/2020 21:34: > and how is that systemd relevant at all? https://github.com/systemd/mkosi ^^^ Maybe that bit? The fact that mkosi is a systemd project? If you don't have anything positive to add, it's a lot less effort to just do nothing! Col ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel