* [PATCH] libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()
@ 2019-08-19 8:30 Kevin Hao
2019-08-19 12:59 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Hao @ 2019-08-19 8:30 UTC (permalink / raw)
To: util-linux
The "umount -f -a -r" get stuck in a endless loop when run with a
mountinfo like below:
15 0 179:2 / / ro,relatime - ext4 /dev/root ro
16 15 0:6 / /dev rw,relatime - devtmpfs devtmpfs rw,size=242896k,nr_inodes=60724,mode=755
17 15 0:4 / /proc rw,relatime - proc proc rw
18 15 0:15 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k
19 15 0:16 / /sys rw,relatime - sysfs sysfs rw
20 19 0:7 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
21 15 0:17 / /run rw,nosuid,nodev - tmpfs tmpfs rw,mode=755
22 15 0:18 / /var/volatile rw,relatime - tmpfs tmpfs rw
23 15 179:1 / /boot rw,relatime - vfat /dev/mmcblk0p1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
24 16 0:19 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
25 18 0:20 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k
The reason is that the two same mnt entry "/mnt/.psplash" will cause
the dst->tab set to NULL when umount this mnt entry the second time.
This will trigger an endless loop in mnt_reset_table() because that
mnt entry is linked on the libmnt_table but its .tab is set to NULL.
Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
---
libmount/src/fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libmount/src/fs.c b/libmount/src/fs.c
index eb89bb8a39be..4126ee9dce85 100644
--- a/libmount/src/fs.c
+++ b/libmount/src/fs.c
@@ -188,9 +188,10 @@ struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest,
dest = mnt_new_fs();
if (!dest)
return NULL;
+
+ dest->tab = NULL;
}
- dest->tab = NULL;
dest->id = src->id;
dest->parent = src->parent;
dest->devno = src->devno;
--
2.14.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()
2019-08-19 8:30 [PATCH] libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs() Kevin Hao
@ 2019-08-19 12:59 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2019-08-19 12:59 UTC (permalink / raw)
To: Kevin Hao; +Cc: util-linux
On Mon, Aug 19, 2019 at 04:30:22PM +0800, Kevin Hao wrote:
> The "umount -f -a -r" get stuck in a endless loop when run with a
> mountinfo like below:
> 15 0 179:2 / / ro,relatime - ext4 /dev/root ro
> 16 15 0:6 / /dev rw,relatime - devtmpfs devtmpfs rw,size=242896k,nr_inodes=60724,mode=755
> 17 15 0:4 / /proc rw,relatime - proc proc rw
> 18 15 0:15 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k
> 19 15 0:16 / /sys rw,relatime - sysfs sysfs rw
> 20 19 0:7 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
> 21 15 0:17 / /run rw,nosuid,nodev - tmpfs tmpfs rw,mode=755
> 22 15 0:18 / /var/volatile rw,relatime - tmpfs tmpfs rw
> 23 15 179:1 / /boot rw,relatime - vfat /dev/mmcblk0p1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
> 24 16 0:19 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
> 25 18 0:20 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k
>
> The reason is that the two same mnt entry "/mnt/.psplash" will cause
> the dst->tab set to NULL when umount this mnt entry the second time.
> This will trigger an endless loop in mnt_reset_table() because that
> mnt entry is linked on the libmnt_table but its .tab is set to NULL.
Good catch! Applied.
The cxt->fs usually does not point to any table, but it's context
specific setting. Unfortunately, umount --all is different, rather
than copy always a new setting from mount table (mtab) it point to the
file. This optimization works thanks to reference counting, but now we
also check for fs->tab and it makes things more tricky.
Thanks!
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-19 12:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 8:30 [PATCH] libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs() Kevin Hao
2019-08-19 12:59 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).