lkml.org 
[lkml]   [2019]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] kobject: return -ENOSPC when add_uevent_var() fails
On Tue, Jun 11, 2019 at 06:09:24AM +0900, Masahiro Yamada wrote:
> This function never attempts to allocate memory, so returning -ENOMEM
> looks weird to me. The reason of the failure is there is no more space
> in the given kobj_uevent_env structure.
>
> Let's change the error code to -ENOSPC.
>
> This patch is safe since this function had never failed in reality.
>
> The callers of this function put a fixed number of small strings into
> the buffer.
>
> The buffer is defined to be large enough:
>
> #define UEVENT_NUM_ENVP 32 /* number of env pointers */
> #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
>
> As you see WARN() in the error paths, any failure of this function is
> a software bug.
>
> If such a case had ever happened before, you would have already seen
> a noisy back-trace, then you would have increased UEVENT_NUM_ENVP or
> UEVENT_BUFFER_SIZE.
>
> Nobody has ever increased UEVENT_NUM_ENVP or UEVENT_BUFFER_SIZE since
> their addition, that is, this structure is always large enough.

That implies that we should just drop the WARN() entirely. Especially
given that syzbot runs panic-on-warn, right?

How about doing both things at the same time?

thanks,

greg k-h

\
 
 \ /
  Last update: 2019-06-19 19:26    [W:0.038 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site