linux/drivers/net/irda
Peter Hurley ee01ab7049 net: irda: Fix use-after-free in irtty_open()
commit 401879c57f upstream.

The N_IRDA line discipline may access the previous line discipline's closed
and already-fre private data on open [1].

The tty->disc_data field _never_ refers to valid data on entry to the
line discipline's open() method. Rather, the ldisc is expected to
initialize that field for its own use for the lifetime of the instance
(ie. from open() to close() only).

[1]
    ==================================================================
    BUG: KASAN: use-after-free in irtty_open+0x422/0x550 at addr ffff8800331dd068
    Read of size 4 by task a.out/13960
    =============================================================================
    BUG kmalloc-512 (Tainted: G    B          ): kasan: bad access detected
    -----------------------------------------------------------------------------
    ...
    Call Trace:
     [<ffffffff815fa2ae>] __asan_report_load4_noabort+0x3e/0x40 mm/kasan/report.c:279
     [<ffffffff836938a2>] irtty_open+0x422/0x550 drivers/net/irda/irtty-sir.c:436
     [<ffffffff829f1b80>] tty_ldisc_open.isra.2+0x60/0xa0 drivers/tty/tty_ldisc.c:447
     [<ffffffff829f21c0>] tty_set_ldisc+0x1a0/0x940 drivers/tty/tty_ldisc.c:567
     [<     inline     >] tiocsetd drivers/tty/tty_io.c:2650
     [<ffffffff829da49e>] tty_ioctl+0xace/0x1fd0 drivers/tty/tty_io.c:2883
     [<     inline     >] vfs_ioctl fs/ioctl.c:43
     [<ffffffff816708ac>] do_vfs_ioctl+0x57c/0xe60 fs/ioctl.c:607
     [<     inline     >] SYSC_ioctl fs/ioctl.c:622
     [<ffffffff81671204>] SyS_ioctl+0x74/0x80 fs/ioctl.c:613
     [<ffffffff852a7876>] entry_SYSCALL_64_fastpath+0x16/0x7a

Reported-and-tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2016-05-01 00:05:47 +02:00
..
act200l-sir.c drivers/net/*/: Use static const 2010-12-21 02:16:10 -08:00
actisys-sir.c irda: replace __FUNCTION__ with __func__ 2008-07-30 17:20:18 -07:00
ali-ircc.c treewide: Fix common typo in "identify" 2013-10-14 15:31:06 +02:00
ali-ircc.h irda: convert to internal stats 2009-01-06 10:40:43 -08:00
au1k_ir.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
bfin_sir.c irda: remove deprecated IRQF_DISABLED 2013-10-07 15:53:52 -04:00
bfin_sir.h net/irda: convert bfin_sir to common Blackfin UART header 2011-05-24 01:13:11 -04:00
donauboe.c irda: remove deprecated IRQF_DISABLED 2013-10-07 15:53:52 -04:00
donauboe.h Fix common misspellings 2011-03-31 11:26:23 -03:00
esi-sir.c irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
girbil-sir.c Fix common misspellings 2011-03-31 11:26:23 -03:00
irda-usb.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
irda-usb.h drivers/net: use __packed annotation 2010-06-03 03:18:23 -07:00
irtty-sir.c net: irda: Fix use-after-free in irtty_open() 2016-05-01 00:05:47 +02:00
irtty-sir.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
Kconfig irda: sh_irda: Enable driver compilation with COMPILE_TEST 2014-05-14 15:23:55 -04:00
kingsun-sir.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
ks959-sir.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
ksdazzle-sir.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
litelink-sir.c irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
ma600-sir.c irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
Makefile net: irda: ep7211-sir: Remove driver 2014-02-06 19:54:48 -08:00
mcp2120-sir.c irda: replace __FUNCTION__ with __func__ 2008-07-30 17:20:18 -07:00
mcs7780.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
mcs7780.h irda: convert to netdev_tx_t 2009-09-01 01:13:38 -07:00
nsc-ircc.c treewide: Fix common typo in "identify" 2013-10-14 15:31:06 +02:00
nsc-ircc.h Fix common misspellings 2011-03-31 11:26:23 -03:00
old_belkin-sir.c irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
pxaficp_ir.c net: irda: pxaficp_ir: use platform_set_drvdata() 2013-08-21 20:51:10 -07:00
sa1100_ir.c drivers/net/irda/sa1100_ir.c: fix error return code 2012-10-07 14:37:11 -04:00
sh_irda.c irda: sh_irda: use devm_request_irq() 2014-01-09 22:57:13 -05:00
sh_sir.c irda: sh_sir: Use cpufreq_for_each_valid_entry macro for iteration 2014-04-30 00:06:54 +02:00
sir-dev.h irda: Remove extern from function prototypes 2013-09-24 12:54:17 -07:00
sir_dev.c irda: sir_dev: Fix copy/paste typo 2012-11-20 15:51:55 -05:00
sir_dongle.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
smsc-ircc2.c irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
smsc-ircc2.h irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
smsc-sio.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
stir4200.c drivers/net: delete non-required instances of include <linux/init.h> 2014-01-16 11:53:26 -08:00
tekram-sir.c irda: replace __FUNCTION__ with __func__ 2008-07-30 17:20:18 -07:00
toim3232-sir.c treewide: transciever/transceiver spelling fixes 2011-06-24 11:20:14 +02:00
via-ircc.c via-ircc: Remove useless return variables 2014-06-02 17:04:05 -07:00
via-ircc.h irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
vlsi_ir.c irda: vlsi_ir: remove unnecessary pci_set_drvdata() 2013-12-09 18:09:28 -05:00
vlsi_ir.h irda: Fix FSF address in file headers 2013-12-06 12:37:55 -05:00
w83977af.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
w83977af_ir.c w83977af_ir: remove two faux Kconfig macros 2014-05-07 15:24:07 -04:00
w83977af_ir.h irda: convert to internal stats 2009-01-06 10:40:43 -08:00