Re: [syzbot] KASAN: use-after-free Read in rdma_close

From: Leon Romanovsky
Date: Thu Sep 29 2022 - 02:10:20 EST


On Thu, Sep 29, 2022 at 06:52:56AM +0900, asmadeus@xxxxxxxxxxxxx wrote:

<...>

> > From technical perspective, yes, destruction in reverse order is usually the
> > better way to go. Whether I would carve that in stone, without any exception,
> > probably not.
>
> I think it's a tradeoff really.
> Unrolling in place is great, don't get me wrong, but it's also easy to
> miss things when adding code later on -- we actually just did that and
> got another kasan report which made me factor things in to future-proof
> the code.
>
> Having a single place of truth that knows how to "untangle" and properly
> free a struct, making sure it is noop for parts of the struct that
> haven't been initialized yet, is less of a burden for me to think about.

It is not bikeshedding or tradeoff, but matter of well-proven coding
patterns, which are very helpful for review and code maintaining.

Thanks