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:   Mon, 10 Dec 2018 21:12:39 +0100
From:   Dmitry Vyukov <dvyukov@...gle.com>
To:     Cong Wang <xiyou.wangcong@...il.com>
Cc:     netdev <netdev@...r.kernel.org>, Ying Xue <ying.xue@...driver.com>,
        Jon Maloy <jon.maloy@...csson.com>
Subject: Re: [Patch net] tipc: use lock_sock() in tipc_sk_reinit()

On Mon, Dec 10, 2018 at 8:50 PM Cong Wang <xiyou.wangcong@...il.com> wrote:
>
> lock_sock() must be used in process context to be race-free with
> other lock_sock() callers, for example, tipc_release(). Otherwise
> using the spinlock directly can't serialize a parallel tipc_release().
>
> As it is blocking, we have to hold the sock refcnt before
> rhashtable_walk_stop() and release it after rhashtable_walk_start().

Thanks for the quick fix!

> Fixes: 07f6c4bc048a ("tipc: convert tipc reference table to use generic rhashtable")
> Reported-by: Dmitry Vyukov <dvyukov@...gle.com>
> Cc: Ying Xue <ying.xue@...driver.com>
> Cc: Jon Maloy <jon.maloy@...csson.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@...il.com>
> ---
>  net/tipc/socket.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
> index b57b1be7252b..e1396fb87779 100644
> --- a/net/tipc/socket.c
> +++ b/net/tipc/socket.c
> @@ -2724,11 +2724,15 @@ void tipc_sk_reinit(struct net *net)
>                 rhashtable_walk_start(&iter);
>
>                 while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) {
> -                       spin_lock_bh(&tsk->sk.sk_lock.slock);
> +                       sock_hold(&tsk->sk);
> +                       rhashtable_walk_stop(&iter);
> +                       lock_sock(&tsk->sk);
>                         msg = &tsk->phdr;
>                         msg_set_prevnode(msg, tipc_own_addr(net));
>                         msg_set_orignode(msg, tipc_own_addr(net));
> -                       spin_unlock_bh(&tsk->sk.sk_lock.slock);
> +                       release_sock(&tsk->sk);
> +                       rhashtable_walk_start(&iter);
> +                       sock_put(&tsk->sk);
>                 }
>
>                 rhashtable_walk_stop(&iter);
> --
> 2.19.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ