Skip to content

Commit 3b805ca

Browse files
committed
Merge tag 'audit-pr-20191126' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit
Pull audit updates from Paul Moore: "Audit is back for v5.5, albeit with only two patches: - Allow for the auditing of suspicious O_CREAT usage via the new AUDIT_ANOM_CREAT record. - Remove a redundant if-conditional check found during code analysis. It's a minor change, but when the pull request is only two patches long, you need filler in the pull request email" [ Heh on the pull request filler. I wish more people tried to write better pull request messages, even if maybe it's not worth it for the trivial cases ;^) - Linus ] * tag 'audit-pr-20191126' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: audit: remove redundant condition check in kauditd_thread() audit: Report suspicious O_CREAT usage
2 parents ba75082 + c34c78d commit 3b805ca

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

fs/namei.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ static inline int may_follow_link(struct nameidata *nd)
925925
return -ECHILD;
926926

927927
audit_inode(nd->name, nd->stack[0].link.dentry, 0);
928-
audit_log_link_denied("follow_link");
928+
audit_log_path_denied(AUDIT_ANOM_LINK, "follow_link");
929929
return -EACCES;
930930
}
931931

@@ -993,7 +993,7 @@ static int may_linkat(struct path *link)
993993
if (safe_hardlink_source(inode) || inode_owner_or_capable(inode))
994994
return 0;
995995

996-
audit_log_link_denied("linkat");
996+
audit_log_path_denied(AUDIT_ANOM_LINK, "linkat");
997997
return -EPERM;
998998
}
999999

@@ -1031,6 +1031,10 @@ static int may_create_in_sticky(struct dentry * const dir,
10311031
(dir->d_inode->i_mode & 0020 &&
10321032
((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) ||
10331033
(sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) {
1034+
const char *operation = S_ISFIFO(inode->i_mode) ?
1035+
"sticky_create_fifo" :
1036+
"sticky_create_regular";
1037+
audit_log_path_denied(AUDIT_ANOM_CREAT, operation);
10341038
return -EACCES;
10351039
}
10361040
return 0;

include/linux/audit.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ extern void audit_log_d_path(struct audit_buffer *ab,
156156
const struct path *path);
157157
extern void audit_log_key(struct audit_buffer *ab,
158158
char *key);
159-
extern void audit_log_link_denied(const char *operation);
159+
extern void audit_log_path_denied(int type,
160+
const char *operation);
160161
extern void audit_log_lost(const char *message);
161162

162163
extern int audit_log_task_context(struct audit_buffer *ab);
@@ -217,7 +218,7 @@ static inline void audit_log_d_path(struct audit_buffer *ab,
217218
{ }
218219
static inline void audit_log_key(struct audit_buffer *ab, char *key)
219220
{ }
220-
static inline void audit_log_link_denied(const char *string)
221+
static inline void audit_log_path_denied(int type, const char *operation)
221222
{ }
222223
static inline int audit_log_task_context(struct audit_buffer *ab)
223224
{

include/uapi/linux/audit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
#define AUDIT_ANOM_PROMISCUOUS 1700 /* Device changed promiscuous mode */
144144
#define AUDIT_ANOM_ABEND 1701 /* Process ended abnormally */
145145
#define AUDIT_ANOM_LINK 1702 /* Suspicious use of file links */
146+
#define AUDIT_ANOM_CREAT 1703 /* Suspicious file creation */
146147
#define AUDIT_INTEGRITY_DATA 1800 /* Data integrity verification */
147148
#define AUDIT_INTEGRITY_METADATA 1801 /* Metadata integrity verification */
148149
#define AUDIT_INTEGRITY_STATUS 1802 /* Integrity enable status */

kernel/audit.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ static int kauditd_thread(void *dummy)
830830
rc = kauditd_send_queue(sk, portid,
831831
&audit_hold_queue, UNICAST_RETRIES,
832832
NULL, kauditd_rehold_skb);
833-
if (ac && rc < 0) {
833+
if (rc < 0) {
834834
sk = NULL;
835835
auditd_reset(ac);
836836
goto main_queue;
@@ -840,7 +840,7 @@ static int kauditd_thread(void *dummy)
840840
rc = kauditd_send_queue(sk, portid,
841841
&audit_retry_queue, UNICAST_RETRIES,
842842
NULL, kauditd_hold_skb);
843-
if (ac && rc < 0) {
843+
if (rc < 0) {
844844
sk = NULL;
845845
auditd_reset(ac);
846846
goto main_queue;
@@ -2155,18 +2155,19 @@ void audit_log_task_info(struct audit_buffer *ab)
21552155
EXPORT_SYMBOL(audit_log_task_info);
21562156

21572157
/**
2158-
* audit_log_link_denied - report a link restriction denial
2159-
* @operation: specific link operation
2158+
* audit_log_path_denied - report a path restriction denial
2159+
* @type: audit message type (AUDIT_ANOM_LINK, AUDIT_ANOM_CREAT, etc)
2160+
* @operation: specific operation name
21602161
*/
2161-
void audit_log_link_denied(const char *operation)
2162+
void audit_log_path_denied(int type, const char *operation)
21622163
{
21632164
struct audit_buffer *ab;
21642165

21652166
if (!audit_enabled || audit_dummy_context())
21662167
return;
21672168

2168-
/* Generate AUDIT_ANOM_LINK with subject, operation, outcome. */
2169-
ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_ANOM_LINK);
2169+
/* Generate log with subject, operation, outcome. */
2170+
ab = audit_log_start(audit_context(), GFP_KERNEL, type);
21702171
if (!ab)
21712172
return;
21722173
audit_log_format(ab, "op=%s", operation);

0 commit comments

Comments
 (0)