From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org,
Alexey Dobriyan
<adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] c/r: Add AF_UNIX support (v3)
Date: Mon, 06 Jul 2009 18:46:16 -0400 [thread overview]
Message-ID: <4A527EB8.4060201@cs.columbia.edu> (raw)
In-Reply-To: <87tz1psbpq.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
Dan Smith wrote:
> OL> (You'll need to slightly refactor sock_setsockopt() for that).
>
> It seems much easier and less invasive to just check against
> sysctl_{r,w}mem_max. I've got that added to the patch now.
But there are two cases: if you are CAP_NET_ADMIN you are allowed
to go beyond that limit. So you need to add that test too.
And in general, this helps to keep the checks - be it security,
resource limits, or whatever - in one place, instead of having
to duplicate code and, more importantly, risk getting out of
sync with the original checks (e.g., if sock_setsockopt changes).
>
> OL> 2) s = socket(.., SOCK_DGRAM,...);
> OL> bind(s, any_addr);
> OL> connect(s, other_addr, ...);
> --> now s is connected, but after restart you can't connect another
> OL> socket to it because the address wasn't bind() properly.
>
> Okay, I guess that's true. So, since there isn't a "I'm bound, but
> not listening or connected" flag anywhere, does it suffice to bind()
> any socket that is not connected but that does have a local address?
> Sockets that get a local address via connect() should never transition
> through that state, so I think that should work. At least for INET,
> any socket that is restored into a connected state is properly hashed
> such that another socket can't bind() to its local address (tested).
Yes, with the exception below (for UNIX)...
>
> OL> (And if the address was a pathname, but already unlinked, then
> OL> also unlink after the bind, FWIW).
>
> For path-based UNIX sockets, we don't care about this exclusion,
> right? As long as we make the socket owner think everything is as it
You are correct in that you don't need it for the scenario you
presented below.
But we do care, because it is necessary to do the unlink() after the
bind(), like you do for listening sockets, for this scenario:
s = socket()
bind(s, pathname)
unlink(pathname)
<---- checkpoint/restart
r = socket()
bind(r, pathname)
The second bind() will succeed on the original system, but will
fail on the restarted system, unless you do that.
> was, that is. Given that a normal system doesn't fail the bind of b
> in this case:
>
> a = socket(AF_UNIX);
> b = socket(AF_UNIX);
>
> bind(a, addr);
> unlink(addr);
> bind(b, addr);
>
BTW, I just looked again at the code, and I'm concerned about:
+ if (!un->linked) {
+ struct sockaddr_un *sun =
+ (struct sockaddr_un *)&h->laddr;
+ ret = sock_unix_unlink(sun->sun_path);
+ }
You need to verify that the address is not abstract, because
I'm not sure what sock_unix_unlink() would do given the empty
string. Usually this is filtered higher in the VFS (getname).
Oren.
next prev parent reply other threads:[~2009-07-06 22:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 15:55 [PATCH] c/r: Add AF_UNIX support (v3) Dan Smith
[not found] ` <1245167716-28906-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-06-25 2:30 ` Oren Laadan
2009-06-29 17:29 ` Dan Smith
[not found] ` <871vp3x81s.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-07-02 9:15 ` Oren Laadan
2009-07-06 18:31 ` Dan Smith
[not found] ` <87y6r1slxz.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-07-06 19:06 ` Oren Laadan
[not found] ` <4A524B40.4040600-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-07-06 22:12 ` Dan Smith
[not found] ` <87tz1psbpq.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-07-06 22:46 ` Oren Laadan [this message]
[not found] ` <4A527EB8.4060201-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-07-07 14:52 ` Dan Smith
[not found] ` <87prccsfyp.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-07-07 15:15 ` Oren Laadan
[not found] ` <Pine.LNX.4.64.0907071102341.24765-CXF6herHY6ykSYb+qCZC/1i27PF6R63G9nwVQlTi/Pw@public.gmane.org>
2009-07-07 15:24 ` Dan Smith
2009-07-07 15:33 ` Oren Laadan
2009-07-07 15:36 ` Dan Smith
[not found] ` <87ab3gsdwx.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-07-07 15:48 ` Oren Laadan
[not found] ` <4A536E44.6050601-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-07-07 16:04 ` Dan Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A527EB8.4060201@cs.columbia.edu \
--to=orenl-eqauephvms7envbuuze7ea@public.gmane.org \
--cc=adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.