Re: [PATCH] mm: Check writable zero page in page table check

From: Huang, Shaoqin
Date: Mon Sep 05 2022 - 20:24:40 EST




On 9/6/2022 2:50 AM, Edgecombe, Rick P wrote:
On Sat, 2022-09-03 at 10:13 +0800, Huang, Shaoqin wrote:
+ BUG_ON(is_zero_pfn(pfn) && rw);
+

Why we need use BUG_ON() here? Based on [1], we should avoid to use
the
BUG_ON() due to it will panic the machine.

[1]:
https://lore.kernel.org/lkml/20220824163100.224449-1-david@xxxxxxxxxx/

Yea, you are probably right. All the rest of this checker uses BUG_ON()
though. Maybe they should all be something else? Just felt weird to
have this be the only check that is different.

I don't have any objections to changing it to WARN_ON(). Should I
switch the rest of the checks here while I'm at it?

Yes. I think in most situation, WARN_ON() or WARN_ON_ONCE() is ok.