* [PATCH] tty: rocket: Fix possible buffer overwrite on register_PCI
@ 2018-07-27 13:39 Anton Vasilyev
2018-08-02 14:02 ` Alan Cox
0 siblings, 1 reply; 4+ messages in thread
From: Anton Vasilyev @ 2018-07-27 13:39 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Anton Vasilyev, Jiri Slaby, linux-kernel, ldv-project
If number of isa and pci boards exceed NUM_BOARDS on the path
rp_init()->init_PCI()->register_PCI() then buffer overwrite occurs
in register_PCI() on assign rcktpt_io_addr[i].
The patch adds check on upper bound for index of registered
board in register_PCI.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
---
drivers/tty/rocket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
index bdd17d2aaafd..b121d8f8f3d7 100644
--- a/drivers/tty/rocket.c
+++ b/drivers/tty/rocket.c
@@ -1881,7 +1881,7 @@ static __init int register_PCI(int i, struct pci_dev *dev)
ByteIO_t UPCIRingInd = 0;
if (!dev || !pci_match_id(rocket_pci_ids, dev) ||
- pci_enable_device(dev))
+ pci_enable_device(dev) || i >= NUM_BOARDS)
return 0;
rcktpt_io_addr[i] = pci_resource_start(dev, 0);
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: rocket: Fix possible buffer overwrite on register_PCI
2018-07-27 13:39 [PATCH] tty: rocket: Fix possible buffer overwrite on register_PCI Anton Vasilyev
@ 2018-08-02 14:02 ` Alan Cox
2018-08-06 14:10 ` [PATCH v2] " Anton Vasilyev
0 siblings, 1 reply; 4+ messages in thread
From: Alan Cox @ 2018-08-02 14:02 UTC (permalink / raw)
To: Anton Vasilyev; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, ldv-project
On Fri, 27 Jul 2018 16:39:31 +0300
Anton Vasilyev <vasilyev@ispras.ru> wrote:
> If number of isa and pci boards exceed NUM_BOARDS on the path
> rp_init()->init_PCI()->register_PCI() then buffer overwrite occurs
> in register_PCI() on assign rcktpt_io_addr[i].
>
> The patch adds check on upper bound for index of registered
> board in register_PCI.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
> ---
> drivers/tty/rocket.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
> index bdd17d2aaafd..b121d8f8f3d7 100644
> --- a/drivers/tty/rocket.c
> +++ b/drivers/tty/rocket.c
> @@ -1881,7 +1881,7 @@ static __init int register_PCI(int i, struct pci_dev *dev)
> ByteIO_t UPCIRingInd = 0;
>
> if (!dev || !pci_match_id(rocket_pci_ids, dev) ||
> - pci_enable_device(dev))
> + pci_enable_device(dev) || i >= NUM_BOARDS)
> return 0;
>
> rcktpt_io_addr[i] = pci_resource_start(dev, 0);
This is a real fix but you want to check i >= NUM_BOARDS before you
enable the device
Alan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] tty: rocket: Fix possible buffer overwrite on register_PCI
2018-08-02 14:02 ` Alan Cox
@ 2018-08-06 14:10 ` Anton Vasilyev
2018-09-18 13:37 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Anton Vasilyev @ 2018-08-06 14:10 UTC (permalink / raw)
To: Alan Cox
Cc: Anton Vasilyev, Greg Kroah-Hartman, Jiri Slaby, linux-kernel,
ldv-project
If number of isa and pci boards exceed NUM_BOARDS on the path
rp_init()->init_PCI()->register_PCI() then buffer overwrite occurs
in register_PCI() on assign rcktpt_io_addr[i].
The patch adds check on upper bound for index of registered
board in register_PCI.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
---
v2: do not enable device which will not be managed by driver.
Based on Alan's comment.
NOTE: I can't find if there is a call of pci_disable_device(),
corresponding to pci_enable_device() from register_PCI().
---
drivers/tty/rocket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
index bdd17d2aaafd..f2238dc40426 100644
--- a/drivers/tty/rocket.c
+++ b/drivers/tty/rocket.c
@@ -1881,7 +1881,7 @@ static __init int register_PCI(int i, struct pci_dev *dev)
ByteIO_t UPCIRingInd = 0;
if (!dev || !pci_match_id(rocket_pci_ids, dev) ||
- pci_enable_device(dev))
+ i >= NUM_BOARDS || pci_enable_device(dev))
return 0;
rcktpt_io_addr[i] = pci_resource_start(dev, 0);
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tty: rocket: Fix possible buffer overwrite on register_PCI
2018-08-06 14:10 ` [PATCH v2] " Anton Vasilyev
@ 2018-09-18 13:37 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2018-09-18 13:37 UTC (permalink / raw)
To: Anton Vasilyev; +Cc: Alan Cox, Jiri Slaby, linux-kernel, ldv-project
On Mon, Aug 06, 2018 at 05:10:57PM +0300, Anton Vasilyev wrote:
> If number of isa and pci boards exceed NUM_BOARDS on the path
> rp_init()->init_PCI()->register_PCI() then buffer overwrite occurs
> in register_PCI() on assign rcktpt_io_addr[i].
>
> The patch adds check on upper bound for index of registered
> board in register_PCI.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
> ---
> v2: do not enable device which will not be managed by driver.
> Based on Alan's comment.
This patch doesn't apply to my tree at all :(
Can you rebase and resend?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-18 13:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27 13:39 [PATCH] tty: rocket: Fix possible buffer overwrite on register_PCI Anton Vasilyev
2018-08-02 14:02 ` Alan Cox
2018-08-06 14:10 ` [PATCH v2] " Anton Vasilyev
2018-09-18 13:37 ` 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).