summaryrefslogtreecommitdiffstats
path: root/sys-kernel/boest-v4.14.127/0008-This-patch-adds-support-for-a-restricted-user-contro.patch
diff options
context:
space:
mode:
Diffstat (limited to 'sys-kernel/boest-v4.14.127/0008-This-patch-adds-support-for-a-restricted-user-contro.patch')
-rw-r--r--sys-kernel/boest-v4.14.127/0008-This-patch-adds-support-for-a-restricted-user-contro.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/sys-kernel/boest-v4.14.127/0008-This-patch-adds-support-for-a-restricted-user-contro.patch b/sys-kernel/boest-v4.14.127/0008-This-patch-adds-support-for-a-restricted-user-contro.patch
new file mode 100644
index 00000000..ace92f8c
--- /dev/null
+++ b/sys-kernel/boest-v4.14.127/0008-This-patch-adds-support-for-a-restricted-user-contro.patch
@@ -0,0 +1,75 @@
+From ec80690acb31a392caa4471df60ce1be1b8a9bec Mon Sep 17 00:00:00 2001
+From: "Anthony G. Basile" <blueness@gentoo.org>
+Date: Mon, 23 Oct 2017 12:31:25 -0400
+Subject: [PATCH 08/19] This patch adds support for a restricted
+ user-controlled namespace on tmpfs filesystem used to house PaX flags. The
+ namespace must be of the form user.pax.* and its value cannot exceed a size
+ of 8 bytes.
+
+This is needed even on all Gentoo systems so that XATTR_PAX flags
+are preserved for users who might build packages using portage on
+a tmpfs system with a non-hardened kernel and then switch to a
+hardened kernel with XATTR_PAX enabled.
+
+The namespace is added to any user with Extended Attribute support
+enabled for tmpfs. Users who do not enable xattrs will not have
+the XATTR_PAX flags preserved.
+---
+ include/uapi/linux/xattr.h | 4 ++++
+ mm/shmem.c | 15 +++++++++++++++
+ 2 files changed, 19 insertions(+)
+
+diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
+index a92be0f492a9..7b5fec851bc9 100644
+--- a/include/uapi/linux/xattr.h
++++ b/include/uapi/linux/xattr.h
+@@ -74,5 +74,9 @@
+ #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
+ #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
+
++/* User namespace */
++#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
++#define XATTR_PAX_FLAGS_SUFFIX "flags"
++#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
+
+ #endif /* _UAPI_LINUX_XATTR_H */
+diff --git a/mm/shmem.c b/mm/shmem.c
+index 037e2ee9ccac..b0a7289e529b 100644
+--- a/mm/shmem.c
++++ b/mm/shmem.c
+@@ -3389,6 +3389,14 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,
+ struct shmem_inode_info *info = SHMEM_I(inode);
+
+ name = xattr_full_name(handler, name);
++
++ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
++ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
++ return -EOPNOTSUPP;
++ if (size > 8)
++ return -EINVAL;
++ }
++
+ return simple_xattr_set(&info->xattrs, name, value, size, flags);
+ }
+
+@@ -3404,6 +3412,12 @@ static const struct xattr_handler shmem_trusted_xattr_handler = {
+ .set = shmem_xattr_handler_set,
+ };
+
++static const struct xattr_handler shmem_user_xattr_handler = {
++ .prefix = XATTR_USER_PREFIX,
++ .get = shmem_xattr_handler_get,
++ .set = shmem_xattr_handler_set,
++};
++
+ static const struct xattr_handler *shmem_xattr_handlers[] = {
+ #ifdef CONFIG_TMPFS_POSIX_ACL
+ &posix_acl_access_xattr_handler,
+@@ -3411,6 +3425,7 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
+ #endif
+ &shmem_security_xattr_handler,
+ &shmem_trusted_xattr_handler,
++ &shmem_user_xattr_handler,
+ NULL
+ };
+