kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Linux Security Module listsecurity (and security xattr hooks) only one called?
@ 2016-09-06 11:05 Pasquier, Thomas
  2016-09-06 12:12 ` Greg KH
  2016-09-06 17:35 ` Valdis.Kletnieks at vt.edu
  0 siblings, 2 replies; 4+ messages in thread
From: Pasquier, Thomas @ 2016-09-06 11:05 UTC (permalink / raw)
  To: kernelnewbies

Hello everyone,

In security/security.c (see here:https://github.com/torval
ds/linux/blob/835c92d43b29eb354abdbd5475308a474d7efdfa/security/security.c)

Looking at this:

int security_inode_listsecurity(struct inode *inode, char *buffer, size_t
buffer_size)
{
    if (unlikely(IS_PRIVATE(inode)))
        return 0;
    return call_int_hook(inode_listsecurity, 0, inode, buffer, buffer_size);
}
One would expect all stacked security module to be called. However, when
looking at this:

#define call_int_hook(FUNC, IRC, ...) ({            \
    int RC = IRC;                       \
    do {                            \
        struct security_hook_list *P;           \
                                \
        list_for_each_entry(P, &security_hook_heads.FUNC, list) { \
            RC = P->hook.FUNC(__VA_ARGS__);     \
            if (RC != 0)                \
                break;              \
        }                       \
    } while (0);                        \
    RC;                         \
})
If one of the module return a non-zero value, the other are not called.
That means that the list of security of xattr is not built (or rather that
it only contains the first module being called), as the lenght of inserted
element is returned. Similarly for setsecurity and getsecurity, it seems
that only one module will be called as if the given module does not support
the security xattr, it returns -EOPNOTSUPP (instead I believe the next
module being called, until one supporting the attribute is met).

I am aware that LSM stacking is not fully supported yet:
https://lwn.net/Articles/635771/
https://lwn.net/Articles/697259/

Here fix setsecurity and getsecurity: https://github.
com/cschaufler/smack-next/blob/next/security/security.c; but listsecurity
would appear to still not behave as I would expect. However, I may be
missing something.

What is the rational here? I could change the code to support multiple
security xattr, but don't want to do so before I am sure I understand why
it was done like this. Any help is welcome.

Thanks.
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160906/e0fb497a/attachment-0001.html 

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Linux Security Module listsecurity (and security xattr hooks) only one called?
@ 2016-09-05 15:20 Pasquier, Thomas
  0 siblings, 0 replies; 4+ messages in thread
From: Pasquier, Thomas @ 2016-09-05 15:20 UTC (permalink / raw)
  To: kernelnewbies

In security/security.c (see here:
https://github.com/torvalds/linux/blob/835c92d43b29eb354abdbd5475308a474d7efdfa/security/security.c
)

Looking at this:

int security_inode_listsecurity(struct inode *inode, char *buffer, size_t
buffer_size)
{
    if (unlikely(IS_PRIVATE(inode)))
        return 0;
    return call_int_hook(inode_listsecurity, 0, inode, buffer, buffer_size);
}
One would expect all stacked security module to be called. However, when
looking at this:

#define call_int_hook(FUNC, IRC, ...) ({            \
    int RC = IRC;                       \
    do {                            \
        struct security_hook_list *P;           \
                                \
        list_for_each_entry(P, &security_hook_heads.FUNC, list) { \
            RC = P->hook.FUNC(__VA_ARGS__);     \
            if (RC != 0)                \
                break;              \
        }                       \
    } while (0);                        \
    RC;                         \
})
If one of the module return a non-zero value, the other are not called.
That means that the list of security of xattr is not built (or rather that
it only contains the first module being called), as the lenght of inserted
element is returned. Similarly for setsecurity and getsecurity, it seems
that only one module will be called as if the given module does not support
the security xattr, it returns -EOPNOTSUPP (instead I believe the next
module being called, until one supporting the attribute is met).

What is the rational here? I could change the code to support multiple
security xattr, but don't want to do so before I understand why it was done
like this. Any help is welcome.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160905/5241c2fa/attachment-0001.html 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-06 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-06 11:05 Linux Security Module listsecurity (and security xattr hooks) only one called? Pasquier, Thomas
2016-09-06 12:12 ` Greg KH
2016-09-06 17:35 ` Valdis.Kletnieks at vt.edu
  -- strict thread matches above, loose matches on Subject: below --
2016-09-05 15:20 Pasquier, Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).