← Back to team overview

kernel-packages team mailing list archive

[Bug 1479468] [NEW] OverlayFS: Wrong mnt_id and path reported in /proc

 

Public bug reported:

I am running Ubuntu Vivid (3.19.0-22-generic #22-Ubuntu SMP Tue Jun 16
17:15:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux).  There are two issues
in OverlayFS as follows:

 1. /proc/<pid>/fdinfo/<fd> reports wrong mnt_id (non-existent in
/proc/<pid>/mountinfo)

 2. /proc/<pid>/fd/<fd> shows incorrect path for the symlink target

These problems can be easily reproduced with the shell script below.
Fortunately, both problems have been fixed in the upstream's master
branch of the kernel via the following commits:

    torvalds 4.0:   155e35d4d VFS: Introduce inode-getting helpers for layered/unioned fs environments
    torvalds 4.0:   df1a085af VFS: Add a fallthrough flag for marking virtual dentries
    torvalds 4.2-rc2:   f25801ee4 overlay: Call ovl_drop_write() earlier in ovl_dentry_open()
    torvalds 4.2-rc2:   4bacc9c92 overlayfs: Make f_path always point to the overlay and f_inode to the underlay
    torvalds 4.2-rc2:   9391dd00d fix a braino in ovl_d_select_inode()

(The commit df1a085af may technically not be needed but it prevents a
conflict when applying 4bacc9c92.)

Simple script to reproduce the problem:

#!/bin/bash

set -eu

ERROR=0

setup() {
	setup_mount
	start_python > /dev/null 2>&1 &
	BASH_PID=$!
	PYTHON_PID=$(ps -C python | awk '/python/ { print $1 }')
	sleep 1
}

setup_mount() {
	mkdir overlay_test
	cd overlay_test
	mkdir a b c z
	sudo mount -t overlay -o lowerdir=a,upperdir=b,workdir=c overlayfs z
}

start_python() {
	python << EOF
import time
fd = open("z/file", "w")
time.sleep(10)
EOF
}

check_path() {
	WD=$(pwd)
	if ! ls -l /proc/$PYTHON_PID/fd | grep -qw "$WD/z/file"; then
		ERROR=1
		echo "ERROR! expected $WD/z/file"
		set -x
		ls -l /proc/$PYTHON_PID/fd
		set +x
	fi
}

check_mnt_id() {
	FDINFO_MNT_ID=$(awk '/mnt_id:/ { print $2 }' /proc/$PYTHON_PID/fdinfo/3)
	MOUNTINFO_MNT_ID=$(awk '/overlayfs/ { print $1 }' /proc/self/mountinfo)
	if [[ $FDINFO_MNT_ID -ne $MOUNTINFO_MNT_ID ]]; then
		ERROR=1
		echo "ERROR! mnt_id $FDINFO_MNT_ID not in /proc/self/mountinfo"
		set -x
		cat /proc/$PYTHON_PID/fdinfo/3
		cat /proc/self/mountinfo
		set +x
	fi
}

finish() {
	kill -INT $PYTHON_PID > /dev/null 2>&1
	sudo umount z
	cd $ORIG_WD
	rm -rf overlay_test
}

main() {
	ORIG_WD=$(pwd)
	setup

	check_path
	check_mnt_id

	finish
	[[ $ERROR -eq 0 ]] && echo "OverlayFS looks good."
}

main

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: linux (Ubuntu Vivid)
     Importance: Undecided
         Status: New


** Tags: overlayfs

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1479468

Title:
  OverlayFS: Wrong mnt_id and path reported in /proc

Status in linux package in Ubuntu:
  New
Status in linux source package in Vivid:
  New

Bug description:
  I am running Ubuntu Vivid (3.19.0-22-generic #22-Ubuntu SMP Tue Jun 16
  17:15:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux).  There are two
  issues in OverlayFS as follows:

   1. /proc/<pid>/fdinfo/<fd> reports wrong mnt_id (non-existent in
  /proc/<pid>/mountinfo)

   2. /proc/<pid>/fd/<fd> shows incorrect path for the symlink target

  These problems can be easily reproduced with the shell script below.
  Fortunately, both problems have been fixed in the upstream's master
  branch of the kernel via the following commits:

      torvalds 4.0:   155e35d4d VFS: Introduce inode-getting helpers for layered/unioned fs environments
      torvalds 4.0:   df1a085af VFS: Add a fallthrough flag for marking virtual dentries
      torvalds 4.2-rc2:   f25801ee4 overlay: Call ovl_drop_write() earlier in ovl_dentry_open()
      torvalds 4.2-rc2:   4bacc9c92 overlayfs: Make f_path always point to the overlay and f_inode to the underlay
      torvalds 4.2-rc2:   9391dd00d fix a braino in ovl_d_select_inode()

  (The commit df1a085af may technically not be needed but it prevents a
  conflict when applying 4bacc9c92.)

  Simple script to reproduce the problem:

  #!/bin/bash

  set -eu

  ERROR=0

  setup() {
  	setup_mount
  	start_python > /dev/null 2>&1 &
  	BASH_PID=$!
  	PYTHON_PID=$(ps -C python | awk '/python/ { print $1 }')
  	sleep 1
  }

  setup_mount() {
  	mkdir overlay_test
  	cd overlay_test
  	mkdir a b c z
  	sudo mount -t overlay -o lowerdir=a,upperdir=b,workdir=c overlayfs z
  }

  start_python() {
  	python << EOF
  import time
  fd = open("z/file", "w")
  time.sleep(10)
  EOF
  }

  check_path() {
  	WD=$(pwd)
  	if ! ls -l /proc/$PYTHON_PID/fd | grep -qw "$WD/z/file"; then
  		ERROR=1
  		echo "ERROR! expected $WD/z/file"
  		set -x
  		ls -l /proc/$PYTHON_PID/fd
  		set +x
  	fi
  }

  check_mnt_id() {
  	FDINFO_MNT_ID=$(awk '/mnt_id:/ { print $2 }' /proc/$PYTHON_PID/fdinfo/3)
  	MOUNTINFO_MNT_ID=$(awk '/overlayfs/ { print $1 }' /proc/self/mountinfo)
  	if [[ $FDINFO_MNT_ID -ne $MOUNTINFO_MNT_ID ]]; then
  		ERROR=1
  		echo "ERROR! mnt_id $FDINFO_MNT_ID not in /proc/self/mountinfo"
  		set -x
  		cat /proc/$PYTHON_PID/fdinfo/3
  		cat /proc/self/mountinfo
  		set +x
  	fi
  }

  finish() {
  	kill -INT $PYTHON_PID > /dev/null 2>&1
  	sudo umount z
  	cd $ORIG_WD
  	rm -rf overlay_test
  }

  main() {
  	ORIG_WD=$(pwd)
  	setup

  	check_path
  	check_mnt_id

  	finish
  	[[ $ERROR -eq 0 ]] && echo "OverlayFS looks good."
  }

  main

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1479468/+subscriptions


Follow ups