[RFC PATCH v1 6/7] smack: Fix inode numbers in logs

Mickaël Salaün
2024-10-10T15:27:10Z

Use the new inode_get_ino() helper to log the user space's view of
inode's numbers instead of the private kernel values.

Cc: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Mickaël Salaün <mic@digikod.net>
---
security/smack/smack_lsm.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 370fd594da12..0be7e442e70f 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -199,8 +199,8 @@ static int smk_bu_inode(struct inode *inode, int mode, int rc)
char acc[SMK_NUM_ACCESS_TYPE + 1];

if (isp->smk_flags & SMK_INODE_IMPURE)
- pr_info("Smack Unconfined Corruption: inode=(%s %ld) %s\n",
- inode->i_sb->s_id, inode->i_ino, current->comm);
+ pr_info("Smack Unconfined Corruption: inode=(%s %llu) %s\n",
+ inode->i_sb->s_id, inode_get_ino(inode), current->comm);

if (rc <= 0)
return rc;
@@ -212,9 +212,9 @@ static int smk_bu_inode(struct inode *inode, int mode, int rc)

smk_bu_mode(mode, acc);

- pr_info("Smack %s: (%s %s %s) inode=(%s %ld) %s\n", smk_bu_mess[rc],
+ pr_info("Smack %s: (%s %s %s) inode=(%s %llu) %s\n", smk_bu_mess[rc],
tsp->smk_task->smk_known, isp->smk_inode->smk_known, acc,
- inode->i_sb->s_id, inode->i_ino, current->comm);
+ inode->i_sb->s_id, inode_get_ino(inode), current->comm);
return 0;
}
#else
@@ -231,8 +231,8 @@ static int smk_bu_file(struct file *file, int mode, int rc)
char acc[SMK_NUM_ACCESS_TYPE + 1];

if (isp->smk_flags & SMK_INODE_IMPURE)
- pr_info("Smack Unconfined Corruption: inode=(%s %ld) %s\n",
- inode->i_sb->s_id, inode->i_ino, current->comm);
+ pr_info("Smack Unconfined Corruption: inode=(%s %llu) %s\n",
+ inode->i_sb->s_id, inode_get_ino(inode), current->comm);

if (rc <= 0)
return rc;
@@ -240,9 +240,9 @@ static int smk_bu_file(struct file *file, int mode, int rc)
rc = 0;

smk_bu_mode(mode, acc);
- pr_info("Smack %s: (%s %s %s) file=(%s %ld %pD) %s\n", smk_bu_mess[rc],
+ pr_info("Smack %s: (%s %s %s) file=(%s %llu %pD) %s\n", smk_bu_mess[rc],
sskp->smk_known, smk_of_inode(inode)->smk_known, acc,
- inode->i_sb->s_id, inode->i_ino, file,
+ inode->i_sb->s_id, inode_get_ino(inode), file,
current->comm);
return 0;
}
@@ -261,8 +261,8 @@ static int smk_bu_credfile(const struct cred *cred, struct file *file,
char acc[SMK_NUM_ACCESS_TYPE + 1];

if (isp->smk_flags & SMK_INODE_IMPURE)
- pr_info("Smack Unconfined Corruption: inode=(%s %ld) %s\n",
- inode->i_sb->s_id, inode->i_ino, current->comm);
+ pr_info("Smack Unconfined Corruption: inode=(%s %llu) %s\n",
+ inode->i_sb->s_id, inode_get_ino(inode), current->comm);

if (rc <= 0)
return rc;
@@ -270,9 +270,9 @@ static int smk_bu_credfile(const struct cred *cred, struct file *file,
rc = 0;

smk_bu_mode(mode, acc);
- pr_info("Smack %s: (%s %s %s) file=(%s %ld %pD) %s\n", smk_bu_mess[rc],
+ pr_info("Smack %s: (%s %s %s) file=(%s %llu %pD) %s\n", smk_bu_mess[rc],
sskp->smk_known, smk_of_inode(inode)->smk_known, acc,
- inode->i_sb->s_id, inode->i_ino, file,
+ inode->i_sb->s_id, inode_get_ino(inode), file,
current->comm);
return 0;
}
--
2.46.1