Re: [PATCH] tpm: fix a race between poll and write in tpm-dev-common

2019-03-21 Thread Jarkko Sakkinen
On Mon, Mar 18, 2019 at 03:18:16PM -0700, Tadeusz Struk wrote: > Since the poll returns EPOLLIN base on the state of two > variables, the response_read being false and the > response_length > 0 the poll needs to take the buffer_mutex > after it is woken up. > > Fixes: 9488585b21bef0df12 ("tpm: add

Re: [PATCH] tpm: fix a race between poll and write in tpm-dev-common

2019-03-21 Thread Jarkko Sakkinen
On Mon, Mar 18, 2019 at 04:19:27PM -0700, James Bottomley wrote: > On Mon, 2019-03-18 at 15:18 -0700, Tadeusz Struk wrote: > > Since the poll returns EPOLLIN base on the state of two > > variables, the response_read being false and the > > response_length > 0 the poll needs to take the buffer_mutex

Re: [PATCH] tpm: fix a race between poll and write in tpm-dev-common

2019-03-19 Thread Tadeusz Struk
On 3/18/19 4:19 PM, James Bottomley wrote: >> @@ -203,12 +203,14 @@ __poll_t tpm_common_poll(struct file *file, >> poll_table *wait) >> __poll_t mask = 0; >> >> poll_wait(file, &priv->async_wait, wait); >> +mutex_lock(&priv->buffer_mutex); >> >> if (!priv->response_read || pr

Re: [PATCH] tpm: fix a race between poll and write in tpm-dev-common

2019-03-18 Thread James Bottomley
On Mon, 2019-03-18 at 15:18 -0700, Tadeusz Struk wrote: > Since the poll returns EPOLLIN base on the state of two > variables, the response_read being false and the > response_length > 0 the poll needs to take the buffer_mutex > after it is woken up. > > Fixes: 9488585b21bef0df12 ("tpm: add suppor

[PATCH] tpm: fix a race between poll and write in tpm-dev-common

2019-03-18 Thread Tadeusz Struk
Since the poll returns EPOLLIN base on the state of two variables, the response_read being false and the response_length > 0 the poll needs to take the buffer_mutex after it is woken up. Fixes: 9488585b21bef0df12 ("tpm: add support for partial reads") Reported-by: Mantas Mikulėnas Signed-off-by: