Re: [PATCH 06/18] fscrypt: Include instead of

Eric Biggers
2024-09-05T23:02:21Z

On Thu, Sep 05, 2024 at 02:17:14PM +0200, Uros Bizjak wrote:
> Usage of pseudo-random functions requires inclusion of
> <linux/prandom.h> header instead of <linux/random.h>.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Eric Biggers <ebiggers@kernel.org>
> Cc: "Theodore Y. Ts'o" <tytso@mit.edu>
> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
> Cc. linux-fscrypt@vger.kernel.org
> ---
> fs/crypto/keyring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
> index 6681a71625f0..e2c10b3b960b 100644
> --- a/fs/crypto/keyring.c
> +++ b/fs/crypto/keyring.c
> @@ -21,7 +21,7 @@
> #include <asm/unaligned.h>
> #include <crypto/skcipher.h>
> #include <linux/key-type.h>
> -#include <linux/random.h>
> +#include <linux/prandom.h>
> #include <linux/seq_file.h>
>

1. linux-fscrypt wasn't actually Cc'ed on this patch, due to the typo of
"Cc." instead of "Cc:".

2. Currently <linux/random.h> includes <linux/prandom.h>, so the issue described
in the commit message does not exist. I assume this in changing in a later
patch that was not sent to me. The commit message should be rephrased to
clarify that this change is needed because of header refactoring, as
otherwise it sounds like a bug fix.

3. The proposed change does not make sense, because fs/crypto/keyring.c does not
use any "pseudo-random functions". It does use get_random_once(), which is
defined in <linux/once.h>. Currently <linux/random.h> includes
<linux/prandom.h> which includes <linux/once.h>. If the inclusion of
prandom.h by random.h is going away, then perhaps random.h should include
once.h directly so that get_random_once() continues to work? If not, then
this file should include once.h. Either way it should not include prandom.h.

- Eric