netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: minipli@googlemail.com, richard.weinberger@gmail.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH v2] net/tun: fix ioctl() based info leaks
Date: Sun, 29 Jul 2012 23:34:18 -0700 (PDT)	[thread overview]
Message-ID: <20120729.233418.689324134181158219.davem@davemloft.net> (raw)
In-Reply-To: <1343629340.2626.13268.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 30 Jul 2012 08:22:20 +0200

> On Mon, 2012-07-30 at 07:45 +0200, Mathias Krause wrote:
>> The tun module leaks up to 36 bytes of memory by not fully initializing
>> a structure located on the stack that gets copied to user memory by the
>> TUNGETIFF and SIOCGIFHWADDR ioctl()s.
>> 
>> Signed-off-by: Mathias Krause <minipli@googlemail.com>
>> ---
>> v2:
>> - removed braces around else branch
>> - minor adjustment of the commit message
>> 
>>  drivers/net/tun.c |    4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
>> index 987aeef..01255ff 100644
>> --- a/drivers/net/tun.c
>> +++ b/drivers/net/tun.c
>> @@ -1252,9 +1252,11 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
>>  	int vnet_hdr_sz;
>>  	int ret;
>>  
>> -	if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89)
>> +	if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) {
>>  		if (copy_from_user(&ifr, argp, ifreq_len))
>>  			return -EFAULT;
>> +	} else
>> +		memset(&ifr, 0, sizeof(ifr));
>>  
>>  	if (cmd == TUNGETFEATURES) {
>>  		/* Currently this just means: "what IFF flags are valid?".
> 
> 
> Actually braces were better
> 
> vi +169 Documentation/CodingStyle
> 
> This does not apply if only one branch of a conditional statement is a
> single
> statement; in the latter case use braces in both branches:
> 
> if (condition) {
>         do_this();
>         do_that();
> } else {
>         otherwise();
> }

Ok I'll fix this up myself.

      reply	other threads:[~2012-07-30  6:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-29 20:58 [PATCH] net/tun: fix ioctl() based info leaks Mathias Krause
2012-07-29 23:11 ` richard -rw- weinberger
2012-07-30  5:38   ` Mathias Krause
2012-07-30  5:45   ` [PATCH v2] " Mathias Krause
2012-07-30  6:20     ` David Miller
2012-07-30  6:22     ` Eric Dumazet
2012-07-30  6:34       ` David Miller [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=20120729.233418.689324134181158219.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=minipli@googlemail.com \
    --cc=netdev@vger.kernel.org \
    --cc=richard.weinberger@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).