[XFS] xfs_qm_reset_dqcounts() does not return errors.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / security / smack / smack.h
blob62c1e982849d9b1ab83c38c1bc6bc9df68749e77
1 /*
2 * Copyright (C) 2007 Casey Schaufler <casey@schaufler-ca.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, version 2.
8 * Author:
9 * Casey Schaufler <casey@schaufler-ca.com>
13 #ifndef _SECURITY_SMACK_H
14 #define _SECURITY_SMACK_H
16 #include <linux/capability.h>
17 #include <linux/spinlock.h>
18 #include <net/netlabel.h>
21 * Why 23? CIPSO is constrained to 30, so a 32 byte buffer is
22 * bigger than can be used, and 24 is the next lower multiple
23 * of 8, and there are too many issues if there isn't space set
24 * aside for the terminating null byte.
26 #define SMK_MAXLEN 23
27 #define SMK_LABELLEN (SMK_MAXLEN+1)
29 struct superblock_smack {
30 char *smk_root;
31 char *smk_floor;
32 char *smk_hat;
33 char *smk_default;
34 int smk_initialized;
35 spinlock_t smk_sblock; /* for initialization */
38 struct socket_smack {
39 char *smk_out; /* outbound label */
40 char *smk_in; /* inbound label */
41 char smk_packet[SMK_LABELLEN]; /* TCP peer label */
45 * Inode smack data
47 struct inode_smack {
48 char *smk_inode; /* label of the fso */
49 struct mutex smk_lock; /* initialization lock */
50 int smk_flags; /* smack inode flags */
53 #define SMK_INODE_INSTANT 0x01 /* inode is instantiated */
56 * A label access rule.
58 struct smack_rule {
59 char *smk_subject;
60 char *smk_object;
61 int smk_access;
65 * An entry in the table of permitted label accesses.
67 struct smk_list_entry {
68 struct smk_list_entry *smk_next;
69 struct smack_rule smk_rule;
73 * An entry in the table mapping smack values to
74 * CIPSO level/category-set values.
76 struct smack_cipso {
77 int smk_level;
78 char smk_catset[SMK_LABELLEN];
82 * This is the repository for labels seen so that it is
83 * not necessary to keep allocating tiny chuncks of memory
84 * and so that they can be shared.
86 * Labels are never modified in place. Anytime a label
87 * is imported (e.g. xattrset on a file) the list is checked
88 * for it and it is added if it doesn't exist. The address
89 * is passed out in either case. Entries are added, but
90 * never deleted.
92 * Since labels are hanging around anyway it doesn't
93 * hurt to maintain a secid for those awkward situations
94 * where kernel components that ought to use LSM independent
95 * interfaces don't. The secid should go away when all of
96 * these components have been repaired.
98 * If there is a cipso value associated with the label it
99 * gets stored here, too. This will most likely be rare as
100 * the cipso direct mapping in used internally.
102 struct smack_known {
103 struct smack_known *smk_next;
104 char smk_known[SMK_LABELLEN];
105 u32 smk_secid;
106 struct smack_cipso *smk_cipso;
107 spinlock_t smk_cipsolock; /* for changing cipso map */
111 * Mount options
113 #define SMK_FSDEFAULT "smackfsdef="
114 #define SMK_FSFLOOR "smackfsfloor="
115 #define SMK_FSHAT "smackfshat="
116 #define SMK_FSROOT "smackfsroot="
119 * xattr names
121 #define XATTR_SMACK_SUFFIX "SMACK64"
122 #define XATTR_SMACK_IPIN "SMACK64IPIN"
123 #define XATTR_SMACK_IPOUT "SMACK64IPOUT"
124 #define XATTR_NAME_SMACK XATTR_SECURITY_PREFIX XATTR_SMACK_SUFFIX
125 #define XATTR_NAME_SMACKIPIN XATTR_SECURITY_PREFIX XATTR_SMACK_IPIN
126 #define XATTR_NAME_SMACKIPOUT XATTR_SECURITY_PREFIX XATTR_SMACK_IPOUT
129 * smackfs macic number
131 #define SMACK_MAGIC 0x43415d53 /* "SMAC" */
134 * A limit on the number of entries in the lists
135 * makes some of the list administration easier.
137 #define SMACK_LIST_MAX 10000
140 * CIPSO defaults.
142 #define SMACK_CIPSO_DOI_DEFAULT 3 /* Historical */
143 #define SMACK_CIPSO_DIRECT_DEFAULT 250 /* Arbitrary */
144 #define SMACK_CIPSO_MAXCATVAL 63 /* Bigger gets harder */
145 #define SMACK_CIPSO_MAXLEVEL 255 /* CIPSO 2.2 standard */
146 #define SMACK_CIPSO_MAXCATNUM 239 /* CIPSO 2.2 standard */
149 * Just to make the common cases easier to deal with
151 #define MAY_ANY (MAY_READ | MAY_WRITE | MAY_APPEND | MAY_EXEC)
152 #define MAY_ANYREAD (MAY_READ | MAY_EXEC)
153 #define MAY_ANYWRITE (MAY_WRITE | MAY_APPEND)
154 #define MAY_READWRITE (MAY_READ | MAY_WRITE)
155 #define MAY_NOT 0
158 * These functions are in smack_lsm.c
160 struct inode_smack *new_inode_smack(char *);
163 * These functions are in smack_access.c
165 int smk_access(char *, char *, int);
166 int smk_curacc(char *, u32);
167 int smack_to_cipso(const char *, struct smack_cipso *);
168 void smack_from_cipso(u32, char *, char *);
169 char *smack_from_secid(const u32);
170 char *smk_import(const char *, int);
171 struct smack_known *smk_import_entry(const char *, int);
172 u32 smack_to_secid(const char *);
175 * Shared data.
177 extern int smack_cipso_direct;
178 extern int smack_net_nltype;
179 extern char *smack_net_ambient;
181 extern struct smack_known *smack_known;
182 extern struct smack_known smack_known_floor;
183 extern struct smack_known smack_known_hat;
184 extern struct smack_known smack_known_huh;
185 extern struct smack_known smack_known_invalid;
186 extern struct smack_known smack_known_star;
187 extern struct smack_known smack_known_unset;
189 extern struct smk_list_entry *smack_list;
192 * Stricly for CIPSO level manipulation.
193 * Set the category bit number in a smack label sized buffer.
195 static inline void smack_catset_bit(int cat, char *catsetp)
197 if (cat > SMK_LABELLEN * 8)
198 return;
200 catsetp[(cat - 1) / 8] |= 0x80 >> ((cat - 1) % 8);
204 * Present a pointer to the smack label in an inode blob.
206 static inline char *smk_of_inode(const struct inode *isp)
208 struct inode_smack *sip = isp->i_security;
209 return sip->smk_inode;
212 #endif /* _SECURITY_SMACK_H */