]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
6pack: fix free memory scribbles
authorOne Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Tue, 5 Jan 2016 11:51:25 +0000 (11:51 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Jan 2016 06:25:01 +0000 (01:25 -0500)
commit acf673a3187edf72068ee2f92f4dc47d66baed47 fixed a user triggerable free
memory scribble but in doing so replaced it with a different one that allows
the user to control the data and scribble even more.

sixpack_close is called by the tty layer in tty context. The tty context is
protected by sp_get() and sp_put(). However network layer activity via
sp_xmit() is not protected this way. We must therefore stop the queue
otherwise the user gets to dump a buffer mostly of their choice into freed
kernel pages.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hamradio/6pack.c

index 9f0b1c342b770c26453753c52a7543303e09457c..5a1e98547031953b1eae1db7ae59a3750d935f40 100644 (file)
@@ -683,6 +683,12 @@ static void sixpack_close(struct tty_struct *tty)
        if (!atomic_dec_and_test(&sp->refcnt))
                down(&sp->dead_sem);
 
+       /* We must stop the queue to avoid potentially scribbling
+        * on the free buffers. The sp->dead_sem is not sufficient
+        * to protect us from sp->xbuff access.
+        */
+       netif_stop_queue(sp->dev);
+
        del_timer_sync(&sp->tx_t);
        del_timer_sync(&sp->resync_t);