[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <01000164f169bc6b-c73a8353-d7d9-47ec-a782-90aadcb86bfb-000000@email.amazonses.com>
Date: Tue, 31 Jul 2018 17:36:36 +0000
From: Christopher Lameter <cl@...ux.com>
To: Andrey Ryabinin <aryabinin@...tuozzo.com>
cc: Theodore Ts'o <tytso@....edu>, Jan Kara <jack@...e.com>,
linux-ext4@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Pablo Neira Ayuso <pablo@...filter.org>,
Jozsef Kadlecsik <kadlec@...ckhole.kfki.hu>,
Florian Westphal <fw@...len.de>,
"David S. Miller" <davem@...emloft.net>,
netfilter-devel@...r.kernel.org, coreteam@...filter.org,
netdev@...r.kernel.org, Gerrit Renker <gerrit@....abdn.ac.uk>,
dccp@...r.kernel.org, Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
David Airlie <airlied@...ux.ie>,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
Eric Dumazet <edumazet@...gle.com>,
Alexey Kuznetsov <kuznet@....inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
Ursula Braun <ubraun@...ux.ibm.com>,
linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
Dmitry Vyukov <dvyukov@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
Andrey Konovalov <andreyknvl@...gle.com>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4
13/17] khwasan: add hooks implementation)
On Tue, 31 Jul 2018, Andrey Ryabinin wrote:
> Guys, it seems that we have a lot of code using SLAB_TYPESAFE_BY_RCU cache without constructor.
> I think it's nearly impossible to use that combination without having bugs.
> It's either you don't really need the SLAB_TYPESAFE_BY_RCU, or you need to have a constructor in kmem_cache.
>
> Could you guys, please, verify your code if it's really need SLAB_TYPSAFE or constructor?
>
> E.g. the netlink code look extremely suspicious:
>
> /*
> * Do not use kmem_cache_zalloc(), as this cache uses
> * SLAB_TYPESAFE_BY_RCU.
> */
> ct = kmem_cache_alloc(nf_conntrack_cachep, gfp);
> if (ct == NULL)
> goto out;
>
> spin_lock_init(&ct->lock);
>
> If nf_conntrack_cachep objects really used in rcu typesafe manner, than 'ct' returned by kmem_cache_alloc might still be
> in use by another cpu. So we just reinitialize spin_lock used by someone else?
ct may still be read by another cpu in a RCU section but the object was
freed elsewhere so no other processor may modify the object.
The lock must have been released before freeing the slab object and thus
the initialization of the spinlock is unnecessary if it was
initialized in ctor.
If there is refcounting going on then why use SLAB_TYPESAFE_BY_RCU?
Powered by blists - more mailing lists