Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

landlock: Format with clang-format

Let's follow a consistent and documented coding style. Everything may
not be to our liking but it is better than tacit knowledge. Moreover,
this will help maintain style consistency between different developers.

This contains only whitespace changes.

Automatically formatted with:
clang-format-14 -i security/landlock/*.[ch] include/uapi/linux/landlock.h

Link: https://lore.kernel.org/r/20220506160513.523257-3-mic@digikod.net
Cc: stable@vger.kernel.org
Signed-off-by: Mickaël Salaün <mic@digikod.net>

+142 -136
+2 -2
security/landlock/cred.c
··· 15 15 #include "setup.h" 16 16 17 17 static int hook_cred_prepare(struct cred *const new, 18 - const struct cred *const old, const gfp_t gfp) 18 + const struct cred *const old, const gfp_t gfp) 19 19 { 20 20 struct landlock_ruleset *const old_dom = landlock_cred(old)->domain; 21 21 ··· 42 42 __init void landlock_add_cred_hooks(void) 43 43 { 44 44 security_add_hooks(landlock_hooks, ARRAY_SIZE(landlock_hooks), 45 - LANDLOCK_NAME); 45 + LANDLOCK_NAME); 46 46 }
+4 -4
security/landlock/cred.h
··· 20 20 struct landlock_ruleset *domain; 21 21 }; 22 22 23 - static inline struct landlock_cred_security *landlock_cred( 24 - const struct cred *cred) 23 + static inline struct landlock_cred_security * 24 + landlock_cred(const struct cred *cred) 25 25 { 26 26 return cred->security + landlock_blob_sizes.lbs_cred; 27 27 } ··· 34 34 /* 35 35 * The call needs to come from an RCU read-side critical section. 36 36 */ 37 - static inline const struct landlock_ruleset *landlock_get_task_domain( 38 - const struct task_struct *const task) 37 + static inline const struct landlock_ruleset * 38 + landlock_get_task_domain(const struct task_struct *const task) 39 39 { 40 40 return landlock_cred(__task_cred(task))->domain; 41 41 }
+40 -38
security/landlock/fs.c
··· 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 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; ··· 195 196 return layer_mask; 196 197 inode = d_backing_inode(path->dentry); 197 198 rcu_read_lock(); 198 - rule = landlock_find_rule(domain, 199 - rcu_dereference(landlock_inode(inode)->object)); 199 + rule = landlock_find_rule( 200 + domain, rcu_dereference(landlock_inode(inode)->object)); 200 201 rcu_read_unlock(); 201 202 if (!rule) 202 203 return layer_mask; ··· 224 225 } 225 226 226 227 static int check_access_path(const struct landlock_ruleset *const domain, 227 - const struct path *const path, u32 access_request) 228 + const struct path *const path, u32 access_request) 228 229 { 229 230 bool allowed = false; 230 231 struct path walker_path; ··· 244 245 * /proc/<pid>/fd/<file-descriptor> . 245 246 */ 246 247 if ((path->dentry->d_sb->s_flags & SB_NOUSER) || 247 - (d_is_positive(path->dentry) && 248 - unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))) 248 + (d_is_positive(path->dentry) && 249 + unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))) 249 250 return 0; 250 251 if (WARN_ON_ONCE(domain->num_layers < 1)) 251 252 return -EACCES; ··· 269 270 while (true) { 270 271 struct dentry *parent_dentry; 271 272 272 - layer_mask = unmask_layers(domain, &walker_path, 273 - access_request, layer_mask); 273 + layer_mask = unmask_layers(domain, &walker_path, access_request, 274 + layer_mask); 274 275 if (layer_mask == 0) { 275 276 /* Stops when a rule from each layer grants access. */ 276 277 allowed = true; ··· 309 310 } 310 311 311 312 static inline int current_check_access_path(const struct path *const path, 312 - const u32 access_request) 313 + const u32 access_request) 313 314 { 314 315 const struct landlock_ruleset *const dom = 315 316 landlock_get_current_domain(); ··· 437 438 if (prev_inode) 438 439 iput(prev_inode); 439 440 /* Waits for pending iput() in release_inode(). */ 440 - wait_var_event(&landlock_superblock(sb)->inode_refs, !atomic_long_read( 441 - &landlock_superblock(sb)->inode_refs)); 441 + wait_var_event(&landlock_superblock(sb)->inode_refs, 442 + !atomic_long_read(&landlock_superblock(sb)->inode_refs)); 442 443 } 443 444 444 445 /* ··· 460 461 * a dedicated user space option would be required (e.g. as a ruleset flag). 461 462 */ 462 463 static int hook_sb_mount(const char *const dev_name, 463 - const struct path *const path, const char *const type, 464 - const unsigned long flags, void *const data) 464 + const struct path *const path, const char *const type, 465 + const unsigned long flags, void *const data) 465 466 { 466 467 if (!landlock_get_current_domain()) 467 468 return 0; ··· 469 470 } 470 471 471 472 static int hook_move_mount(const struct path *const from_path, 472 - const struct path *const to_path) 473 + const struct path *const to_path) 473 474 { 474 475 if (!landlock_get_current_domain()) 475 476 return 0; ··· 503 504 * view of the filesystem. 504 505 */ 505 506 static int hook_sb_pivotroot(const struct path *const old_path, 506 - const struct path *const new_path) 507 + const struct path *const new_path) 507 508 { 508 509 if (!landlock_get_current_domain()) 509 510 return 0; ··· 546 547 * deal with that. 547 548 */ 548 549 static int hook_path_link(struct dentry *const old_dentry, 549 - const struct path *const new_dir, 550 - struct dentry *const new_dentry) 550 + const struct path *const new_dir, 551 + struct dentry *const new_dentry) 551 552 { 552 553 const struct landlock_ruleset *const dom = 553 554 landlock_get_current_domain(); ··· 560 561 return -EXDEV; 561 562 if (unlikely(d_is_negative(old_dentry))) 562 563 return -ENOENT; 563 - return check_access_path(dom, new_dir, 564 - get_mode_access(d_backing_inode(old_dentry)->i_mode)); 564 + return check_access_path( 565 + dom, new_dir, 566 + get_mode_access(d_backing_inode(old_dentry)->i_mode)); 565 567 } 566 568 567 569 static inline u32 maybe_remove(const struct dentry *const dentry) ··· 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 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(); ··· 615 614 } 616 615 617 616 static int hook_path_symlink(const struct path *const dir, 618 - struct dentry *const dentry, const char *const old_name) 617 + struct dentry *const dentry, 618 + const char *const old_name) 619 619 { 620 620 return current_check_access_path(dir, LANDLOCK_ACCESS_FS_MAKE_SYM); 621 621 } 622 622 623 623 static int hook_path_unlink(const struct path *const dir, 624 - struct dentry *const dentry) 624 + struct dentry *const dentry) 625 625 { 626 626 return current_check_access_path(dir, LANDLOCK_ACCESS_FS_REMOVE_FILE); 627 627 } 628 628 629 629 static int hook_path_rmdir(const struct path *const dir, 630 - struct dentry *const dentry) 630 + struct dentry *const dentry) 631 631 { 632 632 return current_check_access_path(dir, LANDLOCK_ACCESS_FS_REMOVE_DIR); 633 633 } ··· 692 690 __init void landlock_add_fs_hooks(void) 693 691 { 694 692 security_add_hooks(landlock_hooks, ARRAY_SIZE(landlock_hooks), 695 - LANDLOCK_NAME); 693 + LANDLOCK_NAME); 696 694 }
+6 -5
security/landlock/fs.h
··· 50 50 atomic_long_t inode_refs; 51 51 }; 52 52 53 - static inline struct landlock_inode_security *landlock_inode( 54 - const struct inode *const inode) 53 + static inline struct landlock_inode_security * 54 + landlock_inode(const struct inode *const inode) 55 55 { 56 56 return inode->i_security + landlock_blob_sizes.lbs_inode; 57 57 } 58 58 59 - static inline struct landlock_superblock_security *landlock_superblock( 60 - const struct super_block *const superblock) 59 + static inline struct landlock_superblock_security * 60 + landlock_superblock(const struct super_block *const superblock) 61 61 { 62 62 return superblock->s_security + landlock_blob_sizes.lbs_superblock; 63 63 } ··· 65 65 __init void landlock_add_fs_hooks(void); 66 66 67 67 int landlock_append_fs_rule(struct landlock_ruleset *const ruleset, 68 - const struct path *const path, u32 access_hierarchy); 68 + const struct path *const path, 69 + u32 access_hierarchy); 69 70 70 71 #endif /* _SECURITY_LANDLOCK_FS_H */
+3 -3
security/landlock/object.c
··· 17 17 18 18 #include "object.h" 19 19 20 - struct landlock_object *landlock_create_object( 21 - const struct landlock_object_underops *const underops, 22 - void *const underobj) 20 + struct landlock_object * 21 + landlock_create_object(const struct landlock_object_underops *const underops, 22 + void *const underobj) 23 23 { 24 24 struct landlock_object *new_object; 25 25
+3 -3
security/landlock/object.h
··· 76 76 }; 77 77 }; 78 78 79 - struct landlock_object *landlock_create_object( 80 - const struct landlock_object_underops *const underops, 81 - void *const underobj); 79 + struct landlock_object * 80 + landlock_create_object(const struct landlock_object_underops *const underops, 81 + void *const underobj); 82 82 83 83 void landlock_put_object(struct landlock_object *const object); 84 84
+5 -5
security/landlock/ptrace.c
··· 30 30 * means a subset of) the @child domain. 31 31 */ 32 32 static bool domain_scope_le(const struct landlock_ruleset *const parent, 33 - const struct landlock_ruleset *const child) 33 + const struct landlock_ruleset *const child) 34 34 { 35 35 const struct landlock_hierarchy *walker; 36 36 ··· 48 48 } 49 49 50 50 static bool task_is_scoped(const struct task_struct *const parent, 51 - const struct task_struct *const child) 51 + const struct task_struct *const child) 52 52 { 53 53 bool is_scoped; 54 54 const struct landlock_ruleset *dom_parent, *dom_child; ··· 62 62 } 63 63 64 64 static int task_ptrace(const struct task_struct *const parent, 65 - const struct task_struct *const child) 65 + const struct task_struct *const child) 66 66 { 67 67 /* Quick return for non-landlocked tasks. */ 68 68 if (!landlocked(parent)) ··· 86 86 * granted, -errno if denied. 87 87 */ 88 88 static int hook_ptrace_access_check(struct task_struct *const child, 89 - const unsigned int mode) 89 + const unsigned int mode) 90 90 { 91 91 return task_ptrace(current, child); 92 92 } ··· 116 116 __init void landlock_add_ptrace_hooks(void) 117 117 { 118 118 security_add_hooks(landlock_hooks, ARRAY_SIZE(landlock_hooks), 119 - LANDLOCK_NAME); 119 + LANDLOCK_NAME); 120 120 }
+40 -40
security/landlock/ruleset.c
··· 28 28 { 29 29 struct landlock_ruleset *new_ruleset; 30 30 31 - new_ruleset = kzalloc(struct_size(new_ruleset, fs_access_masks, 32 - num_layers), GFP_KERNEL_ACCOUNT); 31 + new_ruleset = 32 + kzalloc(struct_size(new_ruleset, fs_access_masks, num_layers), 33 + GFP_KERNEL_ACCOUNT); 33 34 if (!new_ruleset) 34 35 return ERR_PTR(-ENOMEM); 35 36 refcount_set(&new_ruleset->usage, 1); ··· 67 66 BUILD_BUG_ON(rule.num_layers < LANDLOCK_MAX_NUM_LAYERS); 68 67 } 69 68 70 - static struct landlock_rule *create_rule( 71 - struct landlock_object *const object, 72 - const struct landlock_layer (*const layers)[], 73 - const u32 num_layers, 74 - const struct landlock_layer *const new_layer) 69 + static struct landlock_rule * 70 + create_rule(struct landlock_object *const object, 71 + const struct landlock_layer (*const layers)[], const u32 num_layers, 72 + const struct landlock_layer *const new_layer) 75 73 { 76 74 struct landlock_rule *new_rule; 77 75 u32 new_num_layers; ··· 85 85 new_num_layers = num_layers; 86 86 } 87 87 new_rule = kzalloc(struct_size(new_rule, layers, new_num_layers), 88 - GFP_KERNEL_ACCOUNT); 88 + GFP_KERNEL_ACCOUNT); 89 89 if (!new_rule) 90 90 return ERR_PTR(-ENOMEM); 91 91 RB_CLEAR_NODE(&new_rule->node); ··· 94 94 new_rule->num_layers = new_num_layers; 95 95 /* Copies the original layer stack. */ 96 96 memcpy(new_rule->layers, layers, 97 - flex_array_size(new_rule, layers, num_layers)); 97 + flex_array_size(new_rule, layers, num_layers)); 98 98 if (new_layer) 99 99 /* Adds a copy of @new_layer on the layer stack. */ 100 100 new_rule->layers[new_rule->num_layers - 1] = *new_layer; ··· 142 142 * access rights. 143 143 */ 144 144 static int insert_rule(struct landlock_ruleset *const ruleset, 145 - struct landlock_object *const object, 146 - const struct landlock_layer (*const layers)[], 147 - size_t num_layers) 145 + struct landlock_object *const object, 146 + const struct landlock_layer (*const layers)[], 147 + size_t num_layers) 148 148 { 149 149 struct rb_node **walker_node; 150 150 struct rb_node *parent_node = NULL; ··· 156 156 return -ENOENT; 157 157 walker_node = &(ruleset->root.rb_node); 158 158 while (*walker_node) { 159 - struct landlock_rule *const this = rb_entry(*walker_node, 160 - struct landlock_rule, node); 159 + struct landlock_rule *const this = 160 + rb_entry(*walker_node, struct landlock_rule, node); 161 161 162 162 if (this->object != object) { 163 163 parent_node = *walker_node; ··· 194 194 * ruleset and a domain. 195 195 */ 196 196 new_rule = create_rule(object, &this->layers, this->num_layers, 197 - &(*layers)[0]); 197 + &(*layers)[0]); 198 198 if (IS_ERR(new_rule)) 199 199 return PTR_ERR(new_rule); 200 200 rb_replace_node(&this->node, &new_rule->node, &ruleset->root); ··· 228 228 229 229 /* @ruleset must be locked by the caller. */ 230 230 int landlock_insert_rule(struct landlock_ruleset *const ruleset, 231 - struct landlock_object *const object, const u32 access) 231 + struct landlock_object *const object, const u32 access) 232 232 { 233 - struct landlock_layer layers[] = {{ 233 + struct landlock_layer layers[] = { { 234 234 .access = access, 235 235 /* When @level is zero, insert_rule() extends @ruleset. */ 236 236 .level = 0, 237 - }}; 237 + } }; 238 238 239 239 build_check_layer(); 240 240 return insert_rule(ruleset, object, &layers, ARRAY_SIZE(layers)); ··· 257 257 } 258 258 259 259 static int merge_ruleset(struct landlock_ruleset *const dst, 260 - struct landlock_ruleset *const src) 260 + struct landlock_ruleset *const src) 261 261 { 262 262 struct landlock_rule *walker_rule, *next_rule; 263 263 int err = 0; ··· 282 282 dst->fs_access_masks[dst->num_layers - 1] = src->fs_access_masks[0]; 283 283 284 284 /* Merges the @src tree. */ 285 - rbtree_postorder_for_each_entry_safe(walker_rule, next_rule, 286 - &src->root, node) { 287 - struct landlock_layer layers[] = {{ 285 + rbtree_postorder_for_each_entry_safe(walker_rule, next_rule, &src->root, 286 + node) { 287 + struct landlock_layer layers[] = { { 288 288 .level = dst->num_layers, 289 - }}; 289 + } }; 290 290 291 291 if (WARN_ON_ONCE(walker_rule->num_layers != 1)) { 292 292 err = -EINVAL; ··· 298 298 } 299 299 layers[0].access = walker_rule->layers[0].access; 300 300 err = insert_rule(dst, walker_rule->object, &layers, 301 - ARRAY_SIZE(layers)); 301 + ARRAY_SIZE(layers)); 302 302 if (err) 303 303 goto out_unlock; 304 304 } ··· 310 310 } 311 311 312 312 static int inherit_ruleset(struct landlock_ruleset *const parent, 313 - struct landlock_ruleset *const child) 313 + struct landlock_ruleset *const child) 314 314 { 315 315 struct landlock_rule *walker_rule, *next_rule; 316 316 int err = 0; ··· 325 325 326 326 /* Copies the @parent tree. */ 327 327 rbtree_postorder_for_each_entry_safe(walker_rule, next_rule, 328 - &parent->root, node) { 328 + &parent->root, node) { 329 329 err = insert_rule(child, walker_rule->object, 330 - &walker_rule->layers, walker_rule->num_layers); 330 + &walker_rule->layers, 331 + walker_rule->num_layers); 331 332 if (err) 332 333 goto out_unlock; 333 334 } ··· 339 338 } 340 339 /* Copies the parent layer stack and leaves a space for the new layer. */ 341 340 memcpy(child->fs_access_masks, parent->fs_access_masks, 342 - flex_array_size(parent, fs_access_masks, parent->num_layers)); 341 + flex_array_size(parent, fs_access_masks, parent->num_layers)); 343 342 344 343 if (WARN_ON_ONCE(!parent->hierarchy)) { 345 344 err = -EINVAL; ··· 359 358 struct landlock_rule *freeme, *next; 360 359 361 360 might_sleep(); 362 - rbtree_postorder_for_each_entry_safe(freeme, next, &ruleset->root, 363 - node) 361 + rbtree_postorder_for_each_entry_safe(freeme, next, &ruleset->root, node) 364 362 free_rule(freeme); 365 363 put_hierarchy(ruleset->hierarchy); 366 364 kfree(ruleset); ··· 397 397 * Returns the intersection of @parent and @ruleset, or returns @parent if 398 398 * @ruleset is empty, or returns a duplicate of @ruleset if @parent is empty. 399 399 */ 400 - struct landlock_ruleset *landlock_merge_ruleset( 401 - struct landlock_ruleset *const parent, 402 - struct landlock_ruleset *const ruleset) 400 + struct landlock_ruleset * 401 + landlock_merge_ruleset(struct landlock_ruleset *const parent, 402 + struct landlock_ruleset *const ruleset) 403 403 { 404 404 struct landlock_ruleset *new_dom; 405 405 u32 num_layers; ··· 421 421 new_dom = create_ruleset(num_layers); 422 422 if (IS_ERR(new_dom)) 423 423 return new_dom; 424 - new_dom->hierarchy = kzalloc(sizeof(*new_dom->hierarchy), 425 - GFP_KERNEL_ACCOUNT); 424 + new_dom->hierarchy = 425 + kzalloc(sizeof(*new_dom->hierarchy), GFP_KERNEL_ACCOUNT); 426 426 if (!new_dom->hierarchy) { 427 427 err = -ENOMEM; 428 428 goto out_put_dom; ··· 449 449 /* 450 450 * The returned access has the same lifetime as @ruleset. 451 451 */ 452 - const struct landlock_rule *landlock_find_rule( 453 - const struct landlock_ruleset *const ruleset, 454 - const struct landlock_object *const object) 452 + const struct landlock_rule * 453 + landlock_find_rule(const struct landlock_ruleset *const ruleset, 454 + const struct landlock_object *const object) 455 455 { 456 456 const struct rb_node *node; 457 457 ··· 459 459 return NULL; 460 460 node = ruleset->root.rb_node; 461 461 while (node) { 462 - struct landlock_rule *this = rb_entry(node, 463 - struct landlock_rule, node); 462 + struct landlock_rule *this = 463 + rb_entry(node, struct landlock_rule, node); 464 464 465 465 if (this->object == object) 466 466 return this;
+8 -7
security/landlock/ruleset.h
··· 146 146 void landlock_put_ruleset_deferred(struct landlock_ruleset *const ruleset); 147 147 148 148 int landlock_insert_rule(struct landlock_ruleset *const ruleset, 149 - struct landlock_object *const object, const u32 access); 149 + struct landlock_object *const object, 150 + const u32 access); 150 151 151 - struct landlock_ruleset *landlock_merge_ruleset( 152 - struct landlock_ruleset *const parent, 153 - struct landlock_ruleset *const ruleset); 152 + struct landlock_ruleset * 153 + landlock_merge_ruleset(struct landlock_ruleset *const parent, 154 + struct landlock_ruleset *const ruleset); 154 155 155 - const struct landlock_rule *landlock_find_rule( 156 - const struct landlock_ruleset *const ruleset, 157 - const struct landlock_object *const object); 156 + const struct landlock_rule * 157 + landlock_find_rule(const struct landlock_ruleset *const ruleset, 158 + const struct landlock_object *const object); 158 159 159 160 static inline void landlock_get_ruleset(struct landlock_ruleset *const ruleset) 160 161 {
+31 -29
security/landlock/syscalls.c
··· 43 43 * @src: User space pointer or NULL. 44 44 * @usize: (Alleged) size of the data pointed to by @src. 45 45 */ 46 - static __always_inline int copy_min_struct_from_user(void *const dst, 47 - const size_t ksize, const size_t ksize_min, 48 - const void __user *const src, const size_t usize) 46 + static __always_inline int 47 + copy_min_struct_from_user(void *const dst, const size_t ksize, 48 + const size_t ksize_min, const void __user *const src, 49 + const size_t usize) 49 50 { 50 51 /* Checks buffer inconsistencies. */ 51 52 BUILD_BUG_ON(!dst); ··· 94 93 /* Ruleset handling */ 95 94 96 95 static int fop_ruleset_release(struct inode *const inode, 97 - struct file *const filp) 96 + struct file *const filp) 98 97 { 99 98 struct landlock_ruleset *ruleset = filp->private_data; 100 99 ··· 103 102 } 104 103 105 104 static ssize_t fop_dummy_read(struct file *const filp, char __user *const buf, 106 - const size_t size, loff_t *const ppos) 105 + const size_t size, loff_t *const ppos) 107 106 { 108 107 /* Dummy handler to enable FMODE_CAN_READ. */ 109 108 return -EINVAL; 110 109 } 111 110 112 111 static ssize_t fop_dummy_write(struct file *const filp, 113 - const char __user *const buf, const size_t size, 114 - loff_t *const ppos) 112 + const char __user *const buf, const size_t size, 113 + loff_t *const ppos) 115 114 { 116 115 /* Dummy handler to enable FMODE_CAN_WRITE. */ 117 116 return -EINVAL; ··· 129 128 .write = fop_dummy_write, 130 129 }; 131 130 132 - #define LANDLOCK_ABI_VERSION 1 131 + #define LANDLOCK_ABI_VERSION 1 133 132 134 133 /** 135 134 * sys_landlock_create_ruleset - Create a new ruleset ··· 169 168 return -EOPNOTSUPP; 170 169 171 170 if (flags) { 172 - if ((flags == LANDLOCK_CREATE_RULESET_VERSION) 173 - && !attr && !size) 171 + if ((flags == LANDLOCK_CREATE_RULESET_VERSION) && !attr && 172 + !size) 174 173 return LANDLOCK_ABI_VERSION; 175 174 return -EINVAL; 176 175 } 177 176 178 177 /* Copies raw user space buffer. */ 179 178 err = copy_min_struct_from_user(&ruleset_attr, sizeof(ruleset_attr), 180 - offsetofend(typeof(ruleset_attr), handled_access_fs), 181 - attr, size); 179 + offsetofend(typeof(ruleset_attr), 180 + handled_access_fs), 181 + attr, size); 182 182 if (err) 183 183 return err; 184 184 185 185 /* Checks content (and 32-bits cast). */ 186 186 if ((ruleset_attr.handled_access_fs | LANDLOCK_MASK_ACCESS_FS) != 187 - LANDLOCK_MASK_ACCESS_FS) 187 + LANDLOCK_MASK_ACCESS_FS) 188 188 return -EINVAL; 189 189 190 190 /* Checks arguments and transforms to kernel struct. */ ··· 195 193 196 194 /* Creates anonymous FD referring to the ruleset. */ 197 195 ruleset_fd = anon_inode_getfd("[landlock-ruleset]", &ruleset_fops, 198 - ruleset, O_RDWR | O_CLOEXEC); 196 + ruleset, O_RDWR | O_CLOEXEC); 199 197 if (ruleset_fd < 0) 200 198 landlock_put_ruleset(ruleset); 201 199 return ruleset_fd; ··· 206 204 * landlock_put_ruleset() on the return value. 207 205 */ 208 206 static struct landlock_ruleset *get_ruleset_from_fd(const int fd, 209 - const fmode_t mode) 207 + const fmode_t mode) 210 208 { 211 209 struct fd ruleset_f; 212 210 struct landlock_ruleset *ruleset; ··· 246 244 struct fd f; 247 245 int err = 0; 248 246 249 - BUILD_BUG_ON(!__same_type(fd, 250 - ((struct landlock_path_beneath_attr *)NULL)->parent_fd)); 247 + BUILD_BUG_ON(!__same_type( 248 + fd, ((struct landlock_path_beneath_attr *)NULL)->parent_fd)); 251 249 252 250 /* Handles O_PATH. */ 253 251 f = fdget_raw(fd); ··· 259 257 * pipefs). 260 258 */ 261 259 if ((f.file->f_op == &ruleset_fops) || 262 - (f.file->f_path.mnt->mnt_flags & MNT_INTERNAL) || 263 - (f.file->f_path.dentry->d_sb->s_flags & SB_NOUSER) || 264 - d_is_negative(f.file->f_path.dentry) || 265 - IS_PRIVATE(d_backing_inode(f.file->f_path.dentry))) { 260 + (f.file->f_path.mnt->mnt_flags & MNT_INTERNAL) || 261 + (f.file->f_path.dentry->d_sb->s_flags & SB_NOUSER) || 262 + d_is_negative(f.file->f_path.dentry) || 263 + IS_PRIVATE(d_backing_inode(f.file->f_path.dentry))) { 266 264 err = -EBADFD; 267 265 goto out_fdput; 268 266 } ··· 303 301 * - EPERM: @ruleset_fd has no write access to the underlying ruleset; 304 302 * - EFAULT: @rule_attr inconsistency. 305 303 */ 306 - SYSCALL_DEFINE4(landlock_add_rule, 307 - const int, ruleset_fd, const enum landlock_rule_type, rule_type, 304 + SYSCALL_DEFINE4(landlock_add_rule, const int, ruleset_fd, 305 + const enum landlock_rule_type, rule_type, 308 306 const void __user *const, rule_attr, const __u32, flags) 309 307 { 310 308 struct landlock_path_beneath_attr path_beneath_attr; ··· 324 322 325 323 /* Copies raw user space buffer, only one type for now. */ 326 324 res = copy_from_user(&path_beneath_attr, rule_attr, 327 - sizeof(path_beneath_attr)); 325 + sizeof(path_beneath_attr)); 328 326 if (res) 329 327 return -EFAULT; 330 328 ··· 346 344 * (ruleset->fs_access_masks[0] is automatically upgraded to 64-bits). 347 345 */ 348 346 if ((path_beneath_attr.allowed_access | ruleset->fs_access_masks[0]) != 349 - ruleset->fs_access_masks[0]) { 347 + ruleset->fs_access_masks[0]) { 350 348 err = -EINVAL; 351 349 goto out_put_ruleset; 352 350 } ··· 358 356 359 357 /* Imports the new rule. */ 360 358 err = landlock_append_fs_rule(ruleset, &path, 361 - path_beneath_attr.allowed_access); 359 + path_beneath_attr.allowed_access); 362 360 path_put(&path); 363 361 364 362 out_put_ruleset: ··· 391 389 * - E2BIG: The maximum number of stacked rulesets is reached for the current 392 390 * thread. 393 391 */ 394 - SYSCALL_DEFINE2(landlock_restrict_self, 395 - const int, ruleset_fd, const __u32, flags) 392 + SYSCALL_DEFINE2(landlock_restrict_self, const int, ruleset_fd, const __u32, 393 + flags) 396 394 { 397 395 struct landlock_ruleset *new_dom, *ruleset; 398 396 struct cred *new_cred; ··· 411 409 * returned. 412 410 */ 413 411 if (!task_no_new_privs(current) && 414 - !ns_capable_noaudit(current_user_ns(), CAP_SYS_ADMIN)) 412 + !ns_capable_noaudit(current_user_ns(), CAP_SYS_ADMIN)) 415 413 return -EPERM; 416 414 417 415 /* Gets and checks the ruleset. */