netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eugene Teo <eteo@redhat.com>
To: Willy Tarreau <w@1wt.eu>
Cc: Michael Buesch <mb@bu3sch.de>,
	Solar Designer <solar@openwall.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] getsockopt() early argument sanity checking
Date: Mon, 21 Aug 2006 22:09:22 +1000	[thread overview]
Message-ID: <44E9A272.3020202@redhat.com> (raw)
In-Reply-To: <20060820004307.GD27115@1wt.eu>

Willy Tarreau wrote:
> On Sun, Aug 20, 2006 at 02:05:20AM +0200, Michael Buesch wrote:
>> On Sunday 20 August 2006 01:48, Willy Tarreau wrote:
>>> On Sun, Aug 20, 2006 at 03:05:32AM +0400, Solar Designer wrote:
[snipped]
> diff --git a/net/socket.c b/net/socket.c
> index ac45b13..910ef88 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1307,11 +1307,17 @@ asmlinkage long sys_setsockopt(int fd, i
>  asmlinkage long sys_getsockopt(int fd, int level, int optname, char *optval, int *optlen)
>  {
>  	int err;
> +	int len;
        ^^^^^^^^

>  	struct socket *sock;
>  
>  	if ((sock = sockfd_lookup(fd, &err))!=NULL)
>  	{
> -		if (level == SOL_SOCKET)
> +		/* XXX: insufficient for SMP, but should be redundant anyway */
> +		if (get_user(len, optlen))
> +			err = -EFAULT;
> +		else if (len < 0)
                ^^^^^^^^^^^^^^^^^

s/else//

> +			err = -EINVAL;
> +		else if (level == SOL_SOCKET)

s/else//

>  			err=sock_getsockopt(sock,level,optname,optval,optlen);
>  		else
>  			err=sock->ops->getsockopt(sock, level, optname, optval, optlen);

These checks are already in getsockopt(). Duplicated code?

Eugene
-- 
eteo redhat.com  ph: +65 6490 4142  http://www.kernel.org/~eugeneteo
gpg fingerprint:  47B9 90F6 AE4A 9C51 37E0  D6E1 EA84 C6A2 58DF 8823

  parent reply	other threads:[~2006-08-21 12:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-19 23:05 [PATCH] getsockopt() early argument sanity checking 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 [this message]
2006-08-20  8:34 ` Andi Kleen
2006-08-20 10:15   ` Willy Tarreau
2006-08-20 10:50     ` YOSHIFUJI Hideaki / 吉藤英明
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

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=44E9A272.3020202@redhat.com \
    --to=eteo@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --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;
as well as URLs for NNTP newsgroup(s).