All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Genoud <richard.genoud@gmail.com>
To: Jiri Slaby <jslaby@suse.cz>, stable@vger.kernel.org
Subject: Re: [patch added to 3.12-stable] tty/serial: atmel: fix race condition (TX+DMA)
Date: Mon, 10 Apr 2017 15:47:33 +0200	[thread overview]
Message-ID: <31c49511-39de-1a15-f0e8-ce65c6fd8725@gmail.com> (raw)
In-Reply-To: <20170410125930.26495-43-jslaby@suse.cz>

On 10/04/2017 14:59, Jiri Slaby wrote:
> From: Richard Genoud <richard.genoud@gmail.com>
> 
> This patch has been added to the 3.12 stable tree. If you have any
> objections, please let us know.
> 
> ===============
> 
> commit 31ca2c63fdc0aee725cbd4f207c1256f5deaabde upstream.
> 
> If uart_flush_buffer() is called between atmel_tx_dma() and
> atmel_complete_tx_dma(), the circular buffer has been cleared, but not
> atmel_port->tx_len.
> That leads to a circular buffer overflow (dumping (UART_XMIT_SIZE -
> atmel_port->tx_len) bytes).
> 
> Tested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
>  drivers/tty/serial/atmel_serial.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index ab2e22bf54fd..0e0023f7c18d 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -1690,6 +1690,11 @@ static void atmel_flush_buffer(struct uart_port *port)
>  		UART_PUT_TCR(port, 0);
>  		atmel_port->pdc_tx.ofs = 0;
>  	}
> +	/*
> +	 * in uart_flush_buffer(), the xmit circular buffer has just
> +	 * been cleared, so we have to reset tx_len accordingly.
> +	 */
> +	atmel_port->tx_len = 0;
>  }
>  
>  /*
> 
Hi,
This won't compile on 3.12 kernel since ->tx_len doesn't exist yet.

Here is the backported version of this patch:
Thanks !
======================

commit 31ca2c63fdc0aee725cbd4f207c1256f5deaabde upstream.

If uart_flush_buffer() is called between atmel_tx_dma() and
atmel_complete_tx_dma(), the circular buffer has been cleared, but not
atmel_port->tx_len.
That leads to a circular buffer overflow (dumping (UART_XMIT_SIZE -
atmel_port->tx_len) bytes).

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 drivers/tty/serial/atmel_serial.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/atmel_serial.c
b/drivers/tty/serial/atmel_serial.c
index ab2e22bf54fd..04a809284d63 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1690,6 +1690,11 @@ static void atmel_flush_buffer(struct uart_port
*port)
 		UART_PUT_TCR(port, 0);
 		atmel_port->pdc_tx.ofs = 0;
 	}
+	/*
+	 * in uart_flush_buffer(), the xmit circular buffer has just
+	 * been cleared, so we have to reset its length accordingly.
+	 */
+	sg_dma_len(&atmel_port->sg_tx) = 0;
 }

 /*

  reply	other threads:[~2017-04-10 13:47 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 12:58 [patch added to 3.12-stable] Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000 Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: iforce - validate number of endpoints before using them Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: ims-pcu " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: hanwang " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: yealink " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: cm109 " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: kbtab " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] ALSA: seq: Fix racy cell insertions during snd_seq_pool_done() Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: serial: qcserial: add Dell DW5811e Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] ACM gadget: fix endianness in notifications Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: uss720: fix NULL-deref at probe Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: idmouse: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: wusbcore: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] usb: hub: Fix crash after failure to read BOS descriptor Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] uwb: i1480-dfu: fix NULL-deref at probe Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] uwb: hwa-rc: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] mmc: ushc: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] ext4: mark inode dirty after converting inline directory Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] mmc: sdhci: Do not disable interrupts while waiting for clock Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] nl80211: fix dumpit error path RTNL deadlocks Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] USB: usbtmc: add missing endpoint sanity check Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] xfs: clear _XBF_PAGES from buffers when readahead page Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] block: allow WRITE_SAME commands with the SG_IO ioctl Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] uvcvideo: uvc_scan_fallback() for webcams with broken chain Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] fbcon: Fix vc attr at deinit Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] crypto: algif_hash - avoid zero-sized array Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] virtio_balloon: init 1st buffer in stats vq Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] c6x/ptrace: Remove useless PTRACE_SETREGSET implementation Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] sparc/ptrace: Preserve previous registers for short regset write Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] metag/ptrace: " Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] metag/ptrace: Reject partial NT_METAG_RPIPE writes Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] sched/rt: Add a missing rescheduling point Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] libceph: force GFP_NOIO for socket allocations Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] scsi: mpt3sas: fix hang on ata passthrough commands Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] scsi: libsas: fix ata xfer length Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] ALSA: seq: Fix race during FIFO resize Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] ACPI: Fix incompatibility with mcount-based function graph tracing Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] tty/serial: atmel: fix race condition (TX+DMA) Jiri Slaby
2017-04-10 13:47   ` Richard Genoud [this message]
2017-04-10 15:30     ` Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] USB: fix linked-list corruption in rh_call_control() Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] KVM: x86: clear bus pointer when destroyed Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd() Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] MIPS: Lantiq: Fix cascaded IRQ setup Jiri Slaby
2017-04-10 13:07   ` Amit Pundir
2017-04-10 13:09     ` Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: fix reading out alarm Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: make sure all members in the output are set Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: implement reset routine as suggested by the reference Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: improve irq handling Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] KVM: kvm_io_bus_unregister_dev() should never fail Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] padata: avoid race in reordering Jiri Slaby

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=31c49511-39de-1a15-f0e8-ce65c6fd8725@gmail.com \
    --to=richard.genoud@gmail.com \
    --cc=jslaby@suse.cz \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.