Skip to content

Commit 1d9d403

Browse files
committed
fixup! landlock/audit: Check for quiet flag in landlock_log_denial
1 parent 3e64227 commit 1d9d403

File tree

6 files changed

+29
-27
lines changed

6 files changed

+29
-27
lines changed

security/landlock/audit.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ static bool is_valid_request(const struct landlock_request *const request)
386386
*
387387
* @subject: The Landlock subject's credential denying an action.
388388
* @request: Detail of the user space request.
389-
* @rule_flags: The flags for the matched rule, or NULL if this is a
390-
* scope request (no particular object involved).
389+
* @rule_flags: The flags for the matched rule, or no_rule_flags (zero) if
390+
* this is a scope request (no particular object involved).
391391
*/
392392
void landlock_log_denial(const struct landlock_cred_security *const subject,
393393
const struct landlock_request *const request,
394-
const struct collected_rule_flags *const rule_flags)
394+
const struct collected_rule_flags rule_flags)
395395
{
396396
struct audit_buffer *ab;
397397
struct landlock_hierarchy *youngest_denied;
@@ -440,13 +440,12 @@ void landlock_log_denial(const struct landlock_cred_security *const subject,
440440
return;
441441

442442
/*
443-
* Check if the object is marked quiet by the layer that denied the
444-
* request. (If it's a different layer that marked it as quiet, but
443+
* Checks if the object is marked quiet by the layer that denied the
444+
* request. If it's a different layer that marked it as quiet, but
445445
* that layer is not the one that denied the request, we should still
446-
* audit log the denial)
446+
* audit log the denial.
447447
*/
448-
if (rule_flags &&
449-
rule_flags->quiet_masks & BIT(youngest_layer)) {
448+
if (rule_flags.quiet_masks & BIT(youngest_layer)) {
450449
return;
451450
}
452451

security/landlock/audit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void landlock_log_drop_domain(const struct landlock_hierarchy *const hierarchy);
5757

5858
void landlock_log_denial(const struct landlock_cred_security *const subject,
5959
const struct landlock_request *const request,
60-
const struct collected_rule_flags *const rule_flags);
60+
const struct collected_rule_flags rule_flags);
6161

6262
#else /* CONFIG_AUDIT */
6363

security/landlock/fs.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ static int current_check_access_path(const struct path *const path,
984984
NULL, 0, NULL, NULL, NULL, NULL))
985985
return 0;
986986

987-
landlock_log_denial(subject, &request, &rule_flags);
987+
landlock_log_denial(subject, &request, rule_flags);
988988
return -EACCES;
989989
}
990990

@@ -1194,7 +1194,7 @@ static int current_check_refer_path(struct dentry *const old_dentry,
11941194
&request1, NULL, 0, NULL, NULL, NULL, NULL))
11951195
return 0;
11961196

1197-
landlock_log_denial(subject, &request1, &rule_flags_parent1);
1197+
landlock_log_denial(subject, &request1, rule_flags_parent1);
11981198
return -EACCES;
11991199
}
12001200

@@ -1243,13 +1243,11 @@ static int current_check_refer_path(struct dentry *const old_dentry,
12431243

12441244
if (request1.access) {
12451245
request1.audit.u.path.dentry = old_parent;
1246-
landlock_log_denial(subject, &request1,
1247-
&rule_flags_parent1);
1246+
landlock_log_denial(subject, &request1, rule_flags_parent1);
12481247
}
12491248
if (request2.access) {
12501249
request2.audit.u.path.dentry = new_dir->dentry;
1251-
landlock_log_denial(subject, &request2,
1252-
&rule_flags_parent2);
1250+
landlock_log_denial(subject, &request2, rule_flags_parent2);
12531251
}
12541252

12551253
/*
@@ -1405,7 +1403,7 @@ log_fs_change_topology_path(const struct landlock_cred_security *const subject,
14051403
.u.path = *path,
14061404
},
14071405
.layer_plus_one = handle_layer + 1,
1408-
}, NULL);
1406+
}, no_rule_flags);
14091407
}
14101408

14111409
static void log_fs_change_topology_dentry(
@@ -1419,7 +1417,7 @@ static void log_fs_change_topology_dentry(
14191417
.u.dentry = dentry,
14201418
},
14211419
.layer_plus_one = handle_layer + 1,
1422-
}, NULL);
1420+
}, no_rule_flags);
14231421
}
14241422

14251423
/*
@@ -1707,7 +1705,7 @@ static int hook_file_open(struct file *const file)
17071705

17081706
/* Sets access to reflect the actual request. */
17091707
request.access = open_access_request;
1710-
landlock_log_denial(subject, &request, &rule_flags);
1708+
landlock_log_denial(subject, &request, rule_flags);
17111709
return -EACCES;
17121710
}
17131711

@@ -1737,7 +1735,7 @@ static int hook_file_truncate(struct file *const file)
17371735
#ifdef CONFIG_AUDIT
17381736
.deny_masks = landlock_file(file)->deny_masks,
17391737
#endif /* CONFIG_AUDIT */
1740-
}, NULL);
1738+
}, no_rule_flags);
17411739
return -EACCES;
17421740
}
17431741

@@ -1776,7 +1774,7 @@ static int hook_file_ioctl_common(const struct file *const file,
17761774
#ifdef CONFIG_AUDIT
17771775
.deny_masks = landlock_file(file)->deny_masks,
17781776
#endif /* CONFIG_AUDIT */
1779-
}, NULL);
1777+
}, no_rule_flags);
17801778
return -EACCES;
17811779
}
17821780

security/landlock/net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static int current_check_access_socket(struct socket *const sock,
194194
.layer_masks = &layer_masks,
195195
.layer_masks_size = ARRAY_SIZE(layer_masks),
196196
},
197-
&rule_flags);
197+
rule_flags);
198198
return -EACCES;
199199
}
200200

security/landlock/ruleset.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ struct collected_rule_flags {
5858
layer_mask_t quiet_masks;
5959
};
6060

61+
/**
62+
* no_rule_flags - Convenience constant for an empty collected_rule_flags
63+
*/
64+
static const struct collected_rule_flags no_rule_flags = { 0 };
65+
6166
/**
6267
* union landlock_key - Key of a ruleset's red-black tree
6368
*/

security/landlock/task.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static int hook_ptrace_access_check(struct task_struct *const child,
115115
.u.tsk = child,
116116
},
117117
.layer_plus_one = parent_subject->domain->num_layers,
118-
}, NULL);
118+
}, no_rule_flags);
119119

120120
return err;
121121
}
@@ -161,7 +161,7 @@ static int hook_ptrace_traceme(struct task_struct *const parent)
161161
.u.tsk = current,
162162
},
163163
.layer_plus_one = parent_subject->domain->num_layers,
164-
}, NULL);
164+
}, no_rule_flags);
165165
return err;
166166
}
167167

@@ -290,7 +290,7 @@ static int hook_unix_stream_connect(struct sock *const sock,
290290
},
291291
},
292292
.layer_plus_one = handle_layer + 1,
293-
}, NULL);
293+
}, no_rule_flags);
294294
return -EPERM;
295295
}
296296

@@ -327,7 +327,7 @@ static int hook_unix_may_send(struct socket *const sock,
327327
},
328328
},
329329
.layer_plus_one = handle_layer + 1,
330-
}, NULL);
330+
}, no_rule_flags);
331331
return -EPERM;
332332
}
333333

@@ -383,7 +383,7 @@ static int hook_task_kill(struct task_struct *const p,
383383
.u.tsk = p,
384384
},
385385
.layer_plus_one = handle_layer + 1,
386-
}, NULL);
386+
}, no_rule_flags);
387387
return -EPERM;
388388
}
389389

@@ -426,7 +426,7 @@ static int hook_file_send_sigiotask(struct task_struct *tsk,
426426
#ifdef CONFIG_AUDIT
427427
.layer_plus_one = landlock_file(fown->file)->fown_layer + 1,
428428
#endif /* CONFIG_AUDIT */
429-
}, NULL);
429+
}, no_rule_flags);
430430
return -EPERM;
431431
}
432432

0 commit comments

Comments
 (0)