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:   Tue, 27 Sep 2022 10:56:20 -0700
From:   Eric Dumazet <edumazet@...gle.com>
To:     Kuniyuki Iwashima <kuniyu@...zon.com>
Cc:     David Miller <davem@...emloft.net>,
        David Ahern <dsahern@...nel.org>,
        Jakub Kicinski <kuba@...nel.org>,
        Kuniyuki Iwashima <kuni1840@...il.com>,
        LKML <linux-kernel@...r.kernel.org>,
        netdev <netdev@...r.kernel.org>, Paolo Abeni <pabeni@...hat.com>,
        syzkaller-bugs <syzkaller-bugs@...glegroups.com>
Subject: Re: [PATCH v1 net 5/5] tcp: Fix data races around icsk->icsk_af_ops.

On Tue, Sep 27, 2022 at 10:49 AM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
>
> From:   Kuniyuki Iwashima <kuniyu@...zon.com>
> Date:   Tue, 27 Sep 2022 09:48:24 -0700
> > From:   Eric Dumazet <edumazet@...gle.com>
> > Date:   Tue, 27 Sep 2022 09:39:37 -0700
> > > On Tue, Sep 27, 2022 at 9:33 AM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> > > >
> > > > IPV6_ADDRFORM changes icsk->icsk_af_ops under lock_sock(), but
> > > > tcp_(get|set)sockopt() read it locklessly.  To avoid load/store
> > > > tearing, we need to add READ_ONCE() and WRITE_ONCE() for the reads
> > > > and write.
> > >
> > > I am pretty sure I have released a syzkaller bug recently with this issue.
> > > Have you seen this?
> > > If yes, please include the appropriate syzbot tag.
>
> Are you mentioning this commit ?
>

No, this is a new syzbot report, with a different stack trace.

> 086d49058cd8 ("ipv6: annotate some data-races around sk->sk_prot")
>
> Then, yes, I'll add syzbot tags to patch 4 and 5.
>
>
> >
> > No, I haven't.
> > Could you provide the URL?
> > I'm happy to include the syzbot tag and KCSAN report in the changelog.
> >
> >
> > > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> > > > Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>
> > > > ---
> > > >  net/ipv4/tcp.c           | 10 ++++++----
> > > >  net/ipv6/ipv6_sockglue.c |  3 ++-
> > > >  2 files changed, 8 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> > > > index e373dde1f46f..c86dd0ccef5b 100644
> > > > --- a/net/ipv4/tcp.c
> > > > +++ b/net/ipv4/tcp.c
> > > > @@ -3795,8 +3795,9 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
> > > >         const struct inet_connection_sock *icsk = inet_csk(sk);
> > > >
> > > >         if (level != SOL_TCP)
> > > > -               return icsk->icsk_af_ops->setsockopt(sk, level, optname,
> > > > -                                                    optval, optlen);
> > > > +               /* IPV6_ADDRFORM can change icsk->icsk_af_ops under us. */
> > > > +               return READ_ONCE(icsk->icsk_af_ops)->setsockopt(sk, level, optname,
> > > > +                                                               optval, optlen);
> > > >         return do_tcp_setsockopt(sk, level, optname, optval, optlen);
> > > >  }
> > > >  EXPORT_SYMBOL(tcp_setsockopt);
> > > > @@ -4394,8 +4395,9 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
> > > >         struct inet_connection_sock *icsk = inet_csk(sk);
> > > >
> > > >         if (level != SOL_TCP)
> > > > -               return icsk->icsk_af_ops->getsockopt(sk, level, optname,
> > > > -                                                    optval, optlen);
> > > > +               /* IPV6_ADDRFORM can change icsk->icsk_af_ops under us. */
> > > > +               return READ_ONCE(icsk->icsk_af_ops)->getsockopt(sk, level, optname,
> > > > +                                                               optval, optlen);
> > > >         return do_tcp_getsockopt(sk, level, optname, optval, optlen);
> > > >  }
> > > >  EXPORT_SYMBOL(tcp_getsockopt);
> > > > diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> > > > index a89db5872dc3..726d95859898 100644
> > > > --- a/net/ipv6/ipv6_sockglue.c
> > > > +++ b/net/ipv6/ipv6_sockglue.c
> > > > @@ -479,7 +479,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
> > > >
> > > >                                 /* Paired with READ_ONCE(sk->sk_prot) in inet6_stream_ops */
> > > >                                 WRITE_ONCE(sk->sk_prot, &tcp_prot);
> > > > -                               icsk->icsk_af_ops = &ipv4_specific;
> > > > +                               /* Paired with READ_ONCE() in tcp_(get|set)sockopt() */
> > > > +                               WRITE_ONCE(icsk->icsk_af_ops, &ipv4_specific);
> > > >                                 sk->sk_socket->ops = &inet_stream_ops;
> > > >                                 sk->sk_family = PF_INET;
> > > >                                 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
> > > > --
> > > > 2.30.2
> > > >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ