Skip to content

Commit

Permalink
audit: treat s_id as an untrusted string
Browse files Browse the repository at this point in the history
The use of s_id should go through the untrusted string path, just to be
extra careful.

Signed-off-by: Kees Cook <[email protected]>
Acked-by: Mimi Zohar <[email protected]>
Signed-off-by: Eric Paris <[email protected]>
  • Loading branch information
kees authored and Al Viro committed Jan 17, 2012
1 parent 5afb8a3 commit 41fdc30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
8 changes: 5 additions & 3 deletions security/integrity/ima/ima_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
audit_log_format(ab, " name=");
audit_log_untrustedstring(ab, fname);
}
if (inode)
audit_log_format(ab, " dev=%s ino=%lu",
inode->i_sb->s_id, inode->i_ino);
if (inode) {
audit_log_format(ab, " dev=");
audit_log_untrustedstring(ab, inode->i_sb->s_id);
audit_log_format(ab, " ino=%lu", inode->i_ino);
}
audit_log_format(ab, " res=%d", !result ? 0 : 1);
audit_log_end(ab);
}
23 changes: 13 additions & 10 deletions security/lsm_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,11 @@ static void dump_common_audit_data(struct audit_buffer *ab,
audit_log_d_path(ab, "path=", &a->u.path);

inode = a->u.path.dentry->d_inode;
if (inode)
audit_log_format(ab, " dev=%s ino=%lu",
inode->i_sb->s_id,
inode->i_ino);
if (inode) {
audit_log_format(ab, " dev=");
audit_log_untrustedstring(ab, inode->i_sb->s_id);
audit_log_format(ab, " ino=%lu", inode->i_ino);
}
break;
}
case LSM_AUDIT_DATA_DENTRY: {
Expand All @@ -248,10 +249,11 @@ static void dump_common_audit_data(struct audit_buffer *ab,
audit_log_untrustedstring(ab, a->u.dentry->d_name.name);

inode = a->u.dentry->d_inode;
if (inode)
audit_log_format(ab, " dev=%s ino=%lu",
inode->i_sb->s_id,
inode->i_ino);
if (inode) {
audit_log_format(ab, " dev=");
audit_log_untrustedstring(ab, inode->i_sb->s_id);
audit_log_format(ab, " ino=%lu", inode->i_ino);
}
break;
}
case LSM_AUDIT_DATA_INODE: {
Expand All @@ -266,8 +268,9 @@ static void dump_common_audit_data(struct audit_buffer *ab,
dentry->d_name.name);
dput(dentry);
}
audit_log_format(ab, " dev=%s ino=%lu", inode->i_sb->s_id,
inode->i_ino);
audit_log_format(ab, " dev=");
audit_log_untrustedstring(ab, inode->i_sb->s_id);
audit_log_format(ab, " ino=%lu", inode->i_ino);
break;
}
case LSM_AUDIT_DATA_TASK:
Expand Down

0 comments on commit 41fdc30

Please sign in to comment.