34
34
#include <linux/xfrm.h>
35
35
#include <net/flow.h>
36
36
37
+ /* only a char in selinux superblock security struct flags */
38
+ #define FSCONTEXT_MNT 0x01
39
+ #define CONTEXT_MNT 0x02
40
+ #define ROOTCONTEXT_MNT 0x04
41
+ #define DEFCONTEXT_MNT 0x08
42
+
37
43
/*
38
44
* Bounding set
39
45
*/
@@ -243,9 +249,6 @@ struct request_sock;
243
249
* @mnt contains the mounted file system.
244
250
* @flags contains the new filesystem flags.
245
251
* @data contains the filesystem-specific data.
246
- * @sb_post_mountroot:
247
- * Update the security module's state when the root filesystem is mounted.
248
- * This hook is only called if the mount was successful.
249
252
* @sb_post_addmount:
250
253
* Update the security module's state when a filesystem is mounted.
251
254
* This hook is called any time a mount is successfully grafetd to
@@ -261,6 +264,22 @@ struct request_sock;
261
264
* Update module state after a successful pivot.
262
265
* @old_nd contains the nameidata structure for the old root.
263
266
* @new_nd contains the nameidata structure for the new root.
267
+ * @sb_get_mnt_opts:
268
+ * Get the security relevant mount options used for a superblock
269
+ * @sb the superblock to get security mount options from
270
+ * @mount_options array for pointers to mount options
271
+ * @mount_flags array of ints specifying what each mount options is
272
+ * @num_opts number of options in the arrays
273
+ * @sb_set_mnt_opts:
274
+ * Set the security relevant mount options used for a superblock
275
+ * @sb the superblock to set security mount options for
276
+ * @mount_options array for pointers to mount options
277
+ * @mount_flags array of ints specifying what each mount options is
278
+ * @num_opts number of options in the arrays
279
+ * @sb_clone_mnt_opts:
280
+ * Copy all security options from a given superblock to another
281
+ * @oldsb old superblock which contain information to clone
282
+ * @newsb new superblock which needs filled in
264
283
*
265
284
* Security hooks for inode operations.
266
285
*
@@ -1183,6 +1202,10 @@ struct request_sock;
1183
1202
* Convert secid to security context.
1184
1203
* @secid contains the security ID.
1185
1204
* @secdata contains the pointer that stores the converted security context.
1205
+ * @secctx_to_secid:
1206
+ * Convert security context to secid.
1207
+ * @secid contains the pointer to the generated security ID.
1208
+ * @secdata contains the security context.
1186
1209
*
1187
1210
* @release_secctx:
1188
1211
* Release the security context.
@@ -1235,13 +1258,19 @@ struct security_operations {
1235
1258
void (* sb_umount_busy ) (struct vfsmount * mnt );
1236
1259
void (* sb_post_remount ) (struct vfsmount * mnt ,
1237
1260
unsigned long flags , void * data );
1238
- void (* sb_post_mountroot ) (void );
1239
1261
void (* sb_post_addmount ) (struct vfsmount * mnt ,
1240
1262
struct nameidata * mountpoint_nd );
1241
1263
int (* sb_pivotroot ) (struct nameidata * old_nd ,
1242
1264
struct nameidata * new_nd );
1243
1265
void (* sb_post_pivotroot ) (struct nameidata * old_nd ,
1244
1266
struct nameidata * new_nd );
1267
+ int (* sb_get_mnt_opts ) (const struct super_block * sb ,
1268
+ char * * * mount_options , int * * flags ,
1269
+ int * num_opts );
1270
+ int (* sb_set_mnt_opts ) (struct super_block * sb , char * * mount_options ,
1271
+ int * flags , int num_opts );
1272
+ void (* sb_clone_mnt_opts ) (const struct super_block * oldsb ,
1273
+ struct super_block * newsb );
1245
1274
1246
1275
int (* inode_alloc_security ) (struct inode * inode );
1247
1276
void (* inode_free_security ) (struct inode * inode );
@@ -1371,6 +1400,7 @@ struct security_operations {
1371
1400
int (* getprocattr )(struct task_struct * p , char * name , char * * value );
1372
1401
int (* setprocattr )(struct task_struct * p , char * name , void * value , size_t size );
1373
1402
int (* secid_to_secctx )(u32 secid , char * * secdata , u32 * seclen );
1403
+ int (* secctx_to_secid )(char * secdata , u32 seclen , u32 * secid );
1374
1404
void (* release_secctx )(char * secdata , u32 seclen );
1375
1405
1376
1406
#ifdef CONFIG_SECURITY_NETWORK
@@ -1495,10 +1525,16 @@ int security_sb_umount(struct vfsmount *mnt, int flags);
1495
1525
void security_sb_umount_close (struct vfsmount * mnt );
1496
1526
void security_sb_umount_busy (struct vfsmount * mnt );
1497
1527
void security_sb_post_remount (struct vfsmount * mnt , unsigned long flags , void * data );
1498
- void security_sb_post_mountroot (void );
1499
1528
void security_sb_post_addmount (struct vfsmount * mnt , struct nameidata * mountpoint_nd );
1500
1529
int security_sb_pivotroot (struct nameidata * old_nd , struct nameidata * new_nd );
1501
1530
void security_sb_post_pivotroot (struct nameidata * old_nd , struct nameidata * new_nd );
1531
+ int security_sb_get_mnt_opts (const struct super_block * sb , char * * * mount_options ,
1532
+ int * * flags , int * num_opts );
1533
+ int security_sb_set_mnt_opts (struct super_block * sb , char * * mount_options ,
1534
+ int * flags , int num_opts );
1535
+ void security_sb_clone_mnt_opts (const struct super_block * oldsb ,
1536
+ struct super_block * newsb );
1537
+
1502
1538
int security_inode_alloc (struct inode * inode );
1503
1539
void security_inode_free (struct inode * inode );
1504
1540
int security_inode_init_security (struct inode * inode , struct inode * dir ,
@@ -1603,6 +1639,7 @@ int security_setprocattr(struct task_struct *p, char *name, void *value, size_t
1603
1639
int security_netlink_send (struct sock * sk , struct sk_buff * skb );
1604
1640
int security_netlink_recv (struct sk_buff * skb , int cap );
1605
1641
int security_secid_to_secctx (u32 secid , char * * secdata , u32 * seclen );
1642
+ int security_secctx_to_secid (char * secdata , u32 seclen , u32 * secid );
1606
1643
void security_release_secctx (char * secdata , u32 seclen );
1607
1644
1608
1645
#else /* CONFIG_SECURITY */
@@ -1777,9 +1814,6 @@ static inline void security_sb_post_remount (struct vfsmount *mnt,
1777
1814
unsigned long flags , void * data )
1778
1815
{ }
1779
1816
1780
- static inline void security_sb_post_mountroot (void )
1781
- { }
1782
-
1783
1817
static inline void security_sb_post_addmount (struct vfsmount * mnt ,
1784
1818
struct nameidata * mountpoint_nd )
1785
1819
{ }
@@ -2266,7 +2300,7 @@ static inline struct dentry *securityfs_create_file(const char *name,
2266
2300
mode_t mode ,
2267
2301
struct dentry * parent ,
2268
2302
void * data ,
2269
- struct file_operations * fops )
2303
+ const struct file_operations * fops )
2270
2304
{
2271
2305
return ERR_PTR (- ENODEV );
2272
2306
}
@@ -2280,6 +2314,13 @@ static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *secle
2280
2314
return - EOPNOTSUPP ;
2281
2315
}
2282
2316
2317
+ static inline int security_secctx_to_secid (char * secdata ,
2318
+ u32 seclen ,
2319
+ u32 * secid )
2320
+ {
2321
+ return - EOPNOTSUPP ;
2322
+ }
2323
+
2283
2324
static inline void security_release_secctx (char * secdata , u32 seclen )
2284
2325
{
2285
2326
}
0 commit comments