lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 25 Apr 2020 07:42:26 -0400
From:   Paul Moore <paul@...l-moore.com>
To:     Dmitry Vyukov <dvyukov@...gle.com>,
        David Miller <davem@...emloft.net>, <kuba@...nel.org>,
        netdev <netdev@...r.kernel.org>
CC:     Stephen Smalley <stephen.smalley.work@...il.com>,
        Eric Paris <eparis@...isplace.org>, <selinux@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        syzkaller <syzkaller@...glegroups.com>,
        Willem de Bruijn <willemb@...gle.com>
Subject: Re: selinux_netlink_send changes program behavior

On April 25, 2020 1:15:05 AM Dmitry Vyukov <dvyukov@...gle.com> wrote:

> On Fri, Apr 24, 2020 at 11:51 PM Paul Moore <paul@...l-moore.com> wrote:
>>
>> On Fri, Apr 24, 2020 at 4:27 AM Dmitry Vyukov <dvyukov@...gle.com> wrote:
>>> Hi SELinux maintainers,
>>>
>>> We've hit a case where a developer wasn't able to reproduce a kernel
>>> bug, it turned out to be a difference in behavior between SELinux and
>>> non-SELinux kernels.
>>> Condensed version: a program does sendmmsg on netlink socket with 2
>>> mmsghdr's, first is completely empty/zeros, second contains some
>>> actual payload. Without SELinux the first mmsghdr is treated as no-op
>>> and the kernel processes the second one (triggers bug). However the
>>> SELinux hook does:
>>>
>>> static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
>>> {
>>> if (skb->len < NLMSG_HDRLEN) {
>>>  err = -EINVAL;
>>>  goto out;
>>> }
>>>
>>> and fails processing on the first empty mmsghdr (does not happen
>>> without SELinux).
>>>
>>> Is this difference in behavior intentional/acceptable/should be fixed?
>>
>> From a practical perspective, SELinux is always going to need to do a
>> length check as it needs to peek into the netlink message header for
>> the message type so it can map that to the associated SELinux
>> permissions.  So in that sense, the behavior is intentional and
>> desired; however from a bug-for-bug compatibility perspective ... not
>> so much.
>>
>> Ultimately, my it's-Friday-and-it's-been-a-long-week-ending-in-a-long-day
>> thought is that this was a buggy operation to begin with and the bug
>> was just caught in different parts of the kernel, depending on how it
>> was configured.  It may not be ideal, but I can think of worse things
>> (and arguably SELinux is doing the Right Thing).
>
> +netlink maintainers for intended semantics of empty netlink messages
>
> If it's a bug, or intended behavior depends on the intended
> behavior... which I assume is not documented anywhere officially.

Your original email gave the impression that there was a big in the non-SELinux case; if that is not the case my response changes.

> However, most of the netlink families use netlink_rcv_skb, which does:
>
> int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
>                           struct nlmsghdr *,
>                           struct netlink_ext_ack *))
> {
>    ...
>    while (skb->len >= nlmsg_total_size(0)) {
>    ...
>       skb_pull(skb, msglen);
>    }
>    return 0;
> }
>
> 1. How intentional is this while loop logic vs sloppy error checking?
> 2. netlink_rcv_skb seems to be able to handle 2+ messages in the same
> skb, while selinux_netlink_send only checks the first one... so can I
> skip SELinux checks by putting a malicious message after a permitted
> one?..



Powered by blists - more mailing lists