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]
Message-ID: <CAEivzxf630y_kjVLNM4m1vfQxnwyOBK+0wiCLW1T+8miPVC5Fg@mail.gmail.com>
Date:   Mon, 13 Mar 2023 12:40:28 +0100
From:   Aleksandr Mikhalitsyn <aleksandr.mikhalitsyn@...onical.com>
To:     davem@...emloft.net
Cc:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Leon Romanovsky <leon@...nel.org>, paul@...l-moore.com,
        jmorris@...ei.org, serge@...lyn.com
Subject: Re: [PATCH net-next v2] scm: fix MSG_CTRUNC setting condition for SO_PASSSEC

+CC security subsystem folks

On Mon, Mar 13, 2023 at 12:32 PM Alexander Mikhalitsyn
<aleksandr.mikhalitsyn@...onical.com> wrote:
>
> Currently, kernel would set MSG_CTRUNC flag if msg_control buffer
> wasn't provided and SO_PASSCRED was set or if there was pending SCM_RIGHTS.
>
> For some reason we have no corresponding check for SO_PASSSEC.
>
> In the recvmsg(2) doc we have:
>        MSG_CTRUNC
>               indicates that some control data was discarded due to lack
>               of space in the buffer for ancillary data.
>
> So, we need to set MSG_CTRUNC flag for all types of SCM.
>
> This change can break applications those don't check MSG_CTRUNC flag.
>
> Cc: "David S. Miller" <davem@...emloft.net>
> Cc: Eric Dumazet <edumazet@...gle.com>
> Cc: Jakub Kicinski <kuba@...nel.org>
> Cc: Paolo Abeni <pabeni@...hat.com>
> Cc: Leon Romanovsky <leon@...nel.org>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@...onical.com>
>
> v2:
> - commit message was rewritten according to Eric's suggestion
> ---
>  include/net/scm.h | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/scm.h b/include/net/scm.h
> index 1ce365f4c256..585adc1346bd 100644
> --- a/include/net/scm.h
> +++ b/include/net/scm.h
> @@ -105,16 +105,27 @@ static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct sc
>                 }
>         }
>  }
> +
> +static inline bool scm_has_secdata(struct socket *sock)
> +{
> +       return test_bit(SOCK_PASSSEC, &sock->flags);
> +}
>  #else
>  static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct scm_cookie *scm)
>  { }
> +
> +static inline bool scm_has_secdata(struct socket *sock)
> +{
> +       return false;
> +}
>  #endif /* CONFIG_SECURITY_NETWORK */
>
>  static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
>                                 struct scm_cookie *scm, int flags)
>  {
>         if (!msg->msg_control) {
> -               if (test_bit(SOCK_PASSCRED, &sock->flags) || scm->fp)
> +               if (test_bit(SOCK_PASSCRED, &sock->flags) || scm->fp ||
> +                   scm_has_secdata(sock))
>                         msg->msg_flags |= MSG_CTRUNC;
>                 scm_destroy(scm);
>                 return;
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ