0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/export.h>
0010 #include <linux/kernel.h>
0011 #include <linux/sched.h>
0012 #include <linux/cred.h>
0013 #include <linux/err.h>
0014 #include <linux/init.h>
0015 #include <linux/slab.h>
0016 #include <keys/system_keyring.h>
0017
0018
0019 struct key *ima_blacklist_keyring;
0020
0021
0022
0023
0024 static __init int ima_mok_init(void)
0025 {
0026 struct key_restriction *restriction;
0027
0028 pr_notice("Allocating IMA blacklist keyring.\n");
0029
0030 restriction = kzalloc(sizeof(struct key_restriction), GFP_KERNEL);
0031 if (!restriction)
0032 panic("Can't allocate IMA blacklist restriction.");
0033
0034 restriction->check = restrict_link_by_builtin_trusted;
0035
0036 ima_blacklist_keyring = keyring_alloc(".ima_blacklist",
0037 KUIDT_INIT(0), KGIDT_INIT(0), current_cred(),
0038 (KEY_POS_ALL & ~KEY_POS_SETATTR) |
0039 KEY_USR_VIEW | KEY_USR_READ |
0040 KEY_USR_WRITE | KEY_USR_SEARCH,
0041 KEY_ALLOC_NOT_IN_QUOTA |
0042 KEY_ALLOC_SET_KEEP,
0043 restriction, NULL);
0044
0045 if (IS_ERR(ima_blacklist_keyring))
0046 panic("Can't allocate IMA blacklist keyring.");
0047 return 0;
0048 }
0049 device_initcall(ima_mok_init);