cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

xattr.h (3402B)


      1/* SPDX-License-Identifier: GPL-2.0-or-later */
      2/*
      3 *   Copyright (C) 2021 Samsung Electronics Co., Ltd.
      4 */
      5
      6#ifndef __XATTR_H__
      7#define __XATTR_H__
      8
      9/*
     10 * These are on-disk structures to store additional metadata into xattr to
     11 * reproduce windows filesystem semantics. And they are encoded with NDR to
     12 * compatible with samba's xattr meta format. The compatibility with samba
     13 * is important because it can lose the information(file attribute,
     14 * creation time, acls) about the existing files when switching between
     15 * ksmbd and samba.
     16 */
     17
     18/*
     19 * Dos attribute flags used for what variable is valid.
     20 */
     21enum {
     22	XATTR_DOSINFO_ATTRIB		= 0x00000001,
     23	XATTR_DOSINFO_EA_SIZE		= 0x00000002,
     24	XATTR_DOSINFO_SIZE		= 0x00000004,
     25	XATTR_DOSINFO_ALLOC_SIZE	= 0x00000008,
     26	XATTR_DOSINFO_CREATE_TIME	= 0x00000010,
     27	XATTR_DOSINFO_CHANGE_TIME	= 0x00000020,
     28	XATTR_DOSINFO_ITIME		= 0x00000040
     29};
     30
     31/*
     32 * Dos attribute structure which is compatible with samba's one.
     33 * Storing it into the xattr named "DOSATTRIB" separately from inode
     34 * allows ksmbd to faithfully reproduce windows filesystem semantics
     35 * on top of a POSIX filesystem.
     36 */
     37struct xattr_dos_attrib {
     38	__u16	version;	/* version 3 or version 4 */
     39	__u32	flags;		/* valid flags */
     40	__u32	attr;		/* Dos attribute */
     41	__u32	ea_size;	/* EA size */
     42	__u64	size;
     43	__u64	alloc_size;
     44	__u64	create_time;	/* File creation time */
     45	__u64	change_time;	/* File change time */
     46	__u64	itime;		/* Invented/Initial time */
     47};
     48
     49/*
     50 * Enumeration is used for computing posix acl hash.
     51 */
     52enum {
     53	SMB_ACL_TAG_INVALID = 0,
     54	SMB_ACL_USER,
     55	SMB_ACL_USER_OBJ,
     56	SMB_ACL_GROUP,
     57	SMB_ACL_GROUP_OBJ,
     58	SMB_ACL_OTHER,
     59	SMB_ACL_MASK
     60};
     61
     62#define SMB_ACL_READ			4
     63#define SMB_ACL_WRITE			2
     64#define SMB_ACL_EXECUTE			1
     65
     66struct xattr_acl_entry {
     67	int type;
     68	uid_t uid;
     69	gid_t gid;
     70	mode_t perm;
     71};
     72
     73/*
     74 * xattr_smb_acl structure is used for computing posix acl hash.
     75 */
     76struct xattr_smb_acl {
     77	int count;
     78	int next;
     79	struct xattr_acl_entry entries[];
     80};
     81
     82/* 64bytes hash in xattr_ntacl is computed with sha256 */
     83#define XATTR_SD_HASH_TYPE_SHA256	0x1
     84#define XATTR_SD_HASH_SIZE		64
     85
     86/*
     87 * xattr_ntacl is used for storing ntacl and hashes.
     88 * Hash is used for checking valid posix acl and ntacl in xattr.
     89 */
     90struct xattr_ntacl {
     91	__u16	version; /* version 4*/
     92	void	*sd_buf;
     93	__u32	sd_size;
     94	__u16	hash_type; /* hash type */
     95	__u8	desc[10]; /* posix_acl description */
     96	__u16	desc_len;
     97	__u64	current_time;
     98	__u8	hash[XATTR_SD_HASH_SIZE]; /* 64bytes hash for ntacl */
     99	__u8	posix_acl_hash[XATTR_SD_HASH_SIZE]; /* 64bytes hash for posix acl */
    100};
    101
    102/* DOS ATTRIBUITE XATTR PREFIX */
    103#define DOS_ATTRIBUTE_PREFIX		"DOSATTRIB"
    104#define DOS_ATTRIBUTE_PREFIX_LEN	(sizeof(DOS_ATTRIBUTE_PREFIX) - 1)
    105#define XATTR_NAME_DOS_ATTRIBUTE	(XATTR_USER_PREFIX DOS_ATTRIBUTE_PREFIX)
    106#define XATTR_NAME_DOS_ATTRIBUTE_LEN	\
    107		(sizeof(XATTR_USER_PREFIX DOS_ATTRIBUTE_PREFIX) - 1)
    108
    109/* STREAM XATTR PREFIX */
    110#define STREAM_PREFIX			"DosStream."
    111#define STREAM_PREFIX_LEN		(sizeof(STREAM_PREFIX) - 1)
    112#define XATTR_NAME_STREAM		(XATTR_USER_PREFIX STREAM_PREFIX)
    113#define XATTR_NAME_STREAM_LEN		(sizeof(XATTR_NAME_STREAM) - 1)
    114
    115/* SECURITY DESCRIPTOR(NTACL) XATTR PREFIX */
    116#define SD_PREFIX			"NTACL"
    117#define SD_PREFIX_LEN	(sizeof(SD_PREFIX) - 1)
    118#define XATTR_NAME_SD	(XATTR_SECURITY_PREFIX SD_PREFIX)
    119#define XATTR_NAME_SD_LEN	\
    120		(sizeof(XATTR_SECURITY_PREFIX SD_PREFIX) - 1)
    121
    122#endif /* __XATTR_H__ */