From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Xinyu Chen <xinyu.chen@freescale.com>,
Dirk Behme <dirk.behme@de.bosch.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Shawn Guo <shawn.guo@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [ 110/135] tty: serial: imx: console write routing is unsafe on SMP
Date: Mon, 17 Sep 2012 01:38:15 +0100 [thread overview]
Message-ID: <20120917003641.451592910@decadent.org.uk> (raw)
In-Reply-To: <20120917003625.784119135@decadent.org.uk>
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xinyu Chen <xinyu.chen@freescale.com>
commit 9ec1882df244c4ee1baa692676fef5e8b0f5487d upstream.
The console feature's write routing is unsafe on SMP with
the startup/shutdown call.
There could be several consumers of the console
* the kernel printk
* the init process using /dev/kmsg to call printk to show log
* shell, which open /dev/console and write with sys_write()
The shell goes into the normal uart open/write routing,
but the other two go into the console operations.
The open routing calls imx serial startup, which will write USR1/2
register without any lock and critical with imx_console_write call.
Add a spin_lock for startup/shutdown/console_write routing.
This patch is a port from Freescale's Android kernel.
Signed-off-by: Xinyu Chen <xinyu.chen@freescale.com>
Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
CC: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/tty/serial/imx.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -725,6 +725,7 @@ static int imx_startup(struct uart_port
}
}
+ spin_lock_irqsave(&sport->port.lock, flags);
/*
* Finally, clear and enable interrupts
*/
@@ -778,7 +779,6 @@ static int imx_startup(struct uart_port
/*
* Enable modem status interrupts
*/
- spin_lock_irqsave(&sport->port.lock,flags);
imx_enable_ms(&sport->port);
spin_unlock_irqrestore(&sport->port.lock,flags);
@@ -808,10 +808,13 @@ static void imx_shutdown(struct uart_por
{
struct imx_port *sport = (struct imx_port *)port;
unsigned long temp;
+ unsigned long flags;
+ spin_lock_irqsave(&sport->port.lock, flags);
temp = readl(sport->port.membase + UCR2);
temp &= ~(UCR2_TXEN);
writel(temp, sport->port.membase + UCR2);
+ spin_unlock_irqrestore(&sport->port.lock, flags);
if (USE_IRDA(sport)) {
struct imxuart_platform_data *pdata;
@@ -840,12 +843,14 @@ static void imx_shutdown(struct uart_por
* Disable all interrupts, port and break condition.
*/
+ spin_lock_irqsave(&sport->port.lock, flags);
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
if (USE_IRDA(sport))
temp &= ~(UCR1_IREN);
writel(temp, sport->port.membase + UCR1);
+ spin_unlock_irqrestore(&sport->port.lock, flags);
}
static void
@@ -1119,6 +1124,9 @@ imx_console_write(struct console *co, co
{
struct imx_port *sport = imx_ports[co->index];
unsigned int old_ucr1, old_ucr2, ucr1;
+ unsigned long flags;
+
+ spin_lock_irqsave(&sport->port.lock, flags);
/*
* First, save UCR1/2 and then disable interrupts
@@ -1145,6 +1153,8 @@ imx_console_write(struct console *co, co
writel(old_ucr1, sport->port.membase + UCR1);
writel(old_ucr2, sport->port.membase + UCR2);
+
+ spin_unlock_irqrestore(&sport->port.lock, flags);
}
/*
next prev parent reply other threads:[~2012-09-17 1:23 UTC|newest]
Thread overview: 141+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-17 0:36 [ 000/135] 3.2.30-stable review Ben Hutchings
2012-09-17 0:36 ` [ 001/135] [PARISC] Redefine ATOMIC_INIT and ATOMIC64_INIT to drop the casts Ben Hutchings
2012-09-17 0:36 ` [ 002/135] ARM: S3C24XX: Fix s3c2410_dma_enqueue parameters Ben Hutchings
2012-09-17 0:36 ` [ 003/135] ARM: OMAP2+: Fix dmtimer set source clock failure Ben Hutchings
2012-09-17 0:36 ` [ 004/135] ARM: Orion: Set eth packet size csum offload limit Ben Hutchings
2012-09-17 0:36 ` [ 005/135] iwlwifi: fix flow handler debug code Ben Hutchings
2012-09-17 0:36 ` [ 006/135] iwlwifi: protect SRAM debugfs Ben Hutchings
2012-09-17 0:36 ` [ 007/135] Input: i8042 - add Gigabyte T1005 series netbooks to noloop table Ben Hutchings
2012-09-17 0:36 ` [ 008/135] [SCSI] mpt2sas: Fix for Driver oops, when loading driver with max_queue_depth command line option to a very small value Ben Hutchings
2012-09-17 0:36 ` [ 009/135] [SCSI] megaraid_sas: Move poll_aen_lock initializer Ben Hutchings
2012-09-17 0:36 ` [ 010/135] [SCSI] Fix Device not ready issue on mpt2sas Ben Hutchings
2012-09-17 0:36 ` [ 011/135] hwmon: (asus_atk0110) Add quirk for Asus M5A78L Ben Hutchings
2012-09-17 0:36 ` [ 012/135] drm/i915: Fix assert_pch_hdmi_disabled to mention HDMI (not DP) Ben Hutchings
2012-09-17 0:36 ` [ 013/135] drm/i915: fix wrong order of parameters in port checking functions Ben Hutchings
2012-09-17 0:36 ` [ 014/135] OMAPFB: fix framebuffer console colors Ben Hutchings
2012-09-17 0:36 ` [ 015/135] ARM: imx6: spin the cpu until hardware takes it down Ben Hutchings
2012-09-17 0:36 ` [ 016/135] ARM: dts: imx51-babbage: fix esdhc cd/wp properties Ben Hutchings
2012-09-17 0:36 ` [ 017/135] xen/setup: Fix one-off error when adding for-balloon PFNs to the P2M Ben Hutchings
2012-09-17 0:36 ` [ 018/135] ARM: imx: select CPU_FREQ_TABLE when needed Ben Hutchings
2012-09-17 0:36 ` [ 019/135] drm: remove some potentially dangerous DRM_ERRORs Ben Hutchings
2012-09-17 0:36 ` [ 020/135] drm: Check for invalid cursor flags Ben Hutchings
2012-09-17 0:36 ` [ 021/135] HID: multitouch: support PixArt optical touch screen Ben Hutchings
2012-09-17 0:36 ` [ 022/135] HID: add NOGET quirk for Eaton Ellipse MAX UPS Ben Hutchings
2012-09-17 0:36 ` [ 023/135] drm/radeon: dont disable plls that are in use by other crtcs Ben Hutchings
2012-09-17 0:36 ` [ 024/135] drm/radeon/atom: rework DIG modesetting on DCE3+ Ben Hutchings
2012-09-17 0:36 ` [ 025/135] drm/radeon: force dma32 to fix regression rs4xx,rs6xx,rs740 Ben Hutchings
2012-09-17 0:36 ` [ 026/135] drm/edid/quirks: ViewSonic VA2026w Ben Hutchings
2012-09-17 0:36 ` [ 027/135] drm: Add EDID_QUIRK_FORCE_REDUCED_BLANKING for ASUS VW222S Ben Hutchings
2012-09-17 0:36 ` [ 028/135] e1000e: DoS while TSO enabled caused by link partner with small MSS Ben Hutchings
2012-09-17 0:36 ` [ 029/135] ext3: Fix fdatasync() for files with only i_size changes Ben Hutchings
2012-09-17 0:36 ` [ 030/135] UBI: fix a horrible memory deallocation bug Ben Hutchings
2012-09-17 0:36 ` [ 031/135] fuse: fix retrieve length Ben Hutchings
2012-09-17 0:36 ` [ 032/135] mmc: mxs-mmc: fix deadlock in SDIO IRQ case Ben Hutchings
2012-09-17 0:36 ` [ 033/135] mmc: mxs-mmc: fix deadlock caused by recursion loop Ben Hutchings
2012-09-17 0:36 ` [ 034/135] mmc: sdhci-esdhc: break out early if clock is 0 Ben Hutchings
2012-09-17 0:37 ` [ 035/135] mmc: card: Skip secure erase on MoviNAND; causes unrecoverable corruption Ben Hutchings
2012-09-17 0:37 ` [ 036/135] powerpc: Update DSCR on all CPUs when writing sysfs dscr_default Ben Hutchings
2012-09-17 0:37 ` [ 037/135] powerpc: Keep thread.dscr and thread.dscr_inherit in sync Ben Hutchings
2012-09-17 0:37 ` [ 038/135] powerpc: Fix DSCR inheritance in copy_thread() Ben Hutchings
2012-09-17 0:37 ` [ 039/135] powerpc: Restore correct DSCR in context switch Ben Hutchings
2012-09-17 0:37 ` [ 040/135] powerpc/xics: Harden xics hypervisor backend Ben Hutchings
2012-09-17 0:37 ` [ 041/135] powerpc: Make sure IPI handlers see data written by IPI senders Ben Hutchings
2012-09-17 0:37 ` [ 042/135] udf: Fix data corruption for files in ICB Ben Hutchings
2012-09-17 0:37 ` [ 043/135] xen: Use correct masking in xen_swiotlb_alloc_coherent Ben Hutchings
2012-09-17 0:37 ` [ 044/135] Remove user-triggerable BUG from mpol_to_str Ben Hutchings
2012-09-17 0:37 ` [ 045/135] CIFS: Fix error handling in cifs_push_mandatory_locks Ben Hutchings
2012-09-17 0:37 ` [ 046/135] drm/vmwgfx: add MODULE_DEVICE_TABLE so vmwgfx loads at boot Ben Hutchings
2012-09-17 0:37 ` [ 047/135] i2c-designware: Fix build error if CONFIG_I2C_DESIGNWARE_PLATFORM=y && CONFIG_I2C_DESIGNWARE_PCI=y Ben Hutchings
2012-09-17 0:37 ` [ 048/135] net: Allow driver to limit number of GSO segments per skb Ben Hutchings
2012-09-17 0:37 ` [ 049/135] sfc: Fix maximum number of TSO segments and minimum TX queue size Ben Hutchings
2012-09-17 0:37 ` [ 050/135] tcp: Apply device TSO segment limit earlier Ben Hutchings
2012-09-17 0:37 ` [ 051/135] net_sched: gact: Fix potential panic in tcf_gact() Ben Hutchings
2012-09-17 0:37 ` [ 052/135] isdnloop: fix and simplify isdnloop_init() Ben Hutchings
2012-09-17 0:37 ` [ 053/135] pptp: lookup route with the proper net namespace Ben Hutchings
2012-09-17 0:37 ` [ 054/135] net/core: Fix potential memory leak in dev_set_alias() Ben Hutchings
2012-09-17 0:37 ` [ 055/135] af_packet: remove BUG statement in tpacket_destruct_skb Ben Hutchings
2012-09-17 0:37 ` [ 056/135] ipv6: addrconf: Avoid calling netdevice notifiers with RCU read-side lock Ben Hutchings
2012-09-17 0:37 ` [ 057/135] atm: fix info leak in getsockopt(SO_ATMPVC) Ben Hutchings
2012-09-17 0:37 ` [ 058/135] atm: fix info leak via getsockname() Ben Hutchings
2012-09-17 0:37 ` [ 059/135] Bluetooth: HCI - Fix info leak in getsockopt(HCI_FILTER) Ben Hutchings
2012-09-17 0:37 ` [ 060/135] Bluetooth: HCI - Fix info leak via getsockname() Ben Hutchings
2012-09-17 0:37 ` [ 061/135] Bluetooth: RFCOMM - Fix info leak in getsockopt(BT_SECURITY) Ben Hutchings
2012-09-17 0:37 ` [ 062/135] Bluetooth: RFCOMM - Fix info leak in ioctl(RFCOMMGETDEVLIST) Ben Hutchings
2012-09-17 0:37 ` [ 063/135] Bluetooth: RFCOMM - Fix info leak via getsockname() Ben Hutchings
2012-09-17 0:37 ` [ 064/135] Bluetooth: L2CAP " Ben Hutchings
2012-09-17 0:37 ` [ 065/135] llc: fix " Ben Hutchings
2012-09-17 0:37 ` [ 066/135] dccp: fix info leak via getsockopt(DCCP_SOCKOPT_CCID_TX_INFO) Ben Hutchings
2012-09-17 0:37 ` [ 067/135] ipvs: fix info leak in getsockopt(IP_VS_SO_GET_TIMEOUT) Ben Hutchings
2012-09-17 0:37 ` [ 068/135] net: fix info leak in compat dev_ifconf() Ben Hutchings
2012-09-17 0:37 ` [ 069/135] af_packet: dont emit packet on orig fanout group Ben Hutchings
2012-09-17 0:37 ` [ 070/135] af_netlink: force credentials passing [CVE-2012-3520] Ben Hutchings
2012-09-17 0:37 ` [ 071/135] netlink: fix possible spoofing from non-root processes Ben Hutchings
2012-09-17 0:37 ` [ 072/135] gianfar: fix default tx vlan offload feature flag Ben Hutchings
2012-09-17 0:37 ` [ 073/135] l2tp: avoid to use synchronize_rcu in tunnel free function Ben Hutchings
2012-09-17 0:37 ` [ 074/135] net: ipv4: ipmr_expire_timer causes crash when removing net namespace Ben Hutchings
2012-09-17 0:37 ` [ 075/135] bnx2x: fix 57840_MF pci id Ben Hutchings
2012-09-17 0:37 ` [ 076/135] workqueue: UNBOUND -> REBIND morphing in rebind_workers() should be atomic Ben Hutchings
2012-09-17 0:37 ` [ 077/135] fixing dmi match for hp t5745 and hp st5747 thin client Ben Hutchings
2012-09-17 0:37 ` [ 078/135] time: Improve sanity checking of timekeeping inputs Ben Hutchings
2012-09-17 0:37 ` [ 079/135] time: Avoid making adjustments if we havent accumulated anything Ben Hutchings
2012-09-17 0:37 ` [ 080/135] time: Move ktime_t overflow checking into timespec_valid_strict Ben Hutchings
2012-09-17 0:37 ` [ 081/135] drm/i915: Wait for all pending operations to the fb before disabling the pipe Ben Hutchings
2012-09-17 0:37 ` [ 082/135] xhci: Fix bug after deq ptr set to link TRB Ben Hutchings
2012-09-17 0:37 ` [ 083/135] ARM: 7487/1: mm: avoid setting nG bit for user mappings that arent present Ben Hutchings
2012-09-17 0:37 ` [ 084/135] i2c-i801: Add device IDs for Intel Lynx Point Ben Hutchings
2012-09-17 0:37 ` [ 085/135] i2c-i801: Add Device IDs for Intel Lynx Point-LP PCH Ben Hutchings
2012-09-17 0:37 ` [ 086/135] USB: option: add ZTE K5006-Z Ben Hutchings
2012-09-17 0:37 ` [ 087/135] USB: option: replace ZTE K5006-Z entry with vendor class rule Ben Hutchings
2012-09-17 0:37 ` [ 088/135] ARM: 7496/1: hw_breakpoint: dont rely on dfsr to show watchpoint access type Ben Hutchings
2012-09-17 0:37 ` [ 089/135] drm/i915: SDVO hotplug have different interrupt status bits for i915/i965/g4x Ben Hutchings
2012-09-17 0:37 ` [ 090/135] drm/i915: only enable sdvo hotplug irq if needed Ben Hutchings
2012-09-17 0:37 ` [ 091/135] can: mcp251x: avoid repeated frame bug Ben Hutchings
2012-09-17 0:37 ` [ 092/135] perf_event: Switch to internal refcount, fix race with close() Ben Hutchings
2012-09-17 0:37 ` [ 093/135] NFS: Fix the initialisation of the readdir cookieverf array Ben Hutchings
2012-09-17 0:37 ` [ 094/135] NFS: Fix a problem with the legacy binary mount code Ben Hutchings
2012-09-17 0:38 ` [ 095/135] staging: comedi: das08: Correct AI encoding for das08jr-16-ao Ben Hutchings
2012-09-17 0:38 ` [ 096/135] staging: comedi: das08: Correct AO output " Ben Hutchings
2012-09-17 0:38 ` [ 097/135] staging: vt6656: [BUG] - Failed connection, incorrect endian Ben Hutchings
2012-09-17 0:38 ` [ 098/135] xhci: Recognize USB 3.0 devices as superspeed at powerup Ben Hutchings
2012-09-17 0:38 ` [ 099/135] Intel xhci: Only switch the switchable ports Ben Hutchings
2012-09-17 0:38 ` [ 100/135] rt2x00: Identify ASUS USB-N53 device Ben Hutchings
2012-09-17 0:38 ` [ 101/135] rt2x00: Fix word size of rt2500usb MAC_CSR19 register Ben Hutchings
2012-09-17 0:38 ` [ 102/135] rt2x00: Fix rfkill polling prior to interface start Ben Hutchings
2012-09-17 0:38 ` [ 103/135] rt2800usb: Added rx packet length validity check Ben Hutchings
2012-09-17 0:38 ` [ 104/135] staging: zcache: fix cleancache race condition with shrinker Ben Hutchings
2012-09-17 0:38 ` [ 105/135] xhci: Switch PPT ports to EHCI on shutdown Ben Hutchings
2012-09-17 0:38 ` [ 106/135] xhci: Fix a logical vs bitwise AND bug Ben Hutchings
2012-09-17 0:38 ` [ 107/135] xhci: Make handover code more robust Ben Hutchings
2012-09-17 0:38 ` [ 108/135] usb: host: xhci: Fix Compliance Mode on SN65LVPE502CP Hardware Ben Hutchings
2012-09-17 0:38 ` [ 109/135] usb: host: xhci: fix compilation error for non-PCI based stacks Ben Hutchings
2012-09-17 0:38 ` Ben Hutchings [this message]
2012-09-17 0:38 ` [ 111/135] tty: serial: imx: dont reinit clock in imx_setup_ufcr() Ben Hutchings
2012-09-17 0:38 ` [ 112/135] ibmveth: Fix alignment of rx queue bug Ben Hutchings
2012-09-17 0:38 ` [ 113/135] USB: ftdi-sio: add support for more Physik Instrumente devices Ben Hutchings
2012-09-17 0:38 ` [ 114/135] USB: ftdi_sio: PID for NZR SEM 16+ USB Ben Hutchings
2012-09-17 0:38 ` [ 115/135] USB: add device quirk for Joss Optical touchboard Ben Hutchings
2012-09-17 0:38 ` [ 116/135] kobject: fix oops with "input0: bad kobj_uevent_env content in show_uevent()" Ben Hutchings
2012-09-17 0:38 ` [ 117/135] NFS: return error from decode_getfh in decode open Ben Hutchings
2012-09-19 1:26 ` Herton Ronaldo Krzesinski
2012-09-19 3:39 ` Ben Hutchings
2012-09-19 15:53 ` Myklebust, Trond
2012-09-20 1:21 ` Ben Hutchings
2012-09-17 0:38 ` [ 118/135] SUNRPC: Fix a UDP transport regression Ben Hutchings
2012-09-17 0:38 ` [ 119/135] ARM: 7513/1: Make sure dtc is built before running it Ben Hutchings
2012-09-17 0:38 ` [ 120/135] ARM: 7526/1: traps: send SIGILL if get_user fails on undef handling path Ben Hutchings
2012-09-17 0:38 ` [ 121/135] ALSA: hda - Fix Oops at codec reset/reconfig Ben Hutchings
2012-09-17 0:38 ` [ 122/135] USB: ftdi_sio: do not claim CDC ACM function Ben Hutchings
2012-09-17 0:38 ` [ 123/135] staging: r8712u: fix bug in r8712_recv_indicatepkt() Ben Hutchings
2012-09-17 0:38 ` [ 124/135] EHCI: Update qTD next pointer in QH overlay region during unlink Ben Hutchings
2012-09-17 0:38 ` [ 125/135] hwmon: (twl4030-madc-hwmon) Initialize uninitialized structure elements Ben Hutchings
2012-09-17 0:38 ` [ 126/135] ALSA: ice1724: Use linear scale for AK4396 volume control Ben Hutchings
2012-09-17 0:38 ` [ 127/135] vmwgfx: add dumb ioctl support Ben Hutchings
2012-09-17 0:38 ` [ 128/135] ahci: Add alternate identifier for the 88SE9172 Ben Hutchings
2012-09-17 0:38 ` [ 129/135] drm/radeon: fix up pll selection on DCE5/6 Ben Hutchings
2012-09-17 0:38 ` [ 130/135] drm/radeon: fix ordering in pll picking on dce4+ Ben Hutchings
2012-09-17 0:38 ` [ 131/135] drm/radeon: rework pll selection (v3) Ben Hutchings
2012-09-17 0:38 ` [ 132/135] drm/nouveau: fix booting with plymouth + dumb support Ben Hutchings
2012-09-17 0:38 ` [ 133/135] eCryptfs: Copy up attributes of the lower target inode after rename Ben Hutchings
2012-09-17 0:38 ` [ 134/135] VFS: make vfs_fstat() use f[get|put]_light() Ben Hutchings
2012-09-17 0:38 ` [ 135/135] vfs: make O_PATH file descriptors usable for fstat() Ben Hutchings
2012-09-17 0:53 ` [ 000/135] 3.2.30-stable review Ben Hutchings
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=20120917003641.451592910@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=dirk.behme@de.bosch.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawn.guo@linaro.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=xinyu.chen@freescale.com \
/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
Powered by JetHome