lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191008194425.GA28067@ziepe.ca>
Date:   Tue, 8 Oct 2019 16:44:25 -0300
From:   Jason Gunthorpe <jgg@...pe.ca>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     Doug Ledford <dledford@...hat.com>,
        Potnuri Bharat Teja <bharat@...lsio.com>,
        Matan Barak <matanb@...lanox.com>,
        Leon Romanovsky <leon@...nel.org>,
        Shamir Rabinovitch <shamir.rabinovitch@...cle.com>,
        Matthew Wilcox <willy@...radead.org>,
        Michael Guralnik <michaelgur@...lanox.com>,
        linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] uverbs: prevent potential underflow

On Sat, Oct 05, 2019 at 08:23:37AM +0300, Dan Carpenter wrote:
> The issue is in drivers/infiniband/core/uverbs_std_types_cq.c in the
> UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE) function.  We check that:
> 
> 	if (attr.comp_vector >= attrs->ufile->device->num_comp_vectors) {
> 
> But we don't check that "attr.comp_vector" whether negative.  It
> could potentially lead to an array underflow.  My concern would be where
> cq->vector is used in the create_cq() function from the cxgb4 driver.
> 
> Fixes: 9ee79fce3642 ("IB/core: Add completion queue (cq) object actions")
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
> ---
>  drivers/infiniband/core/uverbs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

 
> diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
> index 1e5aeb39f774..63f7f7db5902 100644
> --- a/drivers/infiniband/core/uverbs.h
> +++ b/drivers/infiniband/core/uverbs.h
> @@ -98,7 +98,7 @@ ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata,
>  
>  struct ib_uverbs_device {
>  	atomic_t				refcount;
> -	int					num_comp_vectors;
> +	u32					num_comp_vectors;
>  	struct completion			comp;
>  	struct device				dev;
>  	/* First group for device attributes, NULL terminated array */

I would have expected you to change struct ib_cq_init_attr ? Or at
least both..

This is actually a bug as the type of
UVERBS_ATTR_CREATE_CQ_COMP_VECTOR for userspace is u32:

        UVERBS_ATTR_PTR_IN(UVERBS_ATTR_CREATE_CQ_COMP_VECTOR,
                           UVERBS_ATTR_TYPE(u32),
                           UA_MANDATORY),

But we are stuffing it into a int:

        ret = uverbs_copy_from(&attr.comp_vector, attrs,
                               UVERBS_ATTR_CREATE_CQ_COMP_VECTOR);

So very large values will become negative and switching
num_comp_vectors to u32 won't help??

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ