linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	tedheadster@gmail.com, luto@kernel.org
Subject: Re: net/3com/3c515: Fix timer handling, prevent leaks and crashes
Date: Fri, 16 Dec 2016 13:25:35 -0500 (EST)	[thread overview]
Message-ID: <20161216.132535.904601621144551948.davem@davemloft.net> (raw)
In-Reply-To: <alpine.DEB.2.20.1612111826310.18281@nanos>

From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 11 Dec 2016 18:31:22 +0100 (CET)

> The timer handling in this driver is broken in several ways:
> 
> - corkscrew_open() initializes and arms a timer before requesting the
>   device interrupt. If the request fails the timer stays armed.
> 
>   A second call to corkscrew_open will unconditionally reinitialize the
>   quued timer and arm it again. Also a immediate device removal will leave
>   the timer queued because close() is not called (open() failed) and
>   therefore nothing issues del_timer().
> 
>   The reinitialization corrupts the link chain in the timer wheel hash
>   bucket and causes a NULL pointer dereference when the timer wheel tries
>   to operate on that hash bucket. Immediate device removal lets the link
>   chain poke into freed and possibly reused memory.
> 
>   Solution: Arm the timer after the successful irq request.
> 
> - corkscrew_close() uses del_timer()
> 
>   On close the timer is disarmed with del_timer() which lets the following
>   code race against a concurrent timer expiry function.
> 
>   Solution: Use del_timer_sync() instead
> 
> - corkscrew_close() calls del_timer() unconditionally
> 
>   del_timer() is invoked even if the timer was never initialized. This
>   works by chance because the struct containing the timer is zeroed at
>   allocation time.
> 
>   Solution: Move the setup of the timer into corkscrew_setup().
> 
> Reported-by: Matthew Whitehead <tedheadster@gmail.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Applied, thanks Thomas.

      reply	other threads:[~2016-12-16 18:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-11 17:31 net/3com/3c515: Fix timer handling, prevent leaks and crashes Thomas Gleixner
2016-12-16 18:25 ` 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=20161216.132535.904601621144551948.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tedheadster@gmail.com \
    --cc=tglx@linutronix.de \
    /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).