aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-12-28 09:27:07 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-01-25 23:16:27 -0500
commitf4a4a8b1252a08b60cde66a6622bbca4a7f4af2e (patch)
tree883f53870ed0ad1c9a3529e7cbfd009e2189e27f
parent5e9e2040247ac19a46d6627736ece726c46f1fdf (diff)
file->f_path.dentry is pinned down for as long as the file is open...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--kernel/auditsc.c5
-rw-r--r--security/commoncap.c6
2 files changed, 2 insertions, 9 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 072566dd0caf..55f82fce2526 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -2405,7 +2405,6 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
2405 struct audit_aux_data_bprm_fcaps *ax; 2405 struct audit_aux_data_bprm_fcaps *ax;
2406 struct audit_context *context = current->audit_context; 2406 struct audit_context *context = current->audit_context;
2407 struct cpu_vfs_cap_data vcaps; 2407 struct cpu_vfs_cap_data vcaps;
2408 struct dentry *dentry;
2409 2408
2410 ax = kmalloc(sizeof(*ax), GFP_KERNEL); 2409 ax = kmalloc(sizeof(*ax), GFP_KERNEL);
2411 if (!ax) 2410 if (!ax)
@@ -2415,9 +2414,7 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
2415 ax->d.next = context->aux; 2414 ax->d.next = context->aux;
2416 context->aux = (void *)ax; 2415 context->aux = (void *)ax;
2417 2416
2418 dentry = dget(bprm->file->f_path.dentry); 2417 get_vfs_caps_from_disk(bprm->file->f_path.dentry, &vcaps);
2419 get_vfs_caps_from_disk(dentry, &vcaps);
2420 dput(dentry);
2421 2418
2422 ax->fcap.permitted = vcaps.permitted; 2419 ax->fcap.permitted = vcaps.permitted;
2423 ax->fcap.inheritable = vcaps.inheritable; 2420 ax->fcap.inheritable = vcaps.inheritable;
diff --git a/security/commoncap.c b/security/commoncap.c
index 2915d8503054..f66713bd7450 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -434,7 +434,6 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
434 */ 434 */
435static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_cap) 435static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_cap)
436{ 436{
437 struct dentry *dentry;
438 int rc = 0; 437 int rc = 0;
439 struct cpu_vfs_cap_data vcaps; 438 struct cpu_vfs_cap_data vcaps;
440 439
@@ -446,9 +445,7 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
446 if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID) 445 if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)
447 return 0; 446 return 0;
448 447
449 dentry = dget(bprm->file->f_path.dentry); 448 rc = get_vfs_caps_from_disk(bprm->file->f_path.dentry, &vcaps);
450
451 rc = get_vfs_caps_from_disk(dentry, &vcaps);
452 if (rc < 0) { 449 if (rc < 0) {
453 if (rc == -EINVAL) 450 if (rc == -EINVAL)
454 printk(KERN_NOTICE "%s: get_vfs_caps_from_disk returned %d for %s\n", 451 printk(KERN_NOTICE "%s: get_vfs_caps_from_disk returned %d for %s\n",
@@ -464,7 +461,6 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
464 __func__, rc, bprm->filename); 461 __func__, rc, bprm->filename);
465 462
466out: 463out:
467 dput(dentry);
468 if (rc) 464 if (rc)
469 bprm_clear_caps(bprm); 465 bprm_clear_caps(bprm);
470 466