linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
To: Anton Vasilyev <vasilyev@ispras.ru>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
Subject: Re: [PATCH] tty: rocket: Fix possible buffer overwrite on register_PCI
Date: Thu, 2 Aug 2018 15:02:01 +0100	[thread overview]
Message-ID: <20180802150201.316e3361@alans-desktop> (raw)
In-Reply-To: <20180727133931.12701-1-vasilyev@ispras.ru>

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


  reply	other threads:[~2018-08-02 14:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 13:39 [PATCH] tty: rocket: Fix possible buffer overwrite on register_PCI Anton Vasilyev
2018-08-02 14:02 ` Alan Cox [this message]
2018-08-06 14:10   ` [PATCH v2] " Anton Vasilyev
2018-09-18 13:37     ` Greg Kroah-Hartman

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=20180802150201.316e3361@alans-desktop \
    --to=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vasilyev@ispras.ru \
    /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;
as well as URLs for NNTP newsgroup(s).