Commit 25cd496
committed
mount: forbid mount on path with symlinks
It was forbidden to create mount units for a symlink. But the reason is
that the mount unit needs to know the real path that will appear in
/proc/self/mountinfo. The kernel dereferences *all* the symlinks in the
path at mount time (I checked this with `mount -c` running under `strace`).
This will have no effect on most systems. As recommended by docs, most
systems use /etc/fstab, as opposed to native mount unit files.
fstab-generator dereferences symlinks for backwards compatibility.
A relatively minor issue regarding Time Of Check / Time Of Use also exists
here. I can't see how to get rid of it entirely. If we pass an absolute
path to mount, the racing process can replace it with a symlink. If we
chdir() to the mount point and pass ".", the racing process can move the
directory. The latter might potentially be nicer, except that it breaks
WorkingDirectory=.
I'm not saying the race is relevant to security - I just want to consider
how bad the effect is. Currently, it can make the mount unit active (and
hence the job return success), despite there never being a matching entry
in /proc/self/mountinfo. This wart will be removed in the next commit;
i.e. it will make the mount unit fail instead.1 parent 22bc57c commit 25cd496
4 files changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
| 581 | + | |
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
942 | 942 | | |
943 | 943 | | |
944 | 944 | | |
945 | | - | |
| 945 | + | |
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4705 | 4705 | | |
4706 | 4706 | | |
4707 | 4707 | | |
4708 | | - | |
| 4708 | + | |
| 4709 | + | |
4709 | 4710 | | |
4710 | 4711 | | |
4711 | 4712 | | |
4712 | 4713 | | |
4713 | 4714 | | |
4714 | | - | |
| 4715 | + | |
4715 | 4716 | | |
4716 | | - | |
| 4717 | + | |
4717 | 4718 | | |
4718 | 4719 | | |
4719 | | - | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
4720 | 4723 | | |
4721 | 4724 | | |
| 4725 | + | |
4722 | 4726 | | |
4723 | 4727 | | |
4724 | 4728 | | |
4725 | 4729 | | |
4726 | | - | |
| 4730 | + | |
4727 | 4731 | | |
4728 | 4732 | | |
4729 | 4733 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
| 763 | + | |
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
| |||
0 commit comments