Skip to content

Commit c5e3cdb

Browse files
committed
tomoyo: revert CONFIG_SECURITY_TOMOYO_LKM support
This patch reverts two TOMOYO patches that were merged into Linus' tree during the v6.12 merge window: 8b985bb ("tomoyo: allow building as a loadable LSM module") 268225a ("tomoyo: preparation step for building as a loadable LSM module") Together these two patches introduced the CONFIG_SECURITY_TOMOYO_LKM Kconfig build option which enabled a TOMOYO specific dynamic LSM loading mechanism (see the original commits for more details). Unfortunately, this approach was widely rejected by the LSM community as well as some members of the general kernel community. Objections included concerns over setting a bad precedent regarding individual LSMs managing their LSM callback registrations as well as general kernel symbol exporting practices. With little to no support for the CONFIG_SECURITY_TOMOYO_LKM approach outside of Tetsuo, and multiple objections, we need to revert these changes. Link: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/all/CAHC9VhR=QjdoHG3wJgHFJkKYBg7vkQH2MpffgVzQ0tAByo_wRg@mail.gmail.com Acked-by: John Johansen <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 9852d85 commit c5e3cdb

File tree

11 files changed

+118
-577
lines changed

11 files changed

+118
-577
lines changed

security/tomoyo/Kconfig

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@ config SECURITY_TOMOYO
1313
found at <https://tomoyo.sourceforge.net/>.
1414
If you are unsure how to answer this question, answer N.
1515

16-
config SECURITY_TOMOYO_LKM
17-
bool "Cut out most of TOMOYO's code to a loadable kernel module"
18-
default n
19-
depends on SECURITY_TOMOYO
20-
depends on MODULES
21-
help
22-
Say Y here if you want to include TOMOYO without bloating
23-
vmlinux file. If you say Y, most of TOMOYO code is cut out to
24-
a loadable kernel module named tomoyo.ko . This option will be
25-
useful for kernels built by Linux distributors where TOMOYO is
26-
included but TOMOYO is not enabled by default. Please be sure
27-
to explicitly load tomoyo.ko if you want to activate TOMOYO
28-
without calling userspace policy loader, for tomoyo.ko is
29-
loaded immediately before calling userspace policy loader.
30-
3116
config SECURITY_TOMOYO_MAX_ACCEPT_ENTRY
3217
int "Default maximal count for learning mode"
3318
default 2048

security/tomoyo/Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
tomoyo-objs := audit.o common.o condition.o domain.o environ.o file.o gc.o group.o memory.o mount.o network.o proxy.o realpath.o securityfs_if.o util.o
3-
obj-y += init.o load_policy.o
4-
ifdef CONFIG_SECURITY_TOMOYO_LKM
5-
obj-m += tomoyo.o
6-
else
7-
obj-y += tomoyo.o
8-
endif
2+
obj-y = audit.o common.o condition.o domain.o environ.o file.o gc.o group.o load_policy.o memory.o mount.o network.o realpath.o securityfs_if.o tomoyo.o util.o
93

104
targets += builtin-policy.h
115

security/tomoyo/common.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -998,13 +998,8 @@ static bool tomoyo_select_domain(struct tomoyo_io_buffer *head,
998998
p = find_task_by_pid_ns(pid, &init_pid_ns);
999999
else
10001000
p = find_task_by_vpid(pid);
1001-
if (p) {
1001+
if (p)
10021002
domain = tomoyo_task(p)->domain_info;
1003-
#ifdef CONFIG_SECURITY_TOMOYO_LKM
1004-
if (!domain)
1005-
domain = &tomoyo_kernel_domain;
1006-
#endif
1007-
}
10081003
rcu_read_unlock();
10091004
} else if (!strncmp(data, "domain=", 7)) {
10101005
if (tomoyo_domain_def(data + 7))
@@ -1715,13 +1710,8 @@ static void tomoyo_read_pid(struct tomoyo_io_buffer *head)
17151710
p = find_task_by_pid_ns(pid, &init_pid_ns);
17161711
else
17171712
p = find_task_by_vpid(pid);
1718-
if (p) {
1713+
if (p)
17191714
domain = tomoyo_task(p)->domain_info;
1720-
#ifdef CONFIG_SECURITY_TOMOYO_LKM
1721-
if (!domain)
1722-
domain = &tomoyo_kernel_domain;
1723-
#endif
1724-
}
17251715
rcu_read_unlock();
17261716
if (!domain)
17271717
return;

security/tomoyo/common.h

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,6 @@ int tomoyo_get_mode(const struct tomoyo_policy_namespace *ns, const u8 profile,
978978
int tomoyo_init_request_info(struct tomoyo_request_info *r,
979979
struct tomoyo_domain_info *domain,
980980
const u8 index);
981-
int __init tomoyo_interface_init(void);
982981
int tomoyo_mkdev_perm(const u8 operation, const struct path *path,
983982
const unsigned int mode, unsigned int dev);
984983
int tomoyo_mount_permission(const char *dev_name, const struct path *path,
@@ -1215,14 +1214,10 @@ static inline void tomoyo_put_group(struct tomoyo_group *group)
12151214
*
12161215
* Returns pointer to "struct tomoyo_task" for specified thread.
12171216
*/
1218-
#ifdef CONFIG_SECURITY_TOMOYO_LKM
1219-
extern struct tomoyo_task *tomoyo_task(struct task_struct *task);
1220-
#else
12211217
static inline struct tomoyo_task *tomoyo_task(struct task_struct *task)
12221218
{
12231219
return task->security + tomoyo_blob_sizes.lbs_task;
12241220
}
1225-
#endif
12261221

12271222
/**
12281223
* tomoyo_same_name_union - Check for duplicated "struct tomoyo_name_union" entry.
@@ -1289,71 +1284,4 @@ static inline struct tomoyo_policy_namespace *tomoyo_current_namespace(void)
12891284
pos = srcu_dereference((head)->next, &tomoyo_ss); \
12901285
for ( ; pos != (head); pos = srcu_dereference(pos->next, &tomoyo_ss))
12911286

1292-
#ifdef CONFIG_SECURITY_TOMOYO_LKM
1293-
1294-
#define LSM_HOOK(RET, DEFAULT, NAME, ...) typedef RET (NAME##_t)(__VA_ARGS__);
1295-
#include <linux/lsm_hook_defs.h>
1296-
#undef LSM_HOOK
1297-
1298-
struct tomoyo_hooks {
1299-
cred_prepare_t *cred_prepare;
1300-
bprm_committed_creds_t *bprm_committed_creds;
1301-
task_alloc_t *task_alloc;
1302-
task_free_t *task_free;
1303-
bprm_check_security_t *bprm_check_security;
1304-
file_fcntl_t *file_fcntl;
1305-
file_open_t *file_open;
1306-
file_truncate_t *file_truncate;
1307-
path_truncate_t *path_truncate;
1308-
path_unlink_t *path_unlink;
1309-
path_mkdir_t *path_mkdir;
1310-
path_rmdir_t *path_rmdir;
1311-
path_symlink_t *path_symlink;
1312-
path_mknod_t *path_mknod;
1313-
path_link_t *path_link;
1314-
path_rename_t *path_rename;
1315-
inode_getattr_t *inode_getattr;
1316-
file_ioctl_t *file_ioctl;
1317-
file_ioctl_compat_t *file_ioctl_compat;
1318-
path_chmod_t *path_chmod;
1319-
path_chown_t *path_chown;
1320-
path_chroot_t *path_chroot;
1321-
sb_mount_t *sb_mount;
1322-
sb_umount_t *sb_umount;
1323-
sb_pivotroot_t *sb_pivotroot;
1324-
socket_bind_t *socket_bind;
1325-
socket_connect_t *socket_connect;
1326-
socket_listen_t *socket_listen;
1327-
socket_sendmsg_t *socket_sendmsg;
1328-
};
1329-
1330-
extern void tomoyo_register_hooks(const struct tomoyo_hooks *tomoyo_hooks);
1331-
1332-
struct tomoyo_operations {
1333-
void (*check_profile)(void);
1334-
int enabled;
1335-
};
1336-
1337-
extern struct tomoyo_operations tomoyo_ops;
1338-
1339-
/*
1340-
* Temporary hack: functions needed by tomoyo.ko . This will be removed
1341-
* after all functions are marked as EXPORT_STMBOL_GPL().
1342-
*/
1343-
struct tomoyo_tmp_exports {
1344-
struct task_struct * (*find_task_by_vpid)(pid_t nr);
1345-
struct task_struct * (*find_task_by_pid_ns)(pid_t nr, struct pid_namespace *ns);
1346-
void (*put_filesystem)(struct file_system_type *fs);
1347-
struct file * (*get_mm_exe_file)(struct mm_struct *mm);
1348-
char * (*d_absolute_path)(const struct path *path, char *buf, int buflen);
1349-
};
1350-
extern const struct tomoyo_tmp_exports tomoyo_tmp_exports;
1351-
#define find_task_by_vpid tomoyo_tmp_exports.find_task_by_vpid
1352-
#define find_task_by_pid_ns tomoyo_tmp_exports.find_task_by_pid_ns
1353-
#define put_filesystem tomoyo_tmp_exports.put_filesystem
1354-
#define get_mm_exe_file tomoyo_tmp_exports.get_mm_exe_file
1355-
#define d_absolute_path tomoyo_tmp_exports.d_absolute_path
1356-
1357-
#endif /* defined(CONFIG_SECURITY_TOMOYO_LKM) */
1358-
13591287
#endif /* !defined(_SECURITY_TOMOYO_COMMON_H) */

security/tomoyo/gc.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#include <linux/kthread.h>
1010
#include <linux/slab.h>
1111

12-
/* Lock for GC. */
13-
DEFINE_SRCU(tomoyo_ss);
14-
1512
/**
1613
* tomoyo_memory_free - Free memory for elements.
1714
*

0 commit comments

Comments
 (0)