Re: [PATCH v4 2/4] mtd: always initialize 'stats' in struct mtd_oob_ops

From: Miquel Raynal
Date: Wed Sep 21 2022 - 04:41:32 EST


On Wed, 2022-06-29 at 12:57:35 UTC, =?utf-8?b?TWljaGHFgiBLxJlwaWXFhA==?= wrote:
> As the 'stats' field in struct mtd_oob_ops is used in conditional
> expressions, ensure it is always zero-initialized in all such structures
> to prevent random stack garbage from being interpreted as a pointer.
>
> Strictly speaking, this problem currently only needs to be fixed for
> struct mtd_oob_ops structures subsequently passed to mtd_read_oob().
> However, this commit goes a step further and makes all instances of
> struct mtd_oob_ops in the tree zero-initialized, in hope of preventing
> future problems, e.g. if struct mtd_req_stats gets extended with write
> statistics at some point.
>
> Signed-off-by: Michał Kępień <kernel@xxxxxxxxxx>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel