Re: [PATCH 1/1] fscache: Fix oops due to race with cookie_lru and use_cookie
From: David Howells <dhowells@redhat.com>
Date: 2022-11-17 13:31:48
From: David Howells <dhowells@redhat.com>
Date: 2022-11-17 13:31:48
Dave Wysochanski [off-list ref] wrote:
If a cookie expires from the LRU and the LRU_DISCARD flag is set, but the state machine has not run yet, it's possible another thread can call fscache_use_cookie and begin to use it. When the cookie_worker finally runs, it will see the LRU_DISCARD flag set, transition the cookie->state to LRU_DISCARDING, which will then withdraw the cookie. Once the cookie is withdrawn the object is removed the below oops will occur because the object associated with the cookie is now NULL. Fix the oops by clearing the LRU_DISCARD bit if another thread uses the cookie before the cookie_worker runs.
I think this is the right approach. The state machine should just fall through without doing anything, despite having been woken. David