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  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]
Date:	Tue, 01 Jan 2013 13:37:24 +1100
From:	Nigel Cunningham <nigel@...elcunningham.com.au>
To:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] Re: New Defect(s) reported by Coverity Scan

 From b41864867464bfe0e2d114528bc9b39e2d9f546e Mon Sep 17 00:00:00 2001
From: Nigel Cunningham <nigel@...elcunningham.com.au>
Date: Tue, 1 Jan 2013 13:03:50 +1100
Subject: [PATCH] Fix rbd use after free.

This patch addresses Coverity #753114.

The use of ceph_opts in rbd_add is currently confusing - there
are three possible outcomes of the call to rbd_get_client:

1) An existing, matching and usable rdb client is found and returned by
    rbd_client_find. ceph_opts is freed by rbd_get_client and should not
    be freed by rbd_add. This the code path triggering the Coverity
    warning.
2) An existing, matching and usable rdb client is NOT found and returned
    by rbd_client_find. rbd_client_create successfully executes, passing
    responsibility for ceph_opts to the newly created client. It should
    not be freed by rbd_add.
3) An existing, matching and usable rdb client is NOT found and returned
    by rbd_client_find. rbd_client_create fails to create a new client,
    freeing ceph_opts in its error path. It should not be freed by rbd_add.

So then, regardless of the outcome of rbd_get_client, if it is called, we
should not attempt to free ceph_opts. The solution is then simple: there
is no need to seek to free ceph_opts in rbd_add (or do anything with it)
because rbd_get_client is called immediately after the structure is
allocated by rbd_add_parse_args.

Signed-off-by: Nigel Cunningham <nigel@...elcunningham.com.au>
---
  drivers/block/rbd.c |    3 ---
  1 file changed, 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 89576a0..dfb7ef8 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3629,7 +3629,6 @@ static ssize_t rbd_add(struct bus_type *bus,
          rc = PTR_ERR(rbdc);
          goto err_out_args;
      }
-    ceph_opts = NULL;    /* rbd_dev client now owns this */

      /* pick the pool */
      osdc = &rbdc->client->osdc;
@@ -3658,8 +3657,6 @@ err_out_rbd_dev:
  err_out_client:
      rbd_put_client(rbdc);
  err_out_args:
-    if (ceph_opts)
-        ceph_destroy_options(ceph_opts);
      kfree(rbd_opts);
      rbd_spec_put(spec);
  err_out_module:
-- 
1.7.10.4

--
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