@@ -152,14 +152,14 @@ static struct landlock_object *get_inode_object(struct inode *const inode)
152
152
* @path: Should have been checked by get_path_from_fd().
153
153
*/
154
154
int landlock_append_fs_rule (struct landlock_ruleset * const ruleset ,
155
- const struct path * const path , u32 access_rights )
155
+ const struct path * const path , u32 access_rights )
156
156
{
157
157
int err ;
158
158
struct landlock_object * object ;
159
159
160
160
/* Files only get access rights that make sense. */
161
- if (!d_is_dir (path -> dentry ) && ( access_rights | ACCESS_FILE ) !=
162
- ACCESS_FILE )
161
+ if (!d_is_dir (path -> dentry ) &&
162
+ ( access_rights | ACCESS_FILE ) != ACCESS_FILE )
163
163
return - EINVAL ;
164
164
if (WARN_ON_ONCE (ruleset -> num_layers != 1 ))
165
165
return - EINVAL ;
@@ -182,10 +182,9 @@ int landlock_append_fs_rule(struct landlock_ruleset *const ruleset,
182
182
183
183
/* Access-control management */
184
184
185
- static inline u64 unmask_layers (
186
- const struct landlock_ruleset * const domain ,
187
- const struct path * const path , const u32 access_request ,
188
- u64 layer_mask )
185
+ static inline u64 unmask_layers (const struct landlock_ruleset * const domain ,
186
+ const struct path * const path ,
187
+ const u32 access_request , u64 layer_mask )
189
188
{
190
189
const struct landlock_rule * rule ;
191
190
const struct inode * inode ;
@@ -196,8 +195,8 @@ static inline u64 unmask_layers(
196
195
return layer_mask ;
197
196
inode = d_backing_inode (path -> dentry );
198
197
rcu_read_lock ();
199
- rule = landlock_find_rule (domain ,
200
- rcu_dereference (landlock_inode (inode )-> object ));
198
+ rule = landlock_find_rule (
199
+ domain , rcu_dereference (landlock_inode (inode )-> object ));
201
200
rcu_read_unlock ();
202
201
if (!rule )
203
202
return layer_mask ;
@@ -225,7 +224,7 @@ static inline u64 unmask_layers(
225
224
}
226
225
227
226
static int check_access_path (const struct landlock_ruleset * const domain ,
228
- const struct path * const path , u32 access_request )
227
+ const struct path * const path , u32 access_request )
229
228
{
230
229
bool allowed = false;
231
230
struct path walker_path ;
@@ -245,8 +244,8 @@ static int check_access_path(const struct landlock_ruleset *const domain,
245
244
* /proc/<pid>/fd/<file-descriptor> .
246
245
*/
247
246
if ((path -> dentry -> d_sb -> s_flags & SB_NOUSER ) ||
248
- (d_is_positive (path -> dentry ) &&
249
- unlikely (IS_PRIVATE (d_backing_inode (path -> dentry )))))
247
+ (d_is_positive (path -> dentry ) &&
248
+ unlikely (IS_PRIVATE (d_backing_inode (path -> dentry )))))
250
249
return 0 ;
251
250
if (WARN_ON_ONCE (domain -> num_layers < 1 ))
252
251
return - EACCES ;
@@ -270,8 +269,8 @@ static int check_access_path(const struct landlock_ruleset *const domain,
270
269
while (true) {
271
270
struct dentry * parent_dentry ;
272
271
273
- layer_mask = unmask_layers (domain , & walker_path ,
274
- access_request , layer_mask );
272
+ layer_mask = unmask_layers (domain , & walker_path , access_request ,
273
+ layer_mask );
275
274
if (layer_mask == 0 ) {
276
275
/* Stops when a rule from each layer grants access. */
277
276
allowed = true;
@@ -310,7 +309,7 @@ static int check_access_path(const struct landlock_ruleset *const domain,
310
309
}
311
310
312
311
static inline int current_check_access_path (const struct path * const path ,
313
- const u32 access_request )
312
+ const u32 access_request )
314
313
{
315
314
const struct landlock_ruleset * const dom =
316
315
landlock_get_current_domain ();
@@ -438,8 +437,8 @@ static void hook_sb_delete(struct super_block *const sb)
438
437
if (prev_inode )
439
438
iput (prev_inode );
440
439
/* Waits for pending iput() in release_inode(). */
441
- wait_var_event (& landlock_superblock (sb )-> inode_refs , ! atomic_long_read (
442
- & landlock_superblock (sb )-> inode_refs ));
440
+ wait_var_event (& landlock_superblock (sb )-> inode_refs ,
441
+ ! atomic_long_read ( & landlock_superblock (sb )-> inode_refs ));
443
442
}
444
443
445
444
/*
@@ -461,16 +460,16 @@ static void hook_sb_delete(struct super_block *const sb)
461
460
* a dedicated user space option would be required (e.g. as a ruleset flag).
462
461
*/
463
462
static int hook_sb_mount (const char * const dev_name ,
464
- const struct path * const path , const char * const type ,
465
- const unsigned long flags , void * const data )
463
+ const struct path * const path , const char * const type ,
464
+ const unsigned long flags , void * const data )
466
465
{
467
466
if (!landlock_get_current_domain ())
468
467
return 0 ;
469
468
return - EPERM ;
470
469
}
471
470
472
471
static int hook_move_mount (const struct path * const from_path ,
473
- const struct path * const to_path )
472
+ const struct path * const to_path )
474
473
{
475
474
if (!landlock_get_current_domain ())
476
475
return 0 ;
@@ -504,7 +503,7 @@ static int hook_sb_remount(struct super_block *const sb, void *const mnt_opts)
504
503
* view of the filesystem.
505
504
*/
506
505
static int hook_sb_pivotroot (const struct path * const old_path ,
507
- const struct path * const new_path )
506
+ const struct path * const new_path )
508
507
{
509
508
if (!landlock_get_current_domain ())
510
509
return 0 ;
@@ -547,8 +546,8 @@ static inline u32 get_mode_access(const umode_t mode)
547
546
* deal with that.
548
547
*/
549
548
static int hook_path_link (struct dentry * const old_dentry ,
550
- const struct path * const new_dir ,
551
- struct dentry * const new_dentry )
549
+ const struct path * const new_dir ,
550
+ struct dentry * const new_dentry )
552
551
{
553
552
const struct landlock_ruleset * const dom =
554
553
landlock_get_current_domain ();
@@ -561,22 +560,23 @@ static int hook_path_link(struct dentry *const old_dentry,
561
560
return - EXDEV ;
562
561
if (unlikely (d_is_negative (old_dentry )))
563
562
return - ENOENT ;
564
- return check_access_path (dom , new_dir ,
565
- get_mode_access (d_backing_inode (old_dentry )-> i_mode ));
563
+ return check_access_path (
564
+ dom , new_dir ,
565
+ get_mode_access (d_backing_inode (old_dentry )-> i_mode ));
566
566
}
567
567
568
568
static inline u32 maybe_remove (const struct dentry * const dentry )
569
569
{
570
570
if (d_is_negative (dentry ))
571
571
return 0 ;
572
572
return d_is_dir (dentry ) ? LANDLOCK_ACCESS_FS_REMOVE_DIR :
573
- LANDLOCK_ACCESS_FS_REMOVE_FILE ;
573
+ LANDLOCK_ACCESS_FS_REMOVE_FILE ;
574
574
}
575
575
576
576
static int hook_path_rename (const struct path * const old_dir ,
577
- struct dentry * const old_dentry ,
578
- const struct path * const new_dir ,
579
- struct dentry * const new_dentry )
577
+ struct dentry * const old_dentry ,
578
+ const struct path * const new_dir ,
579
+ struct dentry * const new_dentry )
580
580
{
581
581
const struct landlock_ruleset * const dom =
582
582
landlock_get_current_domain ();
@@ -590,20 +590,21 @@ static int hook_path_rename(const struct path *const old_dir,
590
590
if (unlikely (d_is_negative (old_dentry )))
591
591
return - ENOENT ;
592
592
/* RENAME_EXCHANGE is handled because directories are the same. */
593
- return check_access_path (dom , old_dir , maybe_remove (old_dentry ) |
594
- maybe_remove (new_dentry ) |
593
+ return check_access_path (
594
+ dom , old_dir ,
595
+ maybe_remove (old_dentry ) | maybe_remove (new_dentry ) |
595
596
get_mode_access (d_backing_inode (old_dentry )-> i_mode ));
596
597
}
597
598
598
599
static int hook_path_mkdir (const struct path * const dir ,
599
- struct dentry * const dentry , const umode_t mode )
600
+ struct dentry * const dentry , const umode_t mode )
600
601
{
601
602
return current_check_access_path (dir , LANDLOCK_ACCESS_FS_MAKE_DIR );
602
603
}
603
604
604
605
static int hook_path_mknod (const struct path * const dir ,
605
- struct dentry * const dentry , const umode_t mode ,
606
- const unsigned int dev )
606
+ struct dentry * const dentry , const umode_t mode ,
607
+ const unsigned int dev )
607
608
{
608
609
const struct landlock_ruleset * const dom =
609
610
landlock_get_current_domain ();
@@ -614,19 +615,20 @@ static int hook_path_mknod(const struct path *const dir,
614
615
}
615
616
616
617
static int hook_path_symlink (const struct path * const dir ,
617
- struct dentry * const dentry , const char * const old_name )
618
+ struct dentry * const dentry ,
619
+ const char * const old_name )
618
620
{
619
621
return current_check_access_path (dir , LANDLOCK_ACCESS_FS_MAKE_SYM );
620
622
}
621
623
622
624
static int hook_path_unlink (const struct path * const dir ,
623
- struct dentry * const dentry )
625
+ struct dentry * const dentry )
624
626
{
625
627
return current_check_access_path (dir , LANDLOCK_ACCESS_FS_REMOVE_FILE );
626
628
}
627
629
628
630
static int hook_path_rmdir (const struct path * const dir ,
629
- struct dentry * const dentry )
631
+ struct dentry * const dentry )
630
632
{
631
633
return current_check_access_path (dir , LANDLOCK_ACCESS_FS_REMOVE_DIR );
632
634
}
@@ -690,5 +692,5 @@ static struct security_hook_list landlock_hooks[] __lsm_ro_after_init = {
690
692
__init void landlock_add_fs_hooks (void )
691
693
{
692
694
security_add_hooks (landlock_hooks , ARRAY_SIZE (landlock_hooks ),
693
- LANDLOCK_NAME );
695
+ LANDLOCK_NAME );
694
696
}
0 commit comments