From: Andy Lutomirski <luto@amacapital.net>
To: Piotr Wilczek <p.wilczek@samsung.com>,
Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: David Miller <davem@davemloft.net>,
Network Development <netdev@vger.kernel.org>,
Kyungmin Park <kyungmin.park@samsung.com>,
juho80.son@samsung.com,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
jkaluza@redhat.com
Subject: Re: [PATCH net-next V2 0/2] send process status in SCM_PROCINFO
Date: Wed, 23 Jul 2014 13:49:01 -0700 [thread overview]
Message-ID: <CALCETrVMQ9iJxgJRxNQF1kLh_Zgz6=Wq018Nugv8kmwbDPEtjQ@mail.gmail.com> (raw)
In-Reply-To: <53CE5805.9050500@samsung.com>
On Tue, Jul 22, 2014 at 5:24 AM, Piotr Wilczek <p.wilczek@samsung.com> wrote:
> Hi Andy,
>
>
> On 07/02/2014 01:52 AM, Andy Lutomirski wrote:
>>
>> On Tue, Jul 1, 2014 at 4:31 PM, David Miller <davem@davemloft.net> wrote:
>>>
>>> From: Piotr Wilczek <p.wilczek@samsung.com>
>>> Date: Thu, 26 Jun 2014 14:55:52 +0200
>>>
>>>> Server-like processes in many cases need credentials and other
>>>> metadata of the peer, to decide if the calling process is allowed to
>>>> request a specific action, or the server just wants to log away this
>>>> type of information for auditing tasks.
>>>>
>>>> The current practice to retrieve such process metadata is to look that
>>>> information up in procfs with the $PID received over SCM_CREDENTIALS.
>>>> This is sufficient for long-running tasks, but introduces a race which
>>>> cannot be worked around for short-living processes; the calling
>>>> process and all the information in /proc/$PID/ is gone before the
>>>> receiver of the socket message can look it up.
>>>>
>>>> Changes introduced in this patchset can also increase performance
>>>> of such server-like processes, because current way of opening and
>>>> parsing /proc/$PID/* files is much more expensive than receiving these
>>>> metadata using SCM.
>>>>
>>>> As an example, this patch set improves systemd-journald performance
>>>> by about 20%. Generally, performance improvement depends on how heavily
>>>> procfs is read the calling process.
>>>> http://comments.gmane.org/gmane.comp.sysutils.systemd.devel/19467
>>>>
>>>> This patch set is split in two patches:
>>>> - the first adds library to retrive process information without
>>>> dependency on procfs.
>>>> - the second introduces a new SCM type called SCM_PROCINFO to optionally
>>>> allow the direct attaching of process status to SCM.
>>>
>>>
>>> I really would like someone smarter than me to review the security
>>> implications et al. of these changes before I apply them.
>>>
>>> Andy? Maybe you have an opinion?
>>>
>>
>> The degree to which I dislike this depends on what "procinfo" is.
>>
>> From the patch, it looks like procinfo includes cmdline. In which
>> case, NAK in almost the strongest possible terms. (If it includes
>> userspace addresses, then I'll upgrade that to the strongest possible
>> terms.) This is a giant information leak. Imagine what happens when
>> a privileged program gets one of these things as stdout. Keep in mind
>> that procfs has an option to hide pids that belong to other users.
>>
>> Even if procinfo were made relatively innocuous, this is just an
>> extension of a bad interface. If you all really want a way to
>> efficiently pass kernel-verified information through a unix socket,
>> then add something reasonable. This means:
>>
>> 1. It needs to be opt-in, *per send*. After all of the
>> vulnerabilities that have happened due to write(2) capturing
>> unexpected credentials of the caller, there's just no excuse for
>> adding new examples of this. Yes, this will prevent you from getting
>> a magic speed-up with legacy clients, but I've spent long enough
>> battling this sh*t from a security and correctness POV to care. Fix
>> the clients.
>>
>> 2. It should be easily extensible, because people keep wanting to add
>> new things here.
>>
>> Here's a proposal for how it could work:
>>
>> Senders can send SCM_VERIFIED_INFO. The payload is a list of (type,
>> flags, value) where type is the type of verified information and value
>> is what the sender wants to send.
>>
>> Flags can include SCMVI_FLAG_MANDATORY: failure to send this attribute
>> returns -EPERM.
>> SCMVI_FLAG_AUTO: value must be blank; the kernel will fill it in.
>> Any other flags: -EINVAL.
>>
>> This could be in CMSG format or in nlattr format. Or it could be one
>> cmsg per value (which might be easier).
>>
>> Receivers can set SO_PASS_VERIFIED_INFO. If so, then they'll receive
>> all of the sent values that have recognized types and pass
>> verification.
>>
>> For stream sockets, presumably the sender would send an
>> scm_verified_info using setsockopt and the receiver would grab it
>> using getsockopt.
>>
>> Types could include:
>>
>> SCMVI_UID
>> SCMVI_GID
>> SCMVI_PID (racy, but still better than SCM_CREDENTIALS)
>> SCMVI_LOGONUID (but only if CONFIG_AUDITSYSCALL, and someone needs to
>> figure out wtf its semantics are and *document* it before I'd ack such
>> a thing)
>> SCMVI_CGROUP (sigh)
>> SCMVI_AUDIT_SESSIONID (because sessionid is an awful name)
>> etc.
>>
>> I *might* get around to implementing this, but don't expect anything
>> soon -- my current kernel hacking bandwidth is well-occupied by
>> seccomp. But I'd be happy to review.
>>
>> --Andy
>>
>
> Thank you for comments. We do understand security issues of that patch. For
> other reasons, the patch is important for us. To speed things up, would you
> consider cooperation in implementing your SCM_IDENTITY?
Sure.
There's some code here:
https://git.kernel.org/cgit/linux/kernel/git/luto/linux.git/log/?h=scm_identity
It's very much a work-in-progress. Want to take a look and see if
it's a good place to start from?
--Andy
>
> Piotr
>
--
Andy Lutomirski
AMA Capital Management, LLC
prev parent reply other threads:[~2014-07-23 20:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 12:55 [PATCH net-next V2 0/2] send process status in SCM_PROCINFO Piotr Wilczek
2014-06-26 12:55 ` [PATCH net-next V2 1/2] lib:proc_info:add library to get process information Piotr Wilczek
2014-06-26 12:55 ` [PATCH net-next V2 2/2] Send process status in SCM_PROCINFO Piotr Wilczek
2014-07-01 23:31 ` [PATCH net-next V2 0/2] send " David Miller
2014-07-01 23:52 ` Andy Lutomirski
2014-07-03 6:00 ` Piotr Wilczek
2014-07-03 16:14 ` Andy Lutomirski
2014-07-04 13:26 ` Bartlomiej Zolnierkiewicz
2014-07-04 15:15 ` Andy Lutomirski
2014-07-04 16:55 ` Bartlomiej Zolnierkiewicz
2014-07-04 17:07 ` Andy Lutomirski
2014-07-04 17:58 ` Bartlomiej Zolnierkiewicz
2014-07-04 19:53 ` Andy Lutomirski
2014-07-14 16:43 ` Bartlomiej Zolnierkiewicz
2014-07-14 17:05 ` Andy Lutomirski
2014-07-21 12:59 ` Piotr Wilczek
2014-07-22 12:24 ` Piotr Wilczek
2014-07-23 20:49 ` Andy Lutomirski [this message]
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='CALCETrVMQ9iJxgJRxNQF1kLh_Zgz6=Wq018Nugv8kmwbDPEtjQ@mail.gmail.com' \
--to=luto@amacapital.net \
--cc=b.zolnierkie@samsung.com \
--cc=davem@davemloft.net \
--cc=jkaluza@redhat.com \
--cc=juho80.son@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=netdev@vger.kernel.org \
--cc=p.wilczek@samsung.com \
--cc=serge.hallyn@ubuntu.com \
/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).