From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Alexander E. Patrakov" Subject: Re: [PATCH v25 10/12] LRNG - add TRNG support Date: Wed, 20 Nov 2019 14:55:46 +0500 Message-ID: References: <5390778.VeFRgus4bQ@positron.chronox.de> <20191119124150.GB1975017@kroah.com> <19681012.svDddlc5pN@positron.chronox.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <19681012.svDddlc5pN@positron.chronox.de> Content-Language: en-PH Sender: linux-kernel-owner@vger.kernel.org To: =?UTF-8?Q?Stephan_M=c3=bcller?= , Greg Kroah-Hartman Cc: Andy Lutomirski , Arnd Bergmann , Linux Crypto Mailing List , LKML , Linux API , "Eric W. Biederman" , "Ahmed S. Darwish" , "Theodore Y. Ts'o" , Willy Tarreau , Matthew Garrett , Vito Caputo , Andreas Dilger , Jan Kara , Ray Strode , William Jon McCann , zhangjs , Florian Weimer , Lennart Poettering , Nicolai Stange , "Peter, Matthias" List-Id: linux-api@vger.kernel.org 20.11.2019 13:58, Stephan Müller пишет: > Or another idea and apologies if I restart this conversation as there was > already a discussion around it: what about extending the getrandom(2) call > instead of adding a device file? > > What about adding yet another flag to getrandom: GRND_TRUERANDOM and process > it as follows: > > if (flags & ~(GRND_NONBLOCK|GRND_RANDOM|GRND_INSECURE| > GRND_TRUERANDOM)) > return -EINVAL; > > //From Andy's tree > /* > * Requesting insecure and blocking randomness at the same time makes > * no sense. > */ > if ((flags & (GRND_INSECURE|GRND_RANDOM)) == (GRND_INSECURE| > GRND_RANDOM)) > return -EINVAL; > > /* We only allow GRND_TRUERANDOM by itself or with NONBLOCK */ > if (! ((flags & GRND_TRUERANDOM) && > ((flags == GRND_TRUERANDOM) || > (flags == GRND_TRUERANDOM | GRND_NONBLOCK)))) > return -EINVAL; > > if (flags & GRND_TRUERANDOM) { > ... do the TRNG processing ... > ... may return -ENOPNOTSUPP if no TRNG available ... > } This would totally miss the point of adding a device node: UNIX permissions that don't allow "others" to read and deplete "true" random numbers. -- Alexander E. Patrakov