Re: [PATCH v2] random: allow partial reads if later user copies fail
From: Jason A. Donenfeld
Date: Fri Apr 08 2022 - 06:34:16 EST
Hi David,
On 4/8/22, David Laight <David.Laight@xxxxxxxxxx> wrote:
> From: Jason A. Donenfeld
>> Sent: 08 April 2022 00:36
>>
>> Rather than failing entirely if a copy_to_user() fails at some point,
>> instead we should return a partial read for the amount that succeeded
>> prior, unless none succeeded at all, in which case we return -EFAULT as
>> before.
>
> I think you now return -EFAULT for a zero length read.
The diff context doesn't show it, but the first line of the function
is `if (!nbytes) return 0;`, before various other bits of work are
done.
Jason