From: Kees Cook <keescook@chromium.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Jeff Dike <jdike@addtoit.com>,
Richard Weinberger <richard@nod.at>,
anton.ivanov@cambridgegreys.com,
Mike Rapoport <rppt@linux.vnet.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
YueHaibing <yuehaibing@huawei.com>,
linux-um@lists.infradead.org, LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/2] um: vector: Fix a potential NULL pointer dereference in 'vector_net_open()'
Date: Tue, 8 Jan 2019 15:58:40 -0800 [thread overview]
Message-ID: <CAGXu5jKhBmBX90aXi3J57cVAZ2aSrRggzwNpvfnxYufZLoYCeA@mail.gmail.com> (raw)
In-Reply-To: <20181226075436.11018-1-christophe.jaillet@wanadoo.fr>
On Fri, Dec 28, 2018 at 1:57 AM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> 'create_queue()' returns NULL in case of memory allocation failure. So we
> must check if it succeeds in order to avoid potential NULL pointer
> dereference.
>
> For 'vp->rx_queue', the dereference would occur just one line after the
> failed allocation. For 'vp->tx_queue', it would occur later during normal
> processing.
>
> Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> arch/um/drivers/vector_kern.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 046fa9ea0ccc..5b917716289d 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -1182,6 +1182,8 @@ static int vector_net_open(struct net_device *dev)
> vp->rx_header_size,
> MAX_IOV_SIZE
> );
> + if (!vp->rx_queue)
> + goto out_close;
> vp->rx_queue->queue_depth = get_depth(vp->parsed);
> } else {
> vp->header_rxbuffer = kmalloc(
> @@ -1198,6 +1200,8 @@ static int vector_net_open(struct net_device *dev)
> vp->header_size,
> MAX_IOV_SIZE
> );
> + if (!vp->tx_queue)
> + goto out_close;
> } else {
> vp->header_txbuffer = kmalloc(vp->header_size, GFP_KERNEL);
> if (vp->header_txbuffer == NULL)
> --
> 2.19.1
>
--
Kees Cook
prev parent reply other threads:[~2019-01-08 23:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 7:54 [PATCH 1/2] um: vector: Fix a potential NULL pointer dereference in 'vector_net_open()' Christophe JAILLET
2019-01-08 23:58 ` Kees Cook [this message]
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=CAGXu5jKhBmBX90aXi3J57cVAZ2aSrRggzwNpvfnxYufZLoYCeA@mail.gmail.com \
--to=keescook@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=anton.ivanov@cambridgegreys.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=jdike@addtoit.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=richard@nod.at \
--cc=rppt@linux.vnet.ibm.com \
--cc=yuehaibing@huawei.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;
as well as URLs for NNTP newsgroup(s).