mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
Prior to this change, no security hooks were called at the creation of a memfd file. It means that, for SELinux as an example, it will receive the default type of the filesystem that backs the in-memory inode. In most cases, that would be tmpfs, but if MFD_HUGETLB is passed, it will be hugetlbfs. Both can be considered implementation details of memfd. It also means that it is not possible to differentiate between a file coming from memfd_create and a file coming from a standard tmpfs mount point. Additionally, no permission is validated at creation, which differs from the similar memfd_secret syscall. Call security_inode_init_security_anon during creation. This ensures that the file is setup similarly to other anonymous inodes. On SELinux, it means that the file will receive the security context of its task. The ability to limit fexecve on memfd has been of interest to avoid potential pitfalls where /proc/self/exe or similar would be executed [1][2]. Reuse the "execute_no_trans" and "entrypoint" access vectors, similarly to the file class. These access vectors may not make sense for the existing "anon_inode" class. Therefore, define and assign a new class "memfd_file" to support such access vectors. Guard these changes behind a new policy capability named "memfd_class". [1] https://crbug.com/1305267 [2] https://lore.kernel.org/lkml/20221215001205.51969-1-jeffxu@google.com/ Signed-off-by: Thiébaud Weksteen <tweek@google.com> Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com> Tested-by: Stephen Smalley <stephen.smalley.work@gmail.com> Acked-by: Hugh Dickins <hughd@google.com> [PM: subj tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
29 lines
647 B
C
29 lines
647 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _SELINUX_POLICYCAP_NAMES_H_
|
|
#define _SELINUX_POLICYCAP_NAMES_H_
|
|
|
|
#include "policycap.h"
|
|
|
|
/* clang-format off */
|
|
/* Policy capability names */
|
|
const char *const selinux_policycap_names[__POLICYDB_CAP_MAX] = {
|
|
"network_peer_controls",
|
|
"open_perms",
|
|
"extended_socket_class",
|
|
"always_check_network",
|
|
"cgroup_seclabel",
|
|
"nnp_nosuid_transition",
|
|
"genfs_seclabel_symlinks",
|
|
"ioctl_skip_cloexec",
|
|
"userspace_initial_context",
|
|
"netlink_xperm",
|
|
"netif_wildcard",
|
|
"genfs_seclabel_wildcard",
|
|
"functionfs_seclabel",
|
|
"memfd_class",
|
|
};
|
|
/* clang-format on */
|
|
|
|
#endif /* _SELINUX_POLICYCAP_NAMES_H_ */
|