Fun Linux fact: On a Linux system where /tmp/ is tmpfs, if you create the follow...

@jann@infosec.exchange

Fun Linux fact:

On a Linux system where /tmp/ is tmpfs, if you create the following directories:

  • /tmp/pathwalktest
  • /tmp/pathwalktest/a
  • /tmp/pathwalktest/a/b
  • /tmp/pathwalktest/c

and call

rename("/tmp/pathwalktest/a/b", "/tmp/pathwalktest/b")

then a concurrent

open("/tmp/pathwalktest/a/b/../c", O_RDONLY)

normally won't end up opening /tmp/pathwalktest/c.

But a concurrent

open("/proc/self/root/tmp/pathwalktest/a/b/../c", O_RDONLY)

can end up doing that with a simple ABA race ordering.

(This is all working as intended, this is just a difference between rcu-walk and ref-walk; going through procfs magiclinks forces ref-walk mode.)