1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-22 07:53:11 -05:00

One minor code improvement for v6.14

-----BEGIN PGP SIGNATURE-----
 
 iQJLBAABCAA1FiEEC+9tH1YyUwIQzUIeOKUVfIxDyBEFAmeQGOEXHGNhc2V5QHNj
 aGF1Zmxlci1jYS5jb20ACgkQOKUVfIxDyBGbYA//RwccdJJXj5r3gUjfEb1p58hV
 z2D2cbJ6P23+e+mTa+AF/EqDQyRY1SizVnV/yV+ztfkXQ5DM0MLIMziWnenmwCeQ
 FTFp9D+/3q9J26+SdYV4JN9I/dVYeMVjIzEIQr82lEoiAWhPgNeJ8CKlme14wpUb
 jEqtFdAkNVwTxVi3OjMWs6liLBmkaskx2m9AXorsA7MXS6msuWhFmzuElJCt8KID
 DPUgEx9ny90SlCY3+FDz922v6cw4b4AU/z6Bf8ZBbf3cr9VcDOnq/W9D1NeOCfqb
 NXBHDIbjCNmQgR2vcfpDPW1tDk36xJdSOfIzWSlg8ZpMGWBe8Xnla5rpTTH4zaVq
 shMhLxzV1VTQoyrwsyvUbC7g7CssEBh7v+rIhdA0h59cBniMKanGTffAXEBzgXnl
 39kMicu7jX8vLn6HRgmOUrSdr4KgXKzhuW4GfCe/5dBh+2RnnUTn+iUVdj4xts/X
 SwODT0XT5FOofVh2hZYZMZK3MnFa/P401vOENMH3OiY3hYHBJdrO3JtPz9n+vxUF
 bA4rhwvSuBTsLjyJC/8qTLU3sgfCIHl9pBGVlMeRb2yt+7+EAJ6WDEr3LBdIrh9P
 6obhtG3zbQsplpVLwh7MbxuPcZT3u2pBX7ME9zfNWMKltwKKSPho/Bt72G8w2YNi
 VApxTfc6HKbWzJoCk04=
 =tXff
 -----END PGP SIGNATURE-----

Merge tag 'Smack-for-6.14' of https://github.com/cschaufler/smack-next

Pull smack update from Casey Schaufler:
 "One minor code improvement for v6.14"

* tag 'Smack-for-6.14' of https://github.com/cschaufler/smack-next:
  smack: deduplicate access to string conversion
This commit is contained in:
Linus Torvalds 2025-01-21 19:59:46 -08:00
commit 678ca9f78e
4 changed files with 15 additions and 40 deletions

View file

@ -280,6 +280,7 @@ int smk_access(struct smack_known *, struct smack_known *,
int smk_tskacc(struct task_smack *, struct smack_known *,
u32, struct smk_audit_info *);
int smk_curacc(struct smack_known *, u32, struct smk_audit_info *);
int smack_str_from_perm(char *string, int access);
struct smack_known *smack_from_secid(const u32);
char *smk_parse_smack(const char *string, int len);
int smk_netlbl_mls(int, char *, struct netlbl_lsm_secattr *, int);

View file

@ -275,7 +275,6 @@ int smk_curacc(struct smack_known *obj_known,
return smk_tskacc(tsp, obj_known, mode, a);
}
#ifdef CONFIG_AUDIT
/**
* smack_str_from_perm : helper to transalate an int to a
* readable string
@ -283,7 +282,7 @@ int smk_curacc(struct smack_known *obj_known,
* @access : the int
*
*/
static inline void smack_str_from_perm(char *string, int access)
int smack_str_from_perm(char *string, int access)
{
int i = 0;
@ -299,8 +298,15 @@ static inline void smack_str_from_perm(char *string, int access)
string[i++] = 't';
if (access & MAY_LOCK)
string[i++] = 'l';
if (access & MAY_BRINGUP)
string[i++] = 'b';
if (i == 0)
string[i++] = '-';
string[i] = '\0';
return i;
}
#ifdef CONFIG_AUDIT
/**
* smack_log_callback - SMACK specific information
* will be called by generic audit code

View file

@ -107,23 +107,7 @@ static char *smk_bu_mess[] = {
static void smk_bu_mode(int mode, char *s)
{
int i = 0;
if (mode & MAY_READ)
s[i++] = 'r';
if (mode & MAY_WRITE)
s[i++] = 'w';
if (mode & MAY_EXEC)
s[i++] = 'x';
if (mode & MAY_APPEND)
s[i++] = 'a';
if (mode & MAY_TRANSMUTE)
s[i++] = 't';
if (mode & MAY_LOCK)
s[i++] = 'l';
if (i == 0)
s[i++] = '-';
s[i] = '\0';
smack_str_from_perm(s, mode);
}
#endif

View file

@ -562,6 +562,7 @@ static void smk_seq_stop(struct seq_file *s, void *v)
static void smk_rule_show(struct seq_file *s, struct smack_rule *srp, int max)
{
char acc[SMK_NUM_ACCESS_TYPE + 1];
/*
* Don't show any rules with label names too long for
* interface file (/smack/load or /smack/load2)
@ -575,28 +576,11 @@ static void smk_rule_show(struct seq_file *s, struct smack_rule *srp, int max)
if (srp->smk_access == 0)
return;
seq_printf(s, "%s %s",
smack_str_from_perm(acc, srp->smk_access);
seq_printf(s, "%s %s %s\n",
srp->smk_subject->smk_known,
srp->smk_object->smk_known);
seq_putc(s, ' ');
if (srp->smk_access & MAY_READ)
seq_putc(s, 'r');
if (srp->smk_access & MAY_WRITE)
seq_putc(s, 'w');
if (srp->smk_access & MAY_EXEC)
seq_putc(s, 'x');
if (srp->smk_access & MAY_APPEND)
seq_putc(s, 'a');
if (srp->smk_access & MAY_TRANSMUTE)
seq_putc(s, 't');
if (srp->smk_access & MAY_LOCK)
seq_putc(s, 'l');
if (srp->smk_access & MAY_BRINGUP)
seq_putc(s, 'b');
seq_putc(s, '\n');
srp->smk_object->smk_known,
acc);
}
/*