[lkml]   [2015]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [tpmdd-devel] [RFC PATCH 1/2] tee: generic TEE subsystem
On Fri, Apr 17, 2015 at 09:50:56AM +0200, Jens Wiklander wrote:
> + teedev = devm_kzalloc(dev, sizeof(*teedev), GFP_KERNEL);
> + rc = misc_register(&teedev->miscdev);
> +void tee_unregister(struct tee_device *teedev)
> +{
> + misc_deregister(&teedev->miscdev);
> +}
>+static int optee_remove(struct platform_device *pdev)
>+ tee_unregister(optee->teedev);

Isn't that a potential use after free? AFAIK misc_deregister does not
guarentee the miscdev will no longer be accessed after it returns, and
the devm will free it after optee_remove returns.

Memory backing a stuct device needs to be freed via the release

We have been going through this for a while with TPM - it seems like
using misc devices dynamically is not a good idea. Manage your own
struct device directly..


 \ /
  Last update: 2015-04-17 19:01    [W:0.162 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site