netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Michal Hocko <mhocko@suse.com>
Cc: Florian Westphal <fw@strlen.de>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org, vbabka@suse.cz,
	akpm@linux-foundation.org, urezki@gmail.com,
	netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
	Martin Zaharinov <micron10@gmail.com>
Subject: Re: [PATCH mm] mm: fix BUG with kvzalloc+GFP_ATOMIC
Date: Mon, 26 Sep 2022 15:08:08 +0200	[thread overview]
Message-ID: <20220926130808.GD12777@breakpoint.cc> (raw)
In-Reply-To: <YzGUyWlYd15uLu7G@dhcp22.suse.cz>

Michal Hocko <mhocko@suse.com> wrote:
> On Mon 26-09-22 12:08:00, Florian Westphal wrote:
> > Michal Hocko <mhocko@suse.com> wrote:
> > > +		old_tbl = rht_dereference_rcu(ht->tbl, ht);
> > > +		size = tbl->size;
> > > +
> > > +		data = ERR_PTR(-EBUSY);
> > > +
> > > +		if (rht_grow_above_75(ht, tbl))
> > > +			size *= 2;
> > > +		/* Do not schedule more than one rehash */
> > > +		else if (old_tbl != tbl)
> > > +			return data;
> > > +
> > > +		data = ERR_PTR(-ENOMEM);
> > > +
> > > +		rcu_read_unlock();
> > > +		new_tbl = bucket_table_alloc(ht, size, GFP_KERNEL);
> > > +		rcu_read_lock();
> > 
> > I don't think this is going to work, there can be callers that
> > rely on rcu protected data structures getting free'd.
> 
> The caller of this function drops RCU for each retry, why should be the
> called function any special?

I was unfortunately never able to fully understand rhashtable.
AFAICS the rcu_read_lock/unlock in the caller is pointless,
or at least dubious.

To the best of my knowledge there are users of this interface that
invoke it with rcu read lock held, and since those always nest, the
rcu_read_unlock() won't move us to GFP_KERNEL territory.

I guess you can add a might_sleep() and ask kernel to barf at runtime.

  reply	other threads:[~2022-09-26 14:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23 10:38 [PATCH mm] mm: fix BUG with kvzalloc+GFP_ATOMIC Florian Westphal
2022-09-23 13:29 ` Michal Hocko
2022-09-23 13:35   ` Florian Westphal
2022-09-23 14:43     ` Uladzislau Rezki
2022-09-23 14:54       ` Florian Westphal
2022-09-23 15:10         ` Uladzislau Rezki
2022-09-26 15:03           ` Vlastimil Babka
2022-09-26 15:28             ` Sebastian Andrzej Siewior
2022-09-26  7:49     ` Michal Hocko
2022-09-26  7:56       ` Florian Westphal
2022-09-26  8:57         ` Michal Hocko
2022-09-26  9:30           ` Michal Hocko
2022-09-26 10:08             ` Florian Westphal
2022-09-26 12:02               ` Michal Hocko
2022-09-26 13:08                 ` Florian Westphal [this message]
2022-09-26 13:38                   ` Florian Westphal
2022-09-26 14:05                   ` Michal Hocko
2022-09-26 14:20                     ` Florian Westphal
2022-09-26 14:32                       ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220926130808.GD12777@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=micron10@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).