lkml.org 
[lkml]   [2019]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] tpm: fix a race between poll and write in tpm-dev-common
From
Date
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 || priv->response_length)
>> mask = EPOLLIN | EPOLLRDNORM;
>> else
>> mask = EPOLLOUT | EPOLLWRNORM;
>>
>> + mutex_unlock(&priv->buffer_mutex);
> This doesn't do anything to address the theory that the queued work
> hasn't run before the poll wakes up, does it? If you have an
> alternative theory, could you explain it?

Right, it needs to be guarded by the mutex and also the condition
should only check priv->response_length, because we only care
about if there is data to read. The response_read flag only
prevents double writes, without reading in the middle (or a timeout)
which clean it. I will send a v2 soon.

Thanks,
--
Tadeusz

\
 
 \ /
  Last update: 2019-03-19 20:10    [W:0.797 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site