mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
mm: fix NULL deref on vnode inactive
An oversight on vnode inactivation when the last reference was a dirty page causes a NULL-deref due to VOP_RELEASE set-NULL behavior. Use a temporary variable in this case as the backing can still be accesed by a truncation on vnode inactive.
This commit is contained in:
@@ -315,6 +315,7 @@ static int sync_page(page_t *page, bool backing_lock) {
|
||||
page->flags &= ~PAGE_FLAGS_DIRTY;
|
||||
RELEASE_LOCK();
|
||||
int e = 0;
|
||||
vnode_t *backing = page->backing;
|
||||
if ((page->flags & PAGE_FLAGS_TRUNCATED) == 0) {
|
||||
if (backing_lock)
|
||||
VOP_LOCK(page->backing);
|
||||
@@ -323,11 +324,11 @@ static int sync_page(page_t *page, bool backing_lock) {
|
||||
|
||||
if (backing_lock)
|
||||
VOP_UNLOCK(page->backing);
|
||||
VOP_RELEASE(page->backing);
|
||||
VOP_RELEASE(backing);
|
||||
} else {
|
||||
// page got truncated from the file while waiting to be written to disk
|
||||
// its still holding a reference to the vnode, so release that
|
||||
VOP_RELEASE(page->backing);
|
||||
VOP_RELEASE(backing);
|
||||
}
|
||||
|
||||
mm_release_page(mm_get_page_address((page_t *)page));
|
||||
|
||||
Reference in New Issue
Block a user