LWN: Comments on "User namespaces progress"
http://lwn.net/Articles/528078/
This is a special feed containing comments posted
to the individual LWN article titled "User namespaces progress".
hourly2User namespaces progress
http://lwn.net/Articles/531421/rss
2013-01-04T02:00:22+00:00kevinm
<div class="FormattedComment">
Thanks Eric.<br>
<p>
So from this it sounds like all the other types of namespaces (net, pid, mount...) are "owned" by a user namespace (the one in which they were created). When a permission check is done, it is done using the user namespace that owns that namespace that the relevant resource is in - for example, when I try to bind a privileged port, the permission check is done using the user namespace that owns the current network namespace (not the user namespace of the current process, which might well be different). Does that sound like the right concept?<br>
</div>
User namespaces progress
http://lwn.net/Articles/531390/rss
2013-01-03T21:24:01+00:00Cyberax
<div class="FormattedComment">
Doesn't work with Java, just tried it on my system (it's Debian Stable). <br>
</div>
User namespaces progress
http://lwn.net/Articles/531389/rss
2013-01-03T21:21:29+00:00andresfreund
<div class="FormattedComment">
Hm, I don't really see that as a problem. But anyway:<br>
<p>
sudo /sbin/capsh --caps=cap_net_bind_service+pei == --user=andres -- -c "nc -l 434"<br>
<p>
Yes. Ugly. But it works. (capsh is/was a demo tool)<br>
<p>
</div>
User namespaces progress
http://lwn.net/Articles/531385/rss
2013-01-03T21:09:08+00:00Cyberax
<div class="FormattedComment">
That's much better than setting caps for executable files, but still has the problem of non-locality. It's impossible to understand from the daemon's command line that it magically acquires additional caps.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531348/rss
2013-01-03T21:05:20+00:00andresfreund
<div class="FormattedComment">
<font class="QuotedText">> By copying a binary.</font><br>
<font class="QuotedText">> Beautiful. Not.</font><br>
<p>
I only copied the binary because I do *not* want my normal nc to have the capability to bind to root-only ports.<br>
<p>
<font class="QuotedText">> In many scenarios you probably will end up using something like capsh or pam-cap.</font><br>
<p>
libpam-cap is probably easier for you:<br>
apt-get install libpam-cap<br>
pam-auth-update (enable "capabilities management")<br>
sensible-editor /etc/security/capability.conf<br>
# add "cap_net_bind_service cyberax"<br>
<p>
It should be rather similar for other distributions.<br>
<p>
Then start a new shell as your user (*not* via sudo "su - cyberax", use sudo -u cyberax, or su - cyberax from *your* user or such, pam_rootok makes a pretty unfortunate shortcut there) and voila:<br>
andres@alap2:~$ sudo -u andres nc -l 434<br>
^C<br>
<p>
</div>
User namespaces progress
http://lwn.net/Articles/531344/rss
2013-01-03T19:18:18+00:00Cyberax
<div class="FormattedComment">
By copying a binary. <br>
<p>
Beautiful. Not.<br>
<p>
<font class="QuotedText">> In many scenarios you probably will end up using something like capsh or pam-cap.</font><br>
I'll gladly send you a beer if you can give me a command line that actually works. I have tried all sorts of capsh command variations, but NONE of them works.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531343/rss
2013-01-03T19:15:41+00:00Cyberax
<div class="FormattedComment">
And now all Java programs have this privilege. Which is not that bad, since this restriction is brain-dead in the first place. But it also breaks during updates and is totally non-transparent (NOBODY checks file caps).<br>
<p>
You might actually notice that I have an answer in the thread you've linked: <a href="http://stackoverflow.com/a/7701793/625001">http://stackoverflow.com/a/7701793/625001</a> However, while it works for erlang it somehow fails for Java. Don't ask me why.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531328/rss
2013-01-03T17:44:32+00:00andresfreund
<div class="FormattedComment">
It depends a bit on how you want to start java, but in general you can do stuff like: <br>
$ nc -l 234<br>
nc: Permission denied<br>
$ cp `which nc` /tmp/nc && sudo setcap cap_net_bind_service+ep /tmp/nc<br>
$ /tmp/nc -l 234<br>
^C<br>
<p>
In many scenarios you probably will end up using something like capsh or pam-cap.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531329/rss
2013-01-03T17:40:10+00:00man_ls
Have you tried <a href="http://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-1024-on-l#414258">setcap</a>?
<pre>
setcap 'cap_net_bind_service=+ep' /path/to/program
</pre>
It worked for me but it was not Java; in your case run setcap for the java binary.
User namespaces progress
http://lwn.net/Articles/531326/rss
2013-01-03T17:21:58+00:00Cyberax
<div class="FormattedComment">
Ok. I have a Java application that needs to listen on port 80.<br>
<p>
How do I do it? I've actually tried multiple ways and all of them failed.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531325/rss
2013-01-03T17:18:47+00:00andresfreund
<div class="FormattedComment">
Err, no. They can change their uid away after start without any problems. Or they can get an additional CAP_NET_BIND_SERVICE without all the rest of root's powers.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531316/rss
2013-01-03T16:42:45+00:00Cyberax
<div class="FormattedComment">
And forces you to run daemons under the freaking root user. Great improvement, yes.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531291/rss
2013-01-03T07:59:20+00:00ebiederm
<div class="FormattedComment">
Privileged ports keep those pesky users off of the ports where you run your servers.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531289/rss
2013-01-03T07:57:12+00:00ebiederm
<div class="FormattedComment">
When entering a user namespace you drop privileges.<br>
<p>
The best way I can explain it is to describe an April Fool's day joke that you can play on your friendly local sysadmin.<br>
<p>
Create a binary and call it something like $HOME/bin/su. Have that binary<br>
call unshare(CLONE_NEWUSER) and write to /proc/[pid]/uid_map and /proc/[pid]/gid_map so that 0 in the current user namespace maps to the current uid and gid. Have this binary exec $SHELL. No privileges required. <br>
<p>
Report that su is working without requiring root privileges in your account.<br>
<p>
You can look around in /proc/self/status and see that your uid and gid are 0 and that you have all privs.<br>
<p>
Extra points if you can get your local sysadmin to start trying to do things and from your $HOME/bin/su, because things really won't work and if you don't realize what is going on you are likely to be quite frustrated.<br>
Services won't restart. You can't kill processes owned by other users etc.<br>
<p>
Having a pam module set it up so that the user that looks like root has a distinct uid from everyone else is trickier to setup but could be more entertaining.<br>
<p>
So while you have CAP_NET_BIND and can bind to any port in any network namespace you create, creating a network namespace won't do you much good because that network namespace is not connected to any other network namespace.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531281/rss
2013-01-03T05:50:56+00:00quotemstr
<div class="FormattedComment">
Besides: is the concept of a "privileged port" even relevant these days? It's a bad idea to make a security decision based on whether an incoming packet has a source port below 1024.<br>
</div>
User namespaces progress
http://lwn.net/Articles/531273/rss
2013-01-03T03:31:35+00:00mkerrisk
<blockquote>
So, what stops an unprivileged process from creating a new user namespace, so acquiring CAP_BIND in the new namespace, then binding a privileged port?
</blockquote>
I think the answer there is that while the unprivileged process that creates a user namespace gets all privileges for operations inside the namespace, that doesn't give it privilege for operations on objects (e.g., a network namespace) outside the user namespace. To do what you are thinking of would require creating a network namespace inside the user namespace; you could then bind to privileged ports inside that network namespace.
User namespaces progress
http://lwn.net/Articles/531269/rss
2013-01-03T01:56:40+00:00kevinm
<div class="FormattedComment">
So, what stops an unprivileged process from creating a new user namespace, so acquiring CAP_BIND in the new namespace, then binding a privileged port?<br>
<p>
Or does the creation of a new user namespace force the creation of a new namespace of all the other types at the same time?<br>
</div>
User namespaces progress
http://lwn.net/Articles/529133/rss
2012-12-13T19:41:45+00:00luto
<div class="FormattedComment">
This article just inspired me to do some review :)<br>
<p>
<a href="http://lkml.kernel.org/r/<50CA2B55.5070402@amacapital.net">http://lkml.kernel.org/r/<50CA2B55.5070402@amacapital.net</a>><br>
<p>
(That link is currently broken. I think it will come to life soon.)<br>
</div>
User namespaces progress
http://lwn.net/Articles/529036/rss
2012-12-13T13:55:50+00:00rfrancoise
<div class="FormattedComment">
Allowing non-privileged users to create new network/ns/pid namespaces via userns is absolutely great. At the moment, Chrome/Chromium ships with a setuid-root helper to create pid/network namespaces to run the renderers into, it will become unnecessary once this work becomes available.<br>
<p>
Combined with the new "mode 2" seccomp implementation it makes Linux a platform with strong sandboxing support!<br>
</div>