diff options
Diffstat (limited to 'security')
-rw-r--r-- | security/smack/smack_lsm.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 3410e3abd19b..7bcf9edf768d 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -1462,19 +1462,32 @@ static int smack_file_receive(struct file *file) | |||
1462 | /** | 1462 | /** |
1463 | * smack_file_open - Smack dentry open processing | 1463 | * smack_file_open - Smack dentry open processing |
1464 | * @file: the object | 1464 | * @file: the object |
1465 | * @cred: unused | 1465 | * @cred: task credential |
1466 | * | 1466 | * |
1467 | * Set the security blob in the file structure. | 1467 | * Set the security blob in the file structure. |
1468 | * Allow the open only if the task has read access. There are | ||
1469 | * many read operations (e.g. fstat) that you can do with an | ||
1470 | * fd even if you have the file open write-only. | ||
1468 | * | 1471 | * |
1469 | * Returns 0 | 1472 | * Returns 0 |
1470 | */ | 1473 | */ |
1471 | static int smack_file_open(struct file *file, const struct cred *cred) | 1474 | static int smack_file_open(struct file *file, const struct cred *cred) |
1472 | { | 1475 | { |
1476 | struct task_smack *tsp = cred->security; | ||
1473 | struct inode_smack *isp = file_inode(file)->i_security; | 1477 | struct inode_smack *isp = file_inode(file)->i_security; |
1478 | struct smk_audit_info ad; | ||
1479 | int rc; | ||
1474 | 1480 | ||
1475 | file->f_security = isp->smk_inode; | 1481 | if (smack_privileged(CAP_MAC_OVERRIDE)) |
1482 | return 0; | ||
1476 | 1483 | ||
1477 | return 0; | 1484 | smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); |
1485 | smk_ad_setfield_u_fs_path(&ad, file->f_path); | ||
1486 | rc = smk_access(tsp->smk_task, isp->smk_inode, MAY_READ, &ad); | ||
1487 | if (rc == 0) | ||
1488 | file->f_security = isp->smk_inode; | ||
1489 | |||
1490 | return rc; | ||
1478 | } | 1491 | } |
1479 | 1492 | ||
1480 | /* | 1493 | /* |