Contributors: 17
Author Tokens Token Proportion Commits Commit Proportion
Dave Kleikamp 160 56.74% 1 4.55%
Mimi Zohar 56 19.86% 1 4.55%
Al Viro 14 4.96% 2 9.09%
Mingming Cao 11 3.90% 1 4.55%
James Morris 8 2.84% 1 4.55%
Theodore Y. Ts'o 6 2.13% 2 9.09%
Christoph Hellwig 5 1.77% 2 9.09%
Christian Brauner 5 1.77% 2 9.09%
Tiger Yang 3 1.06% 1 4.55%
Stephen Hemminger 3 1.06% 2 9.09%
Eric Paris 3 1.06% 1 4.55%
Andreas Gruenbacher 2 0.71% 1 4.55%
Linus Torvalds (pre-git) 2 0.71% 1 4.55%
Djalal Harouni 1 0.35% 1 4.55%
Eryu Guan 1 0.35% 1 4.55%
Linus Torvalds 1 0.35% 1 4.55%
Greg Kroah-Hartman 1 0.35% 1 4.55%
Total 282 22


// SPDX-License-Identifier: GPL-2.0
/*
 * linux/fs/ext4/xattr_security.c
 * Handler for storing security labels as extended attributes.
 */

#include <linux/string.h>
#include <linux/fs.h>
#include <linux/security.h>
#include <linux/slab.h>
#include "ext4_jbd2.h"
#include "ext4.h"
#include "xattr.h"

static int
ext4_xattr_security_get(const struct xattr_handler *handler,
			struct dentry *unused, struct inode *inode,
			const char *name, void *buffer, size_t size)
{
	return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY,
			      name, buffer, size);
}

static int
ext4_xattr_security_set(const struct xattr_handler *handler,
			struct mnt_idmap *idmap,
			struct dentry *unused, struct inode *inode,
			const char *name, const void *value,
			size_t size, int flags)
{
	return ext4_xattr_set(inode, EXT4_XATTR_INDEX_SECURITY,
			      name, value, size, flags);
}

static int
ext4_initxattrs(struct inode *inode, const struct xattr *xattr_array,
		void *fs_info)
{
	const struct xattr *xattr;
	handle_t *handle = fs_info;
	int err = 0;

	for (xattr = xattr_array; xattr->name != NULL; xattr++) {
		err = ext4_xattr_set_handle(handle, inode,
					    EXT4_XATTR_INDEX_SECURITY,
					    xattr->name, xattr->value,
					    xattr->value_len, XATTR_CREATE);
		if (err < 0)
			break;
	}
	return err;
}

int
ext4_init_security(handle_t *handle, struct inode *inode, struct inode *dir,
		   const struct qstr *qstr)
{
	return security_inode_init_security(inode, dir, qstr,
					    &ext4_initxattrs, handle);
}

const struct xattr_handler ext4_xattr_security_handler = {
	.prefix	= XATTR_SECURITY_PREFIX,
	.get	= ext4_xattr_security_get,
	.set	= ext4_xattr_security_set,
};