]>
Commit | Line | Data |
---|---|---|
bf9ffb20 GKH |
1 | From ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e Mon Sep 17 00:00:00 2001 |
2 | From: "Eric W. Biederman" <ebiederm@xmission.com> | |
3 | Date: Mon, 28 Jul 2014 17:36:04 -0700 | |
4 | Subject: mnt: Change the default remount atime from relatime to the existing value | |
5 | ||
6 | From: "Eric W. Biederman" <ebiederm@xmission.com> | |
7 | ||
8 | commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e upstream. | |
9 | ||
10 | Since March 2009 the kernel has treated the state that if no | |
11 | MS_..ATIME flags are passed then the kernel defaults to relatime. | |
12 | ||
13 | Defaulting to relatime instead of the existing atime state during a | |
14 | remount is silly, and causes problems in practice for people who don't | |
15 | specify any MS_...ATIME flags and to get the default filesystem atime | |
16 | setting. Those users may encounter a permission error because the | |
17 | default atime setting does not work. | |
18 | ||
19 | A default that does not work and causes permission problems is | |
20 | ridiculous, so preserve the existing value to have a default | |
21 | atime setting that is always guaranteed to work. | |
22 | ||
23 | Using the default atime setting in this way is particularly | |
24 | interesting for applications built to run in restricted userspace | |
25 | environments without /proc mounted, as the existing atime mount | |
26 | options of a filesystem can not be read from /proc/mounts. | |
27 | ||
28 | In practice this fixes user space that uses the default atime | |
29 | setting on remount that are broken by the permission checks | |
30 | keeping less privileged users from changing more privileged users | |
31 | atime settings. | |
32 | ||
33 | Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> | |
34 | Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> | |
35 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
36 | ||
37 | --- | |
38 | fs/namespace.c | 8 ++++++++ | |
39 | 1 file changed, 8 insertions(+) | |
40 | ||
41 | --- a/fs/namespace.c | |
42 | +++ b/fs/namespace.c | |
43 | @@ -2473,6 +2473,14 @@ long do_mount(const char *dev_name, cons | |
44 | if (flags & MS_RDONLY) | |
45 | mnt_flags |= MNT_READONLY; | |
46 | ||
47 | + /* The default atime for remount is preservation */ | |
48 | + if ((flags & MS_REMOUNT) && | |
49 | + ((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME | | |
50 | + MS_STRICTATIME)) == 0)) { | |
51 | + mnt_flags &= ~MNT_ATIME_MASK; | |
52 | + mnt_flags |= path.mnt->mnt_flags & MNT_ATIME_MASK; | |
53 | + } | |
54 | + | |
55 | flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN | | |
56 | MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT | | |
57 | MS_STRICTATIME); |