git: tmpfs - Fix write-append/mmap-read race

Matthew Dillon dillon at
Fri Jul 3 22:00:37 PDT 2015

commit b37a7c00afef1d167a3d2e2de799d16d733854f2
Author: Matthew Dillon <dillon at>
Date:   Fri Jul 3 21:55:10 2015 -0700

    tmpfs - Fix write-append/mmap-read race
    * tmpfs_write() was not extending the target file atomically with the
      write via a file node lock.  Although the vnode is locked exclusively,
      this only prevents read() and write() related races.  lseek() and memory
      mapped reads could still race.
    * Adjust the NODE LOCK to cover the entire tmpfs_write() operation.  This
      fixes races against lseek() or stat() which would otherwise allow the
      new post-append file size to be returned before the write completes.
    Reported-by: Ben Woolley <tautolog at>

Summary of changes:
 sys/vfs/tmpfs/tmpfs.h       |  4 ++--
 sys/vfs/tmpfs/tmpfs_subr.c  | 21 ++++++++-------------
 sys/vfs/tmpfs/tmpfs_vnops.c | 23 +++++++++++++----------
 3 files changed, 23 insertions(+), 25 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list