diff options
author | Justus Winter <justus@gnupg.org> | 2016-10-08 18:41:02 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2016-10-09 21:59:13 +0200 |
commit | 93ba74df1d6523ac49d5b227e30e1cfca930f7a9 (patch) | |
tree | a9465d4f937731cf42720598fa08aa86c1d038ff /ext2fs | |
parent | 83cb5faab30be175c757b31ea4acca7f640228ae (diff) |
ext2fs: Poison pointers into dereferenced cache pages.
* ext2fs/ext2fs.h (disk_cache_block_deref): Replace with a macro that
NULLs the given pointer.
(dino_deref): Likewise.
* ext2fs/pager.c (disk_cache_block_deref): Rename.
* ext2fs/pokel.c (pokel_add): Adapt.
(pokel_exec): Likewise.
Diffstat (limited to 'ext2fs')
-rw-r--r-- | ext2fs/ext2fs.h | 8 | ||||
-rw-r--r-- | ext2fs/pager.c | 2 | ||||
-rw-r--r-- | ext2fs/pokel.c | 6 |
3 files changed, 10 insertions, 6 deletions
diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h index c233ce06..afcd25c8 100644 --- a/ext2fs/ext2fs.h +++ b/ext2fs/ext2fs.h @@ -271,7 +271,9 @@ extern pthread_cond_t disk_cache_reassociation; void *disk_cache_block_ref (block_t block); void disk_cache_block_ref_ptr (void *ptr); -void disk_cache_block_deref (void *ptr); +void _disk_cache_block_deref (void *ptr); +#define disk_cache_block_deref(PTR) \ + do { _disk_cache_block_deref (PTR); PTR = NULL; } while (0) int disk_cache_block_is_ref (block_t block); /* Our in-core copy of the super-block (pointer into the disk_cache). */ @@ -412,12 +414,14 @@ dino_ref (ino_t inum) } EXT2FS_EI void -dino_deref (struct ext2_inode *inode) +_dino_deref (struct ext2_inode *inode) { ext2_debug ("(%p)", inode); disk_cache_block_deref (inode); } #endif /* Use extern inlines. */ +#define dino_deref(INODE) \ + do { _dino_deref (INODE); INODE = NULL; } while (0) /* ---------------------------------------------------------------- */ /* inode.c */ diff --git a/ext2fs/pager.c b/ext2fs/pager.c index 456b582c..6a926827 100644 --- a/ext2fs/pager.c +++ b/ext2fs/pager.c @@ -1197,7 +1197,7 @@ disk_cache_block_ref_ptr (void *ptr) } void -disk_cache_block_deref (void *ptr) +_disk_cache_block_deref (void *ptr) { int index; diff --git a/ext2fs/pokel.c b/ext2fs/pokel.c index 3afb32e4..53dc513a 100644 --- a/ext2fs/pokel.c +++ b/ext2fs/pokel.c @@ -71,7 +71,7 @@ pokel_add (struct pokel *pokel, void *loc, vm_size_t length) { if (pokel->image == disk_cache) for (vm_offset_t i = offset; i < end; i += block_size) - disk_cache_block_deref (disk_cache + i); + _disk_cache_block_deref (disk_cache + i); break; } @@ -85,7 +85,7 @@ pokel_add (struct pokel *pokel, void *loc, vm_size_t length) vm_offset_t i_begin = p_offs > offset ? p_offs : offset; vm_offset_t i_end = p_end < end ? p_end : end; for (vm_offset_t i = i_begin; i < i_end; i += block_size) - disk_cache_block_deref (disk_cache + i); + _disk_cache_block_deref (disk_cache + i); } ext2_debug ("extended 0x%x[%ul] to 0x%x[%ul]", @@ -140,7 +140,7 @@ _pokel_exec (struct pokel *pokel, int sync, int wait) vm_offset_t begin = trunc_block (pl->offset); vm_offset_t end = round_block (pl->offset + pl->length); for (vm_offset_t i = begin; i != end; i += block_size) - disk_cache_block_deref (pokel->image + i); + _disk_cache_block_deref (pokel->image + i); } } |