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: <CAPM=9ty_PfiQ9Cd5CRNnQbZ7Ea-69qCUR7JM=BA-n_egDnOE5g@mail.gmail.com>
Date:	Thu, 6 Dec 2012 22:46:29 +0000
From:	Dave Airlie <airlied@...il.com>
To:	Tim Gardner <tim.gardner@...onical.com>
Cc:	linux-kernel@...r.kernel.org,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	dri-devel@...ts.freedesktop.org,
	David Howells <dhowells@...hat.com>,
	Dave Airlie <airlied@...hat.com>
Subject: Re: [PATCH 3.7-rc8] ttm: Fix possible _manager memory allocation oops

On Thu, Dec 6, 2012 at 4:20 PM, Tim Gardner <tim.gardner@...onical.com> wrote:
> Memory for _manager is allocated using kzalloc() but the result is not checked.
>
> Free _manager on error lest memory become orphaned.
>
> I was led to scrutinize ttm_page_alloc_init() from a smatch warning:
>
> drivers/gpu/drm/ttm/ttm_page_alloc.c:799 ttm_page_alloc_init() error: potential null dereference '_manager'.  (kzalloc returns null)
>
> Cc: David Airlie <airlied@...ux.ie>
> Cc: Dave Airlie <airlied@...hat.com>
> Cc: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
> Cc: Zhao Yakui <yakui.zhao@...el.com>
> Cc: David Howells <dhowells@...hat.com>
> Cc: dri-devel@...ts.freedesktop.org
> Cc: stable@...r.kernel.org # 3.5+
> Signed-off-by: Tim Gardner <tim.gardner@...onical.com>
> ---
>
> This patch applies to stable 3.5 and newer.
>
>  drivers/gpu/drm/ttm/ttm_page_alloc.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> index bd2a3b4..2c73d0a 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> @@ -798,6 +798,10 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
>         pr_info("Initializing pool allocator\n");
>
>         _manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
> +       if (!_manager) {
> +               pr_err("ttm: Could not allocate _manager.\n");
> +               return -ENOMEM;
> +       }

This is fine,
>
>         ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc");
>
> @@ -817,6 +821,7 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
>                                    &glob->kobj, "pool");
>         if (unlikely(ret != 0)) {
>                 kobject_put(&_manager->kobj);
> +               kfree(_manager);
>                 _manager = NULL;

I don;t think this is, since the kobject_put shuold free it.

Dave.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ