Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1636991
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.9 6/9] 8250_pci: Fix potential use-after-free in error path |
| Date | 2017-05-06 22:50 +0200 |
| Message-ID | <tEeOm-4n6-31@gated-at.bofh.it> (permalink) |
| References | <tEeOl-4n6-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
commit c130b666a9a711f985a0a44b58699ebe14bb7245 upstream.
Commit f209fa03fc9d ("serial: 8250_pci: Detach low-level driver during
PCI error recovery") introduces a potential use-after-free in case the
pciserial_init_ports call in serial8250_io_resume fails, which may
happen if a memory allocation fails or if the .init quirk failed for
whatever reason). If this happen, further pci_get_drvdata will return a
pointer to freed memory.
This patch reworks the PCI recovery resume hook to restore the old priv
structure in this case, which should be ok, since the ports were already
detached. Such error during recovery causes us to give up on the
recovery.
Fixes: f209fa03fc9d ("serial: 8250_pci: Detach low-level driver during PCI error recovery")
Reported-by: Michal Suchanek <msuchanek@suse.com>
Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/tty/serial/8250/8250_pci.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -5621,17 +5621,15 @@ static pci_ers_result_t serial8250_io_sl
static void serial8250_io_resume(struct pci_dev *dev)
{
struct serial_private *priv = pci_get_drvdata(dev);
- const struct pciserial_board *board;
+ struct serial_private *new;
if (!priv)
return;
- board = priv->board;
- kfree(priv);
- priv = pciserial_init_ports(dev, board);
-
- if (!IS_ERR(priv)) {
- pci_set_drvdata(dev, priv);
+ new = pciserial_init_ports(dev, priv->board);
+ if (!IS_ERR(new)) {
+ pci_set_drvdata(dev, new);
+ kfree(priv);
}
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.9 0/9] 4.9.27-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-06 22:50 +0200 [PATCH 4.9 6/9] 8250_pci: Fix potential use-after-free in error path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-06 22:50 +0200 [PATCH 4.9 8/9] cpu/hotplug: Serialize callback invocations proper Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-06 22:50 +0200 [PATCH 4.9 2/9] Handle mismatched open calls Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-06 22:50 +0200 Re: [PATCH 4.9 0/9] 4.9.27-stable review Guenter Roeck <linux@roeck-us.net> - 2017-05-08 00:10 +0200 Re: [PATCH 4.9 0/9] 4.9.27-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-05-08 21:20 +0200
csiph-web