netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: torvalds@linux-foundation.org
Cc: netdev@vger.kernel.org, serge@hallyn.com, ebiederm@xmission.com
Subject: Re: net: fix incorrect credentials passing
Date: Fri, 19 Apr 2013 21:58:56 -0400 (EDT)	[thread overview]
Message-ID: <20130419.215856.1499421731544629706.davem@davemloft.net> (raw)
In-Reply-To: <alpine.LFD.2.03.1304191826080.2455@gmail.com>

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 19 Apr 2013 18:32:32 -0700 (PDT)

> Commit 257b5358b32f ("scm: Capture the full credentials of the scm 
> sender") changed the credentials passing code to pass in the effective 
> uid/gid instead of the real uid/gid.

Yep, that's exactly what happened, via a very twisty and winding road.

The helper cred_to_ucred(), which was created by commit
3f551f9436c05a3b5eccdd6e94733df5bb98d2a5 ("sock: Introduce
cred_to_ucred") seemed to be aimed at providing the semantics expected
by SO_PEERCRED, which does in fact want to use the effective UIDs and
GIDs.

The SO_PEERCRED side of this can be seen more clearly in commit
109f6e39fa07c48f580125f531f46cb7c245b528 ("af_unix: Allow SO_PEERCRED
to work across namespaces.")

The error begins when we try to use that helper in the SCM credentials
code.

Initially, cred_to_ucred() is what was used by scm_set_cred().  Then
it got changed in dbe9a4173ea53b72b2c35d19f676a85b69f1c9fe ("scm:
Don't use struct ucred in NETLINK_CB and struct scm_cookie.") which
continues the error by propagating the effective UID/GID usage from
cred_to_ucred() into explicit accesses inside of scm_set_cred().

So, as stated, the error originates from trying to use this common
helper for both SO_PEERCERD and the SCM stuff, the latter of which
does not want to use effective UIDs and GIDs.

> This just undoes that (presumably unintentional) part of the commit.

Indeed, I'd say this was an oversight in semantic differences when
creating the cred_to_ucred() helper.

Eric B. please review and ACK this.

Thanks!

  reply	other threads:[~2013-04-20  1:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-20  1:32 net: fix incorrect credentials passing Linus Torvalds
2013-04-20  1:58 ` David Miller [this message]
2013-04-20 10:53   ` Eric W. Biederman
2013-04-20 20:58     ` David Miller

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=20130419.215856.1499421731544629706.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=netdev@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).