Skip to contentSkip to conversation

security/smack/smack.h: Fix smk_known length

PATCH In review wzt wzt 3 participants 3 messages Feb 8, 2010 – Feb 9, 2010

Subsystems (2)
lore
Share & tools
lore

wzt wzt

author
#0 lore raw

PATCH 1/1 security/smack/smack.h: Fix smk_known length

in security/smack/smack.h:

struct smack_known {
        struct list_head        list;
        char                    smk_known[SMK_LABELLEN];
but in security/smack/smack_access.c
void smack_from_cipso(u32 level, char *cp, char *result)
{
        strncpy(result, final, SMK_MAXLEN);
}

miss '\0'.

security/smack/smack.h +1 -1
index c6e9aca..600474b 100644
@@ -109,7 +109,7 @@ struct smk_netlbladdr {
  */
 struct smack_known {
        struct list_head        list;
-       char                    smk_known[SMK_LABELLEN];
+       char                    smk_known[SMK_LABELLEN + 1]; /*

smk_known + \0 */

        u32                     smk_secid;
        struct smack_cipso      *smk_cipso;
        spinlock_t              smk_cipsolock; /* for changing cipso map */
maintainer
#1 lore raw

(note: please copy security/ patches to the LSM list, cc'd, along with the Smack maintainer).

Quoted 29 lines · wzt wzt

in security/smack/smack.h:

struct smack_known {
        struct list_head        list;
        char                    smk_known[SMK_LABELLEN];
but in security/smack/smack_access.c
void smack_from_cipso(u32 level, char *cp, char *result)
{
        strncpy(result, final, SMK_MAXLEN);
}

miss '\0'.

security/smack/smack.h +1 -1
index c6e9aca..600474b 100644
@@ -109,7 +109,7 @@ struct smk_netlbladdr {
  */
 struct smack_known {
        struct list_head        list;
-       char                    smk_known[SMK_LABELLEN];
+       char                    smk_known[SMK_LABELLEN + 1]; /*

smk_known + \0 */

        u32                     smk_secid;
        struct smack_cipso      *smk_cipso;
        spinlock_t              smk_cipsolock; /* for changing cipso map */
Signature · 2 lines
James Morris
<[email protected]>
maintainer
#2 lore raw
Quoted 21 lines · James Morris

(note: please copy security/ patches to the LSM list, cc'd, along with the Smack maintainer).

Quoted 14 lines · wzt wzt

in security/smack/smack.h:

struct smack_known {
        struct list_head        list;
        char                    smk_known[SMK_LABELLEN];
but in security/smack/smack_access.c
void smack_from_cipso(u32 level, char *cp, char *result)
{
        strncpy(result, final, SMK_MAXLEN);
}

miss '\0'.

Quoted 12 lines
Quoted 10 lines
security/smack/smack.h +1 -1
index c6e9aca..600474b 100644
@@ -109,7 +109,7 @@ struct smk_netlbladdr {
  */
 struct smack_known {
        struct list_head        list;
-       char                    smk_known[SMK_LABELLEN];
+       char                    smk_known[SMK_LABELLEN + 1]; /*
Quoted 2 lines

smk_known + \0 */

SMK_LABELLEN is already SMK_MAXLEN+1. That's why the strncpy() above uses SMK_MAXLEN, so that maximum copied will be SMK_MAXLEN+1, including the trailing '\0'. The only possible case it could miss would be a label that is SMK_LABELLEN (24 bytes) long, and that would be an error because Smack labels are limited to SMK_MAXLEN (23 bytes) plus the trailing '\0'. The strncpy() could easily be strcpy(), as only labels that have been imported or hand crafted in the code will be in "from".

Quoted 5 lines
Quoted 5 lines
        u32                     smk_secid;
        struct smack_cipso      *smk_cipso;
        spinlock_t              smk_cipsolock; /* for changing cipso map */