Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

security: Add a hook for the point of notification insertion

Add a security hook that allows an LSM to rule on whether a notification
message is allowed to be inserted into a particular watch queue.

The hook is given the following information:

(1) The credentials of the triggerer (which may be init_cred for a system
notification, eg. a hardware error).

(2) The credentials of the whoever set the watch.

(3) The notification message.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jamorris@linux.microsoft.com>
cc: Casey Schaufler <casey@schaufler-ca.com>
cc: Stephen Smalley <sds@tycho.nsa.gov>
cc: linux-security-module@vger.kernel.org

+38
+5
include/linux/lsm_hook_defs.h
··· 253 253 LSM_HOOK(int, 0, inode_getsecctx, struct inode *inode, void **ctx, 254 254 u32 *ctxlen) 255 255 256 + #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE) 257 + LSM_HOOK(int, 0, post_notification, const struct cred *w_cred, 258 + const struct cred *cred, struct watch_notification *n) 259 + #endif /* CONFIG_SECURITY && CONFIG_KEY_NOTIFICATIONS */ 260 + 256 261 #ifdef CONFIG_SECURITY_NETWORK 257 262 LSM_HOOK(int, 0, unix_stream_connect, struct sock *sock, struct sock *other, 258 263 struct sock *newsk)
+9
include/linux/lsm_hooks.h
··· 1437 1437 * @ctx is a pointer in which to place the allocated security context. 1438 1438 * @ctxlen points to the place to put the length of @ctx. 1439 1439 * 1440 + * Security hooks for the general notification queue: 1441 + * 1442 + * @post_notification: 1443 + * Check to see if a watch notification can be posted to a particular 1444 + * queue. 1445 + * @w_cred: The credentials of the whoever set the watch. 1446 + * @cred: The event-triggerer's credentials 1447 + * @n: The notification being posted 1448 + * 1440 1449 * Security hooks for using the eBPF maps and programs functionalities through 1441 1450 * eBPF syscalls. 1442 1451 *
+15
include/linux/security.h
··· 56 56 struct fs_context; 57 57 struct fs_parameter; 58 58 enum fs_value_type; 59 + struct watch; 60 + struct watch_notification; 59 61 60 62 /* Default (no) options for the capable function */ 61 63 #define CAP_OPT_NONE 0x0 ··· 1276 1274 return 0; 1277 1275 } 1278 1276 #endif /* CONFIG_SECURITY */ 1277 + 1278 + #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE) 1279 + int security_post_notification(const struct cred *w_cred, 1280 + const struct cred *cred, 1281 + struct watch_notification *n); 1282 + #else 1283 + static inline int security_post_notification(const struct cred *w_cred, 1284 + const struct cred *cred, 1285 + struct watch_notification *n) 1286 + { 1287 + return 0; 1288 + } 1289 + #endif 1279 1290 1280 1291 #ifdef CONFIG_SECURITY_NETWORK 1281 1292
+9
security/security.c
··· 2007 2007 } 2008 2008 EXPORT_SYMBOL(security_inode_getsecctx); 2009 2009 2010 + #ifdef CONFIG_WATCH_QUEUE 2011 + int security_post_notification(const struct cred *w_cred, 2012 + const struct cred *cred, 2013 + struct watch_notification *n) 2014 + { 2015 + return call_int_hook(post_notification, 0, w_cred, cred, n); 2016 + } 2017 + #endif /* CONFIG_WATCH_QUEUE */ 2018 + 2010 2019 #ifdef CONFIG_SECURITY_NETWORK 2011 2020 2012 2021 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk)