From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v2] kobject: return -ENOSPC when add_uevent_var() fails
Date: Wed, 19 Jun 2019 19:26:18 +0200 [thread overview]
Message-ID: <20190619172618.GB24692@kroah.com> (raw)
In-Reply-To: <20190610210924.9514-1-yamada.masahiro@socionext.com>
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
prev parent reply other threads:[~2019-06-19 17:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 21:09 Masahiro Yamada
2019-06-19 17:26 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190619172618.GB24692@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®