diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/audit.c | 12 | ||||
-rw-r--r-- | kernel/auditsc.c | 28 |
2 files changed, 17 insertions, 23 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index c8555b180213..783e65701247 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -1312,26 +1312,26 @@ void audit_log_untrustedstring(struct audit_buffer *ab, const char *string) | |||
1312 | 1312 | ||
1313 | /* This is a helper-function to print the escaped d_path */ | 1313 | /* This is a helper-function to print the escaped d_path */ |
1314 | void audit_log_d_path(struct audit_buffer *ab, const char *prefix, | 1314 | void audit_log_d_path(struct audit_buffer *ab, const char *prefix, |
1315 | struct dentry *dentry, struct vfsmount *vfsmnt) | 1315 | struct path *path) |
1316 | { | 1316 | { |
1317 | char *p, *path; | 1317 | char *p, *pathname; |
1318 | 1318 | ||
1319 | if (prefix) | 1319 | if (prefix) |
1320 | audit_log_format(ab, " %s", prefix); | 1320 | audit_log_format(ab, " %s", prefix); |
1321 | 1321 | ||
1322 | /* We will allow 11 spaces for ' (deleted)' to be appended */ | 1322 | /* We will allow 11 spaces for ' (deleted)' to be appended */ |
1323 | path = kmalloc(PATH_MAX+11, ab->gfp_mask); | 1323 | pathname = kmalloc(PATH_MAX+11, ab->gfp_mask); |
1324 | if (!path) { | 1324 | if (!pathname) { |
1325 | audit_log_format(ab, "<no memory>"); | 1325 | audit_log_format(ab, "<no memory>"); |
1326 | return; | 1326 | return; |
1327 | } | 1327 | } |
1328 | p = d_path(dentry, vfsmnt, path, PATH_MAX+11); | 1328 | p = d_path(path->dentry, path->mnt, pathname, PATH_MAX+11); |
1329 | if (IS_ERR(p)) { /* Should never happen since we send PATH_MAX */ | 1329 | if (IS_ERR(p)) { /* Should never happen since we send PATH_MAX */ |
1330 | /* FIXME: can we save some information here? */ | 1330 | /* FIXME: can we save some information here? */ |
1331 | audit_log_format(ab, "<too long>"); | 1331 | audit_log_format(ab, "<too long>"); |
1332 | } else | 1332 | } else |
1333 | audit_log_untrustedstring(ab, p); | 1333 | audit_log_untrustedstring(ab, p); |
1334 | kfree(path); | 1334 | kfree(pathname); |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | /** | 1337 | /** |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 741291a1de0d..ac6d9b23b018 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -208,8 +208,7 @@ struct audit_context { | |||
208 | int name_count; | 208 | int name_count; |
209 | struct audit_names names[AUDIT_NAMES]; | 209 | struct audit_names names[AUDIT_NAMES]; |
210 | char * filterkey; /* key for rule that triggered record */ | 210 | char * filterkey; /* key for rule that triggered record */ |
211 | struct dentry * pwd; | 211 | struct path pwd; |
212 | struct vfsmount * pwdmnt; | ||
213 | struct audit_context *previous; /* For nested syscalls */ | 212 | struct audit_context *previous; /* For nested syscalls */ |
214 | struct audit_aux_data *aux; | 213 | struct audit_aux_data *aux; |
215 | struct audit_aux_data *aux_pids; | 214 | struct audit_aux_data *aux_pids; |
@@ -786,12 +785,9 @@ static inline void audit_free_names(struct audit_context *context) | |||
786 | __putname(context->names[i].name); | 785 | __putname(context->names[i].name); |
787 | } | 786 | } |
788 | context->name_count = 0; | 787 | context->name_count = 0; |
789 | if (context->pwd) | 788 | path_put(&context->pwd); |
790 | dput(context->pwd); | 789 | context->pwd.dentry = NULL; |
791 | if (context->pwdmnt) | 790 | context->pwd.mnt = NULL; |
792 | mntput(context->pwdmnt); | ||
793 | context->pwd = NULL; | ||
794 | context->pwdmnt = NULL; | ||
795 | } | 791 | } |
796 | 792 | ||
797 | static inline void audit_free_aux(struct audit_context *context) | 793 | static inline void audit_free_aux(struct audit_context *context) |
@@ -930,8 +926,7 @@ static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk | |||
930 | if ((vma->vm_flags & VM_EXECUTABLE) && | 926 | if ((vma->vm_flags & VM_EXECUTABLE) && |
931 | vma->vm_file) { | 927 | vma->vm_file) { |
932 | audit_log_d_path(ab, "exe=", | 928 | audit_log_d_path(ab, "exe=", |
933 | vma->vm_file->f_path.dentry, | 929 | &vma->vm_file->f_path); |
934 | vma->vm_file->f_path.mnt); | ||
935 | break; | 930 | break; |
936 | } | 931 | } |
937 | vma = vma->vm_next; | 932 | vma = vma->vm_next; |
@@ -1341,10 +1336,10 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1341 | context->target_sid, context->target_comm)) | 1336 | context->target_sid, context->target_comm)) |
1342 | call_panic = 1; | 1337 | call_panic = 1; |
1343 | 1338 | ||
1344 | if (context->pwd && context->pwdmnt) { | 1339 | if (context->pwd.dentry && context->pwd.mnt) { |
1345 | ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD); | 1340 | ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD); |
1346 | if (ab) { | 1341 | if (ab) { |
1347 | audit_log_d_path(ab, "cwd=", context->pwd, context->pwdmnt); | 1342 | audit_log_d_path(ab, "cwd=", &context->pwd); |
1348 | audit_log_end(ab); | 1343 | audit_log_end(ab); |
1349 | } | 1344 | } |
1350 | } | 1345 | } |
@@ -1367,8 +1362,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1367 | case 0: | 1362 | case 0: |
1368 | /* name was specified as a relative path and the | 1363 | /* name was specified as a relative path and the |
1369 | * directory component is the cwd */ | 1364 | * directory component is the cwd */ |
1370 | audit_log_d_path(ab, " name=", context->pwd, | 1365 | audit_log_d_path(ab, " name=", &context->pwd); |
1371 | context->pwdmnt); | ||
1372 | break; | 1366 | break; |
1373 | default: | 1367 | default: |
1374 | /* log the name's directory component */ | 1368 | /* log the name's directory component */ |
@@ -1695,10 +1689,10 @@ void __audit_getname(const char *name) | |||
1695 | context->names[context->name_count].ino = (unsigned long)-1; | 1689 | context->names[context->name_count].ino = (unsigned long)-1; |
1696 | context->names[context->name_count].osid = 0; | 1690 | context->names[context->name_count].osid = 0; |
1697 | ++context->name_count; | 1691 | ++context->name_count; |
1698 | if (!context->pwd) { | 1692 | if (!context->pwd.dentry) { |
1699 | read_lock(¤t->fs->lock); | 1693 | read_lock(¤t->fs->lock); |
1700 | context->pwd = dget(current->fs->pwd.dentry); | 1694 | context->pwd = current->fs->pwd; |
1701 | context->pwdmnt = mntget(current->fs->pwd.mnt); | 1695 | path_get(¤t->fs->pwd); |
1702 | read_unlock(¤t->fs->lock); | 1696 | read_unlock(¤t->fs->lock); |
1703 | } | 1697 | } |
1704 | 1698 | ||