]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: avoid infinite loop in child fs iteration
authorDave Reisner <d@falconindy.com>
Sun, 4 Mar 2012 21:08:39 +0000 (16:08 -0500)
committerKarel Zak <kzak@redhat.com>
Thu, 8 Mar 2012 15:06:02 +0000 (16:06 +0100)
commitbf91904c24c470a750a7efa8ceaed3f9e9996b6c
tree13a36683bc1dcfcafd8b520ccd8c69c127603d8f
parent7c9c872c2bd43ba44107e63919f57db0b8be7edc
libmount: avoid infinite loop in child fs iteration

In early userspace, the rootfs is mounted with itself as its parent.
Example /proc/self/mountinfo:

1 1 0:1 / / rw - rootfs rootfs rw
14 1 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
15 1 0:13 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sys rw
16 1 0:5 / /dev rw,nosuid,relatime - devtmpfs dev rw,size=506956k
17 1 0:14 / /run rw,nosuid,nodev,relatime - tmpfs run rw,mode=755

This causes an infinite loop in mnt_table_next_child_fs, and is
evidenced by a crash via infinite recursion in findmnt. Simply catch the
condition where the ID of the parent is the ID of the current fs we're
examining and skip over it to the next mount in the table.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
libmount/src/tab.c