Re: [PATCH v4 0/3] mm, treewide: Rename kzfree() to kfree_sensitive()

From: Matthew Wilcox
Date: Wed Jun 17 2020 - 08:23:39 EST


On Wed, Jun 17, 2020 at 01:31:57PM +0200, Michal Hocko wrote:
> On Wed 17-06-20 04:08:20, Matthew Wilcox wrote:
> > If you call vfree() under
> > a spinlock, you're in trouble. in_atomic() only knows if we hold a
> > spinlock for CONFIG_PREEMPT, so it's not safe to check for in_atomic()
> > in __vfree(). So we need the warning in order that preempt people can
> > tell those without that there is a bug here.
>
> ... Unless I am missing something in_interrupt depends on preempt_count() as
> well so neither of the two is reliable without PREEMPT_COUNT configured.

preempt_count() always tracks whether we're in interrupt context,
regardless of CONFIG_PREEMPT. The difference is that CONFIG_PREEMPT
will track spinlock acquisitions as well.