netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: mikulas@artax.karlin.mff.cuni.cz
Cc: eric.dumazet@gmail.com, maxk@qualcomm.com, vtun@office.satix.net,
	netdev@vger.kernel.org
Subject: Re: [PATCH] Crash in tun
Date: Fri, 20 Jul 2012 11:23:37 -0700 (PDT)	[thread overview]
Message-ID: <20120720.112337.474955511809249636.davem@davemloft.net> (raw)
In-Reply-To: <alpine.DEB.2.00.1207191746170.7550@artax.karlin.mff.cuni.cz>

From: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Date: Thu, 19 Jul 2012 18:13:36 +0200 (CEST)

> tun: fix a crash bug and a memory leak
> 
> This patch fixes a crash
> tun_chr_close -> netdev_run_todo -> tun_free_netdev -> sk_release_kernel ->
> sock_release -> iput(SOCK_INODE(sock))
> introduced by commit 1ab5ecb90cb6a3df1476e052f76a6e8f6511cb3d
> 
> The problem is that this socket is embedded in struct tun_struct, it has
> no inode, iput is called on invalid inode, which modifies invalid memory
> and optionally causes a crash.
> 
> sock_release also decrements sockets_in_use, this causes a bug that
> "sockets: used" field in /proc/*/net/sockstat keeps on decreasing when
> creating and closing tun devices.
> 
> This patch introduces a flag SOCK_EXTERNALLY_ALLOCATED that instructs
> sock_release to not free the inode and not decrement sockets_in_use,
> fixing both memory corruption and sockets_in_use underflow.
> 
> It should be backported to 3.3 an 3.4 stabke.
> 
> Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
> Cc: stable@kernel.org

Applied.

  parent reply	other threads:[~2012-07-20 18:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19  1:12 [PATCH] Crash in tun Mikulas Patocka
2012-07-19  6:09 ` Eric Dumazet
2012-07-19 15:28   ` David Miller
2012-07-19 16:13   ` Mikulas Patocka
2012-07-19 17:44     ` Max Krasnyansky
2012-07-19 17:47       ` David Miller
2012-07-19 17:57         ` Max Krasnyansky
2012-07-20 18:23     ` David Miller [this message]
2012-07-21  7:55       ` Al Viro
2012-07-21  9:53         ` Nicholas A. Bellinger
2012-07-23  9:43         ` David Laight

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=20120720.112337.474955511809249636.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=maxk@qualcomm.com \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=netdev@vger.kernel.org \
    --cc=vtun@office.satix.net \
    /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).