* [PATCH 0/2] uart_close related fixes
@ 2016-10-28 12:07 Rob Herring
2016-10-28 12:07 ` [PATCH 1/2] tty: serial_core: Fix serial console crash on port shutdown Rob Herring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rob Herring @ 2016-10-28 12:07 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, Borislav Petkov, Mike Galbraith, Jiri Slaby,
linux-serial, Niklas Söderlund, Geert Uytterhoeven,
Mugunthan V N
Greg,
As discussed, these are the 2 fixes needed to fix regressions with
761ed4a94582ab29 ("tty: serial_core: convert uart_close to use
tty_port_close"). Hopefully these fix all the fallout.
These apply on top of the previous patch from me which you applied.
Rob
Geert Uytterhoeven (1):
tty: serial_core: Fix serial console crash on port shutdown
Rob Herring (1):
tty: serial_core: fix NULL struct tty pointer access in
uart_write_wakeup
drivers/tty/serial/serial_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--
2.10.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] tty: serial_core: Fix serial console crash on port shutdown
2016-10-28 12:07 [PATCH 0/2] uart_close related fixes Rob Herring
@ 2016-10-28 12:07 ` Rob Herring
2016-10-28 12:07 ` [PATCH 2/2] tty: serial_core: fix NULL struct tty pointer access in uart_write_wakeup Rob Herring
2016-10-28 12:13 ` [PATCH 0/2] uart_close related fixes Greg Kroah-Hartman
2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2016-10-28 12:07 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, Borislav Petkov, Mike Galbraith, Jiri Slaby,
linux-serial, Niklas Söderlund, Geert Uytterhoeven,
Mugunthan V N
From: Geert Uytterhoeven <geert+renesas@glider.be>
The port->console flag is always false, as uart_console() is called
before the serial console has been registered.
Hence for a serial port used as the console, uart_tty_port_shutdown()
will still be called when userspace closes the port, powering it down.
This may lead to a system lock up when the serial console driver writes
to the serial port's registers.
To fix this, move the setting of port->console after the call to
uart_configure_port(), which registers the serial console.
Fixes: 761ed4a94582ab29 ("tty: serial_core: convert uart_close to use tty_port_close")
Reported-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Rob Herring <robh@kernel.org>
Tested-by: Mugunthan V N <mugunthanvnm@ti.com>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
[robh: rebased on tty-linus]
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/tty/serial/serial_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 664c99aeeca5..ce8899c13af3 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2759,6 +2759,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
uart_configure_port(drv, state, uport);
+ port->console = uart_console(uport);
+
num_groups = 2;
if (uport->attr_group)
num_groups++;
--
2.10.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] tty: serial_core: fix NULL struct tty pointer access in uart_write_wakeup
2016-10-28 12:07 [PATCH 0/2] uart_close related fixes Rob Herring
2016-10-28 12:07 ` [PATCH 1/2] tty: serial_core: Fix serial console crash on port shutdown Rob Herring
@ 2016-10-28 12:07 ` Rob Herring
2016-10-28 12:13 ` [PATCH 0/2] uart_close related fixes Greg Kroah-Hartman
2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2016-10-28 12:07 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, Borislav Petkov, Mike Galbraith, Jiri Slaby,
linux-serial, Niklas Söderlund, Geert Uytterhoeven,
Mugunthan V N
Since commit 761ed4a94582ab29 ("tty: serial_core: convert uart_close to
use tty_port_close"), the serial console is broken on various systems
and typing "reboot" splats the following on the serial console:
INIT: Sending p[ 427.863916] BUG: unable to handle kernel NULL pointer dereference at 00000000000001e0
[ 427.885156] IP: [] tty_wakeup+0xc/0x70
[ 427.898337] PGD 0 [ 427.902051]
[ 427.907498] Oops: 0000 [#1] PREEMPT SMP
[ 427.917635] Modules linked in: nfsv3 nfs_acl nfs fscache lockd
sunrpc grace edd af_packet cpufreq_conservative cpufreq_userspace
cpufreq_powersave fuse loop md_mod dm_mod joydev hid_generic usbhid
ipmi_ssif ohci_pci ohci_hcd ehci_pci ehci_hcd e1000e ptp firewire_ohci
edac_core pps_core tpm_infineon sp5100_tco firewire_core acpi_cpufreq
serio_raw pcspkr fjes usbcore shpchp edac_mce_amd tpm_tis ipmi_si
tpm_tis_core i2c_piix4 k10temp sg ipmi_msghandler tpm sr_mod button
cdrom kvm_amd kvm irqbypass crc_itu_t ast ttm drm_kms_helper drm
fb_sys_fops sysimgblt sysfillrect syscopyarea i2c_algo_bit scsi_dh_rdac
scsi_dh_alua scsi_dh_emc scsi_dh_hp_sw ata_generic pata_atiixp
[ 428.054179] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.9.0-rc1-1.g73e3f23-default #1
[ 428.072868] Hardware name: System manufacturer System Product Name/KGP(M)E-D16, BIOS 0902 12/03/2010
[ 428.094755] task: ffffffffa2c0d500 task.stack: ffffffffa2c00000
[ 428.109717] RIP: 0010:[] [] tty_wakeup+0xc/0x70
[ 428.128407] RSP: 0018:ffff9a1a5fc03df8 EFLAGS: 00010086
[ 428.142184] RAX: ffff9a1857258000 RBX: ffffffffa3050ea0 RCX: 0000000000000000
[ 428.159649] RDX: 000000000000001b RSI: 0000000000000000 RDI: 0000000000000000
[ 428.177109] RBP: ffff9a1a5fc03e08 R08: 0000000000000000 R09: 0000000000000000
[ 428.194547] R10: 0000000000021c77 R11: 0000000000000000 R12: ffff9a1857258000
[ 428.212002] R13: 0000000000000000 R14: 0000000000000020 R15: 0000000000000020
[ 428.229481] FS: 0000000000000000(0000) GS:ffff9a1a5fc00000(0000) knlGS:0000000000000000
[ 428.248938] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 428.263726] CR2: 00000000000001e0 CR3: 0000000390c06000 CR4: 00000000000006f0
[ 428.281331] Stack:
[ 428.288696] ffffffffa3050ea0 ffff9a1857258000 ffff9a1a5fc03e18 ffffffffa24e0ab1
[ 428.307064] ffff9a1a5fc03e40 ffffffffa24e8865 ffffffffa3050ea0 00000000000000c2
[ 428.325456] 0000000000000046 ffff9a1a5fc03e78 ffffffffa24e8a5f ffffffffa3050ea0
[ 428.343905] Call Trace:
[ 428.352319] [ 428.356216] [] uart_write_wakeup+0x21/0x30
The problem is for console ports, the serial port is not shutdown and
interrupts may fire after the struct tty is gone. Simply calling the
tty_port helper tty_port_tty_wakeup instead of tty_wakeup directly will
ensure there is a valid struct tty.
Fixes: 761ed4a94582ab29 ("tty: serial_core: convert uart_close to use tty_port_close")
Reported-by: Borislav Petkov <bp@alien8.de>
Reported-by: Mike Galbraith <mgalbraith@suse.de>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/tty/serial/serial_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index ce8899c13af3..f2303f390345 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -111,7 +111,7 @@ void uart_write_wakeup(struct uart_port *port)
* closed. No cookie for you.
*/
BUG_ON(!state);
- tty_wakeup(state->port.tty);
+ tty_port_tty_wakeup(&state->port);
}
static void uart_stop(struct tty_struct *tty)
@@ -632,7 +632,7 @@ static void uart_flush_buffer(struct tty_struct *tty)
if (port->ops->flush_buffer)
port->ops->flush_buffer(port);
uart_port_unlock(port, flags);
- tty_wakeup(tty);
+ tty_port_tty_wakeup(&state->port);
}
/*
--
2.10.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] uart_close related fixes
2016-10-28 12:07 [PATCH 0/2] uart_close related fixes Rob Herring
2016-10-28 12:07 ` [PATCH 1/2] tty: serial_core: Fix serial console crash on port shutdown Rob Herring
2016-10-28 12:07 ` [PATCH 2/2] tty: serial_core: fix NULL struct tty pointer access in uart_write_wakeup Rob Herring
@ 2016-10-28 12:13 ` Greg Kroah-Hartman
2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-28 12:13 UTC (permalink / raw)
To: Rob Herring
Cc: linux-kernel, Borislav Petkov, Mike Galbraith, Jiri Slaby,
linux-serial, Niklas Söderlund, Geert Uytterhoeven,
Mugunthan V N
On Fri, Oct 28, 2016 at 07:07:46AM -0500, Rob Herring wrote:
> Greg,
>
> As discussed, these are the 2 fixes needed to fix regressions with
> 761ed4a94582ab29 ("tty: serial_core: convert uart_close to use
> tty_port_close"). Hopefully these fix all the fallout.
>
> These apply on top of the previous patch from me which you applied.
Thanks for them, all now applied.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-28 12:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-28 12:07 [PATCH 0/2] uart_close related fixes Rob Herring
2016-10-28 12:07 ` [PATCH 1/2] tty: serial_core: Fix serial console crash on port shutdown Rob Herring
2016-10-28 12:07 ` [PATCH 2/2] tty: serial_core: fix NULL struct tty pointer access in uart_write_wakeup Rob Herring
2016-10-28 12:13 ` [PATCH 0/2] uart_close related fixes Greg Kroah-Hartman
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).