2020-10-02 15:24:00

by Thibaut Sautereau

[permalink] [raw]
Subject: [PATCH] random32: Restore __latent_entropy attribute on net_rand_state

From: Thibaut Sautereau <[email protected]>

Commit f227e3ec3b5c ("random32: update the net random state on interrupt
and activity") broke compilation and was temporarily fixed by Linus in
83bdc7275e62 ("random32: remove net_rand_state from the latent entropy
gcc plugin") by entirely moving net_rand_state out of the things handled
by the latent_entropy GCC plugin.

From what I understand when reading the plugin code, using the
__latent_entropy attribute on a declaration was the wrong part and
simply keeping the __latent_entropy attribute on the variable definition
was the correct fix.

Fixes: 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy gcc plugin")
Cc: Linus Torvalds <[email protected]>
Cc: Willy Tarreau <[email protected]>
Cc: Emese Revfy <[email protected]>
Signed-off-by: Thibaut Sautereau <[email protected]>
---
lib/random32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/random32.c b/lib/random32.c
index 932345323af0..dfb9981ab798 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -49,7 +49,7 @@ static inline void prandom_state_selftest(void)
}
#endif

-DEFINE_PER_CPU(struct rnd_state, net_rand_state);
+DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;

/**
* prandom_u32_state - seeded pseudo-random number generator.
--
2.28.0


2020-10-02 15:24:38

by Willy Tarreau

[permalink] [raw]
Subject: Re: [PATCH] random32: Restore __latent_entropy attribute on net_rand_state

On Fri, Oct 02, 2020 at 05:16:11PM +0200, Thibaut Sautereau wrote:
> From: Thibaut Sautereau <[email protected]>
>
> Commit f227e3ec3b5c ("random32: update the net random state on interrupt
> and activity") broke compilation and was temporarily fixed by Linus in
> 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy
> gcc plugin") by entirely moving net_rand_state out of the things handled
> by the latent_entropy GCC plugin.
>
> From what I understand when reading the plugin code, using the
> __latent_entropy attribute on a declaration was the wrong part and
> simply keeping the __latent_entropy attribute on the variable definition
> was the correct fix.

Ah thank you, this is what I tried to figure and failed to! Spender
mentioned that a one-liner was all that was needed to fix this but
never responded to my request asking about it.

Willy

2020-10-06 02:16:32

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] random32: Restore __latent_entropy attribute on net_rand_state

On Fri, Oct 02, 2020 at 05:16:11PM +0200, Thibaut Sautereau wrote:
> From: Thibaut Sautereau <[email protected]>
>
> Commit f227e3ec3b5c ("random32: update the net random state on interrupt
> and activity") broke compilation and was temporarily fixed by Linus in
> 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy
> gcc plugin") by entirely moving net_rand_state out of the things handled
> by the latent_entropy GCC plugin.
>
> From what I understand when reading the plugin code, using the
> __latent_entropy attribute on a declaration was the wrong part and
> simply keeping the __latent_entropy attribute on the variable definition
> was the correct fix.
>
> Fixes: 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy gcc plugin")
> Cc: Linus Torvalds <[email protected]>
> Cc: Willy Tarreau <[email protected]>
> Cc: Emese Revfy <[email protected]>
> Signed-off-by: Thibaut Sautereau <[email protected]>

Yes, that looks correct. Thank you!

Acked-by: Kees Cook <[email protected]>

I'm not sure the best tree for this. Ted, Andrew, Linus? I'll take it
via my gcc plugin tree if no one else takes it. :)

--
Kees Cook

2020-10-06 02:33:17

by Willy Tarreau

[permalink] [raw]
Subject: Re: [PATCH] random32: Restore __latent_entropy attribute on net_rand_state

Hi Kees,

On Mon, Oct 05, 2020 at 07:12:29PM -0700, Kees Cook wrote:
> On Fri, Oct 02, 2020 at 05:16:11PM +0200, Thibaut Sautereau wrote:
> > From: Thibaut Sautereau <[email protected]>
> >
> > Commit f227e3ec3b5c ("random32: update the net random state on interrupt
> > and activity") broke compilation and was temporarily fixed by Linus in
> > 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy
> > gcc plugin") by entirely moving net_rand_state out of the things handled
> > by the latent_entropy GCC plugin.
> >
> > From what I understand when reading the plugin code, using the
> > __latent_entropy attribute on a declaration was the wrong part and
> > simply keeping the __latent_entropy attribute on the variable definition
> > was the correct fix.
> >
> > Fixes: 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy gcc plugin")
> > Cc: Linus Torvalds <[email protected]>
> > Cc: Willy Tarreau <[email protected]>
> > Cc: Emese Revfy <[email protected]>
> > Signed-off-by: Thibaut Sautereau <[email protected]>
>
> Yes, that looks correct. Thank you!
>
> Acked-by: Kees Cook <[email protected]>
>
> I'm not sure the best tree for this. Ted, Andrew, Linus? I'll take it
> via my gcc plugin tree if no one else takes it. :)

It was already merged as commit 09a6b0bc3be79 and queued for -stable.

Cheers,
Willy

2020-10-06 06:00:04

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] random32: Restore __latent_entropy attribute on net_rand_state

On Tue, Oct 06, 2020 at 04:28:09AM +0200, Willy Tarreau wrote:
> Hi Kees,
>
> On Mon, Oct 05, 2020 at 07:12:29PM -0700, Kees Cook wrote:
> > On Fri, Oct 02, 2020 at 05:16:11PM +0200, Thibaut Sautereau wrote:
> > > From: Thibaut Sautereau <[email protected]>
> > >
> > > Commit f227e3ec3b5c ("random32: update the net random state on interrupt
> > > and activity") broke compilation and was temporarily fixed by Linus in
> > > 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy
> > > gcc plugin") by entirely moving net_rand_state out of the things handled
> > > by the latent_entropy GCC plugin.
> > >
> > > From what I understand when reading the plugin code, using the
> > > __latent_entropy attribute on a declaration was the wrong part and
> > > simply keeping the __latent_entropy attribute on the variable definition
> > > was the correct fix.
> > >
> > > Fixes: 83bdc7275e62 ("random32: remove net_rand_state from the latent entropy gcc plugin")
> > > Cc: Linus Torvalds <[email protected]>
> > > Cc: Willy Tarreau <[email protected]>
> > > Cc: Emese Revfy <[email protected]>
> > > Signed-off-by: Thibaut Sautereau <[email protected]>
> >
> > Yes, that looks correct. Thank you!
> >
> > Acked-by: Kees Cook <[email protected]>
> >
> > I'm not sure the best tree for this. Ted, Andrew, Linus? I'll take it
> > via my gcc plugin tree if no one else takes it. :)
>
> It was already merged as commit 09a6b0bc3be79 and queued for -stable.

Ah, perfect! Thanks.

--
Kees Cook