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] [day] [month] [year] [list]
Date:   Thu, 16 Dec 2021 15:56:01 +0100
From:   Jens Wiklander <jens.wiklander@...aro.org>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org, op-tee@...ts.trustedfirmware.org,
        Sumit Garg <sumit.garg@...aro.org>,
        Christian König <christian.koenig@....com>,
        Rijo Thomas <Rijo-john.Thomas@....com>,
        Devaraj Rangasamy <Devaraj.Rangasamy@....com>,
        stable@...r.kernel.org, Lars Persson <larper@...s.com>,
        Patrik Lantz <Patrik.Lantz@...s.com>
Subject: Re: [PATCH v2] tee: handle lookup of shm with reference count 0

On Wed, Dec 15, 2021 at 1:52 PM Greg KH <gregkh@...uxfoundation.org> wrote:
>
> On Wed, Dec 15, 2021 at 10:25:01AM +0100, Jens Wiklander wrote:
> > Since the tee subsystem does not keep a strong reference to its idle
> > shared memory buffers, it races with other threads that try to destroy a
> > shared memory through a close of its dma-buf fd or by unmapping the
> > memory.
> >
> > In tee_shm_get_from_id() when a lookup in teedev->idr has been
> > successful, it is possible that the tee_shm is in the dma-buf teardown
> > path, but that path is blocked by the teedev mutex. Since we don't have
> > an API to tell if the tee_shm is in the dma-buf teardown path or not we
> > must find another way of detecting this condition.
> >
> > Fix this by doing the reference counting directly on the tee_shm using a
> > new refcount_t refcount field. dma-buf is replaced by using
> > anon_inode_getfd() instead, this separates the life-cycle of the
> > underlying file from the tee_shm. tee_shm_put() is updated to hold the
> > mutex when decreasing the refcount to 0 and then remove the tee_shm from
> > teedev->idr before releasing the mutex. This means that the tee_shm can
> > never be found unless it has a refcount larger than 0.
> >
> > Fixes: 967c9cca2cc5 ("tee: generic TEE subsystem")
> > Cc: stable@...r.kernel.org
> > Reviewed-by: Lars Persson <larper@...s.com>
> > Reviewed-by: Sumit Garg <sumit.garg@...aro.org>
> > Reported-by: Patrik Lantz <patrik.lantz@...s.com>
> > Signed-off-by: Jens Wiklander <jens.wiklander@...aro.org>
> > ---
> > v1->v2
> > * fix copyright years in drivers/tee/tee_shm.c
> > * update kerneldoc comment for struct tee_shm with the reference counter
>
> Reviewed-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>

I'm picking up this now.

Thanks for reviewing,
Jens

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ