From: "YOSHIFUJI Hideaki / 吉藤英明" <yoshfuji@linux-ipv6.org>
To: w@1wt.eu
Cc: ak@suse.de, solar@openwall.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, yoshfuji@linux-ipv6.org
Subject: Re: [PATCH] getsockopt() early argument sanity checking
Date: Sun, 20 Aug 2006 19:50:44 +0900 (JST) [thread overview]
Message-ID: <20060820.195044.84187776.yoshfuji@linux-ipv6.org> (raw)
In-Reply-To: <20060820101528.GE602@1wt.eu>
Hello.
In article <20060820101528.GE602@1wt.eu> (at Sun, 20 Aug 2006 12:15:28 +0200), Willy Tarreau <w@1wt.eu> says:
> But I don't want to induce such large changes in this kernel. The goal of
> this test is a preventive measure to catch easily exploitable errors that
> might have remained undetected. For instance, a quick glance shows this
> portion of code in net/ipv4/raw.c (both 2.4 and 2.6) :
>
> static int raw_seticmpfilter(struct sock *sk, char *optval, int optlen)
> {
> if (optlen > sizeof(struct icmp_filter))
> optlen = sizeof(struct icmp_filter);
> if (copy_from_user(&sk->tp_pinfo.tp_raw4.filter, optval, optlen))
> return -EFAULT;
> return 0;
> }
>
> It only relies on sock_setsockopt() refusing optlen values < sizeof(int),
> and this is not documented. Having part of this code being copied for use
> in another code path would open a breach for optlen < 0.
:
> There are two tests in this patch :
>
> - one on the validity of the optlen address. This one is race-free and
> should be conserved anyway.
>
> - one on the optlen range which is valid for most cases but which is
> subject to a race condition and which might be circumvented by
> carefully written code and with some luck as in all race conditions
> issues.
Don't mix getsockopt() and setsockopt() code paths.
For setsockopt(), optlen < 0 is checked in net/socket.c:sys_setsockopt().
For getsockopt(), optlen and *optlen < 0 is (and should be) checked
(or handled) in each getsockopt function; e.g. do_ip_getsockopt(),
raw_geticmpfilter() etc.
--yoshfuji
next prev parent reply other threads:[~2006-08-20 10:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-19 23:05 Solar Designer
2006-08-19 23:48 ` Willy Tarreau
2006-08-20 0:05 ` Michael Buesch
2006-08-20 0:43 ` Willy Tarreau
2006-08-20 19:44 ` David Miller
2006-08-20 20:35 ` Willy Tarreau
2006-08-20 21:12 ` Arjan van de Ven
2006-08-21 12:09 ` Eugene Teo
2006-08-20 8:34 ` Andi Kleen
2006-08-20 10:15 ` Willy Tarreau
2006-08-20 10:50 ` YOSHIFUJI Hideaki / 吉藤英明 [this message]
2006-08-20 19:46 ` David Miller
2006-08-20 16:16 ` Solar Designer
2006-08-20 16:30 ` Arjan van de Ven
2006-08-20 19:47 ` David Miller
2006-08-20 18:38 ` Andi Kleen
2006-08-20 19:45 ` Solar Designer
2006-08-20 19:45 ` David Miller
2006-08-20 18:15 ` Alan Cox
2006-08-21 3:00 ` David Wagner
2006-08-21 8:24 ` Solar Designer
2006-08-20 18:57 Manfred Spraul
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=20060820.195044.84187776.yoshfuji@linux-ipv6.org \
--to=yoshfuji@linux-ipv6.org \
--cc=ak@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=solar@openwall.com \
--cc=w@1wt.eu \
/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
all inboxes | Powered by JetHome®