xref: /linux/fs/smb/client/cifsacl.h (revision be602cde657ee43d23adbf309be6d700d0106dc9)
138c8a9a5SSteve French /* SPDX-License-Identifier: LGPL-2.1 */
238c8a9a5SSteve French /*
338c8a9a5SSteve French  *
438c8a9a5SSteve French  *   Copyright (c) International Business Machines  Corp., 2007
538c8a9a5SSteve French  *   Author(s): Steve French (sfrench@us.ibm.com)
638c8a9a5SSteve French  *
738c8a9a5SSteve French  */
838c8a9a5SSteve French 
938c8a9a5SSteve French #ifndef _CIFSACL_H
1038c8a9a5SSteve French #define _CIFSACL_H
1138c8a9a5SSteve French 
12b51174daSChenXiaoSong #include "../common/smbacl.h"
1338c8a9a5SSteve French 
1438c8a9a5SSteve French #define READ_BIT        0x4
1538c8a9a5SSteve French #define WRITE_BIT       0x2
1638c8a9a5SSteve French #define EXEC_BIT        0x1
1738c8a9a5SSteve French 
1838c8a9a5SSteve French #define ACL_OWNER_MASK 0700
1938c8a9a5SSteve French #define ACL_GROUP_MASK 0070
2038c8a9a5SSteve French #define ACL_EVERYONE_MASK 0007
2138c8a9a5SSteve French 
2238c8a9a5SSteve French #define UBITSHIFT	6
2338c8a9a5SSteve French #define GBITSHIFT	3
2438c8a9a5SSteve French 
2538c8a9a5SSteve French /*
2638c8a9a5SSteve French  * Security Descriptor length containing DACL with 3 ACEs (one each for
2738c8a9a5SSteve French  * owner, group and world).
2838c8a9a5SSteve French  */
2936514876SChenXiaoSong #define DEFAULT_SEC_DESC_LEN (sizeof(struct smb_ntsd) + \
30251b93aeSChenXiaoSong 			      sizeof(struct smb_acl) + \
3109bedafcSChenXiaoSong 			      (sizeof(struct smb_ace) * 4))
3238c8a9a5SSteve French 
3338c8a9a5SSteve French /*
3438c8a9a5SSteve French  * The current SMB3 form of security descriptor is similar to what was used for
3538c8a9a5SSteve French  * cifs (see above) but some fields are split, and fields in the struct below
3638c8a9a5SSteve French  * matches names of fields to the spec, MS-DTYP (see sections 2.4.5 and
3738c8a9a5SSteve French  * 2.4.6). Note that "CamelCase" fields are used in this struct in order to
3838c8a9a5SSteve French  * match the MS-DTYP and MS-SMB2 specs which define the wire format.
3938c8a9a5SSteve French  */
4038c8a9a5SSteve French struct smb3_sd {
4138c8a9a5SSteve French 	__u8 Revision; /* revision level, MUST be one */
4238c8a9a5SSteve French 	__u8 Sbz1; /* only meaningful if 'RM' flag set below */
4338c8a9a5SSteve French 	__le16 Control;
4438c8a9a5SSteve French 	__le32 OffsetOwner;
4538c8a9a5SSteve French 	__le32 OffsetGroup;
4638c8a9a5SSteve French 	__le32 OffsetSacl;
4738c8a9a5SSteve French 	__le32 OffsetDacl;
4838c8a9a5SSteve French } __packed;
4938c8a9a5SSteve French 
5038c8a9a5SSteve French /* Meaning of 'Control' field flags */
5138c8a9a5SSteve French #define ACL_CONTROL_SR	0x8000	/* Self relative */
5238c8a9a5SSteve French #define ACL_CONTROL_RM	0x4000	/* Resource manager control bits */
5338c8a9a5SSteve French #define ACL_CONTROL_PS	0x2000	/* SACL protected from inherits */
5438c8a9a5SSteve French #define ACL_CONTROL_PD	0x1000	/* DACL protected from inherits */
5538c8a9a5SSteve French #define ACL_CONTROL_SI	0x0800	/* SACL Auto-Inherited */
5638c8a9a5SSteve French #define ACL_CONTROL_DI	0x0400	/* DACL Auto-Inherited */
5738c8a9a5SSteve French #define ACL_CONTROL_SC	0x0200	/* SACL computed through inheritance */
58*e9f49feeSShen Lichuan #define ACL_CONTROL_DC	0x0100	/* DACL computed through inheritance */
5938c8a9a5SSteve French #define ACL_CONTROL_SS	0x0080	/* Create server ACL */
6038c8a9a5SSteve French #define ACL_CONTROL_DT	0x0040	/* DACL provided by trusted source */
6138c8a9a5SSteve French #define ACL_CONTROL_SD	0x0020	/* SACL defaulted */
6238c8a9a5SSteve French #define ACL_CONTROL_SP	0x0010	/* SACL is present on object */
6338c8a9a5SSteve French #define ACL_CONTROL_DD	0x0008	/* DACL defaulted */
6438c8a9a5SSteve French #define ACL_CONTROL_DP	0x0004	/* DACL is present on object */
6538c8a9a5SSteve French #define ACL_CONTROL_GD	0x0002	/* Group was defaulted */
6638c8a9a5SSteve French #define ACL_CONTROL_OD	0x0001	/* User was defaulted */
6738c8a9a5SSteve French 
6838c8a9a5SSteve French /* Meaning of AclRevision flags */
6938c8a9a5SSteve French #define ACL_REVISION	0x02 /* See section 2.4.4.1 of MS-DTYP */
7038c8a9a5SSteve French #define ACL_REVISION_DS	0x04 /* Additional AceTypes allowed */
7138c8a9a5SSteve French 
7238c8a9a5SSteve French struct smb3_acl {
7338c8a9a5SSteve French 	u8 AclRevision; /* revision level */
7438c8a9a5SSteve French 	u8 Sbz1; /* MBZ */
7538c8a9a5SSteve French 	__le16 AclSize;
7638c8a9a5SSteve French 	__le16 AceCount;
7738c8a9a5SSteve French 	__le16 Sbz2; /* MBZ */
7838c8a9a5SSteve French } __packed;
7938c8a9a5SSteve French 
8038c8a9a5SSteve French /*
8138c8a9a5SSteve French  * Used to store the special 'NFS SIDs' used to persist the POSIX uid and gid
8238c8a9a5SSteve French  * See http://technet.microsoft.com/en-us/library/hh509017(v=ws.10).aspx
8338c8a9a5SSteve French  */
8438c8a9a5SSteve French struct owner_sid {
8538c8a9a5SSteve French 	u8 Revision;
8638c8a9a5SSteve French 	u8 NumAuth;
8738c8a9a5SSteve French 	u8 Authority[6];
8838c8a9a5SSteve French 	__le32 SubAuthorities[3];
8938c8a9a5SSteve French } __packed;
9038c8a9a5SSteve French 
9138c8a9a5SSteve French struct owner_group_sids {
9238c8a9a5SSteve French 	struct owner_sid owner;
9338c8a9a5SSteve French 	struct owner_sid group;
9438c8a9a5SSteve French } __packed;
9538c8a9a5SSteve French 
9638c8a9a5SSteve French /*
9738c8a9a5SSteve French  * Minimum security identifier can be one for system defined Users
9838c8a9a5SSteve French  * and Groups such as NULL SID and World or Built-in accounts such
9938c8a9a5SSteve French  * as Administrator and Guest and consists of
10038c8a9a5SSteve French  * Revision + Num (Sub)Auths + Authority + Domain (one Subauthority)
10138c8a9a5SSteve French  */
10238c8a9a5SSteve French #define MIN_SID_LEN  (1 + 1 + 6 + 4) /* in bytes */
10338c8a9a5SSteve French 
10438c8a9a5SSteve French /*
10538c8a9a5SSteve French  * Minimum security descriptor can be one without any SACL and DACL and can
10638c8a9a5SSteve French  * consist of revision, type, and two sids of minimum size for owner and group
10738c8a9a5SSteve French  */
10836514876SChenXiaoSong #define MIN_SEC_DESC_LEN  (sizeof(struct smb_ntsd) + (2 * MIN_SID_LEN))
10938c8a9a5SSteve French 
11038c8a9a5SSteve French #endif /* _CIFSACL_H */
111