]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.16.3/mnt-change-the-default-remount-atime-from-relatime-to-the-existing-value.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / mnt-change-the-default-remount-atime-from-relatime-to-the-existing-value.patch
CommitLineData
bf9ffb20
GKH
1From ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e Mon Sep 17 00:00:00 2001
2From: "Eric W. Biederman" <ebiederm@xmission.com>
3Date: Mon, 28 Jul 2014 17:36:04 -0700
4Subject: mnt: Change the default remount atime from relatime to the existing value
5
6From: "Eric W. Biederman" <ebiederm@xmission.com>
7
8commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e upstream.
9
10Since March 2009 the kernel has treated the state that if no
11MS_..ATIME flags are passed then the kernel defaults to relatime.
12
13Defaulting to relatime instead of the existing atime state during a
14remount is silly, and causes problems in practice for people who don't
15specify any MS_...ATIME flags and to get the default filesystem atime
16setting. Those users may encounter a permission error because the
17default atime setting does not work.
18
19A default that does not work and causes permission problems is
20ridiculous, so preserve the existing value to have a default
21atime setting that is always guaranteed to work.
22
23Using the default atime setting in this way is particularly
24interesting for applications built to run in restricted userspace
25environments without /proc mounted, as the existing atime mount
26options of a filesystem can not be read from /proc/mounts.
27
28In practice this fixes user space that uses the default atime
29setting on remount that are broken by the permission checks
30keeping less privileged users from changing more privileged users
31atime settings.
32
33Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
34Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
35Signed-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);