Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * linux/fs/ext2/xattr_security.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Handler for storing security labels as extended attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include "ext2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/security.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include "xattr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) ext2_xattr_security_get(const struct xattr_handler *handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 			struct dentry *unused, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 			const char *name, void *buffer, size_t size, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 			      buffer, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) ext2_xattr_security_set(const struct xattr_handler *handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 			struct dentry *unused, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 			const char *name, const void *value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 			size_t size, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 			      value, size, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static int ext2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 			   void *fs_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	const struct xattr *xattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	for (xattr = xattr_array; xattr->name != NULL; xattr++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 				     xattr->name, xattr->value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 				     xattr->value_len, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ext2_init_security(struct inode *inode, struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		   const struct qstr *qstr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	return security_inode_init_security(inode, dir, qstr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 					    &ext2_initxattrs, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) const struct xattr_handler ext2_xattr_security_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	.prefix	= XATTR_SECURITY_PREFIX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	.get	= ext2_xattr_security_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	.set	= ext2_xattr_security_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };