lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  4 Nov 2016 09:14:06 -0400
From:   Christopher Covington <cov@...eaurora.org>
To:     linux-mm@...r.kernel.org, Jonathan Corbet <corbet@....net>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Michal Hocko <mhocko@...e.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Hugh Dickins <hughd@...gle.com>,
        Konstantin Khlebnikov <koct9i@...il.com>,
        Naoya Horiguchi <n-horiguchi@...jp.nec.com>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Robert Foss <robert.foss@...labora.com>,
        John Stultz <john.stultz@...aro.org>,
        Robert Ho <robert.hu@...el.com>,
        Ross Zwisler <ross.zwisler@...ux.intel.com>,
        Jerome Marchand <jmarchan@...hat.com>,
        Andy Lutomirski <luto@...nel.org>,
        Johannes Weiner <hannes@...xchg.org>,
        Kees Cook <keescook@...omium.org>,
        Christopher Covington <cov@...eaurora.org>,
        Alexey Dobriyan <adobriyan@...il.com>,
        Jann Horn <jann@...jh.net>, Joe Perches <joe@...ches.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        "Richard W.M. Jones" <rjones@...hat.com>,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Christopher Covington <cov@...eauora.org>
Subject: [PATCH] procfs: Add mem_end to /proc/<pid>/stat

Applications such as Just-In-Time (JIT) compilers, Checkpoint/Restore In
Userspace (CRIU), and User Mode Linux (UML) need to know the highest
virtual address, TASK_SIZE, to implement pointer tagging or make a first
educated guess at where to find a large, unused region of memory.
Unfortunately the currently available mechanisms for determining TASK_SIZE
are either convoluted and potentially error-prone, such as making repeated
munmap() calls and checking the return code, or make use of hard-coded
assumptions that limit an application's portability across kernels with
different Kconfig options and multiple architectures.

Therefore, expose TASK_SIZE to userspace. While PAGE_SIZE is exposed to
userspace via an auxiliary vector, that approach is not used for TASK_SIZE
in case run-time alterations to the usable virtual address range are one
day implemented, such as through an extension to prctl(PR_SET_MM) or a flag
to clone. There is no prctl(PR_GET_MM). Instead such information is
expected to come from /proc/<pid>/stat[m]. For the same extendability
reason, use a per-pid proc entry rather than a system-wide entry like
/proc/sys/vm/mmap_min_addr.

Signed-off-by: Christopher Covington <cov@...eauora.org>
---
 Documentation/filesystems/proc.txt | 1 +
 fs/proc/array.c                    | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 74329fd..b9c19cf 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -343,6 +343,7 @@ Table 1-4: Contents of the stat files (as of 2.6.30-rc7)
   env_start     address above which program environment is placed
   env_end       address below which program environment is placed
   exit_code     the thread's exit_code in the form reported by the waitpid system call
+  end_mem       address below which all regular program parts are placed (TASK_SIZE)
 ..............................................................................
 
 The /proc/PID/maps file containing the currently mapped memory regions and
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 9a3ca9e..32b5002 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -561,6 +561,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
 	else
 		seq_puts(m, " 0");
 
+	if (mm && permitted)
+		seq_put_decimal_ull(m, " ", mm->task_size);
+	else
+		seq_puts(m, " 0");
+
 	seq_putc(m, '\n');
 	if (mm)
 		mmput(mm);
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora
Forum, a Linux Foundation Collaborative Project.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ