Re: [PATCH v2 2/2] VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host()

From: Dan Carpenter
Date: Tue Jan 09 2024 - 04:08:15 EST


On Mon, Jan 08, 2024 at 08:05:38PM -0600, Gustavo A. R. Silva wrote:
> > > Gustavo quoted:
> > > "Under FORTIFY_SOURCE we should not copy data across multiple members
> > > in a structure."
> > >
> > > Reported-by: syzkaller <syzkaller@xxxxxxxxxxxxxxxx>
> > > Suggested-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx>
> > > Suggested-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
> > > Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx>
> >
> > Thanks for getting this fixed!
> >
> > Yeah, it's a "false positive" in the sense that the code was expecting
>
> It's a false positive _bug_, and a legitimate _warning_ coming from fortified
> memcpy().

It really feels like you're trying to sell the cost of this as a good
thing... We've already merged fortify so why are you still fighting
about this? Now that it's merged, let's just all admit that false
positives are bad.

I feel like once we recognize that actually false positives are bad as
opposed to good then that's when we start looking for solutions. In
Smatch, I have code that silences warnings about cross member writes
because it was a common source of false positives...

The Kconfig entry does not mention the risk of false positives at all
and it doesn't say anything about turning on fortify along with
CONFIG_PANIC_ON_OOPS is probably bad. There are simple things we could
do to make this less risky.

regards,
dan carpenter