From: Kay Sievers <kay.sievers@vrfy.org>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Greg KH <greg@kroah.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix kobject uevent string handling errors
Date: Sat, 25 Aug 2007 16:25:37 +0200 [thread overview]
Message-ID: <1188051937.2493.21.camel@lov.localdomain> (raw)
In-Reply-To: <20070825041754.GA18557@Krystal>
[-- Attachment #1: Type: text/plain, Size: 2757 bytes --]
On Sat, 2007-08-25 at 00:17 -0400, Mathieu Desnoyers wrote:
> Fix kobject uevent string handling errors
> - add warnings when add_uevent_var. Proper handling of its return values should
> really be done by the callers, but they aren't, so things currently
> fail silently.
Right, I added the checks to kobject_uevent.c now. There are still
checks missing in:
arch/powerpc/kernel/vio.c
block/genhd.c
drivers/base/class.c
drivers/base/core.c
drivers/base/platform.c
drivers/eisa/eisa-bus.c
drivers/ide/ide.c
drivers/scsi/scsi_sysfs.c
drivers/spi/spi.c
We should fix them with a separate patch, and mark add_uevent_var() as
__must_check.
> --- linux-2.6-lttng.orig/lib/kobject_uevent.c 2007-08-25 00:07:41.000000000 -0400
> +++ linux-2.6-lttng/lib/kobject_uevent.c 2007-08-25 00:12:23.000000000 -0400
> @@ -247,8 +247,12 @@ int add_uevent_var(struct kobj_uevent_en
> va_list args;
> int len;
>
> - if (env->envp_idx >= ARRAY_SIZE(env->envp))
> + if (env->envp_idx >= ARRAY_SIZE(env->envp)) {
> + printk("add_uevent_var: too small array size %u %u\n",
> + env->envp_idx, ARRAY_SIZE(env->envp));
> + WARN_ON(1);
> return -ENOMEM;
> + }
I added a warning to the patch.
> va_start(args, format);
> len = vsnprintf(&env->buf[env->buflen],
> @@ -256,8 +260,12 @@ int add_uevent_var(struct kobj_uevent_en
> format, args);
> va_end(args);
>
> - if (len + 1 >= (sizeof(env->buf) - env->buflen))
> + if (len >= (sizeof(env->buf) - env->buflen)) {
This is already in Greg's tree.
> + printk("add_uevent_var: failed vsnprintf %d %u\n",
> + len, (sizeof(env->buf) - env->buflen));
> + WARN_ON(1);
> return -ENOMEM;
> + }
I added a warning to the patch.
> env->envp[env->envp_idx++] = &env->buf[env->buflen];
> env->buflen += len + 1;
> Index: linux-2.6-lttng/drivers/firmware/dmi-id.c
> ===================================================================
> --- linux-2.6-lttng.orig/drivers/firmware/dmi-id.c 2007-08-25 00:07:24.000000000 -0400
> +++ linux-2.6-lttng/drivers/firmware/dmi-id.c 2007-08-25 00:07:58.000000000 -0400
> @@ -152,9 +152,10 @@ static int dmi_dev_uevent(struct device
> if (add_uevent_var(env, "MODALIAS="))
> return -ENOMEM;
> len = get_modalias(&env->buf[env->buflen - 1],
> - sizeof(env->buf) - env->buflen);
> - if (len >= (sizeof(env->buf) - env->buflen))
> + sizeof(env->buf) - (env->buflen - 1));
> + if (len >= (sizeof(env->buf) - (env->buflen - 1)))
> return -ENOMEM;
> + env->buflen += len + 1;
The increment for the trailing '\0' is already done in add_uevent_var(),
so this change is not needed, I think.
Greg,
the attached file replaces the one in your patch tree. It contains the
printk warning and a few checks for return values.
Thanks,
Kay
[-- Attachment #2: driver-core-change-add_uevent_var-to-use-a-struct.patch --]
[-- Type: application/mbox, Size: 68677 bytes --]
next prev parent reply other threads:[~2007-08-25 14:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-24 22:47 kernel BUG with 2.6.23-rc3-mm1: skb_over_panic Mathieu Desnoyers
2007-08-24 23:10 ` Andrew Morton
2007-08-24 23:46 ` Greg KH
2007-08-25 0:16 ` Mathieu Desnoyers
2007-08-25 0:44 ` Andrew Morton
2007-08-25 0:46 ` Greg KH
2007-08-25 1:26 ` Kay Sievers
2007-08-25 3:02 ` Mathieu Desnoyers
2007-08-25 3:44 ` Kay Sievers
2007-08-25 3:52 ` Mathieu Desnoyers
2007-08-25 3:56 ` Mathieu Desnoyers
2007-08-25 3:58 ` Daniel Walker
2007-08-25 4:17 ` [PATCH] Fix kobject uevent string handling errors Mathieu Desnoyers
2007-08-25 4:49 ` Greg KH
2007-08-25 14:25 ` Kay Sievers [this message]
2007-08-25 18:38 ` Mathieu Desnoyers
2007-08-25 1:59 ` kernel BUG with 2.6.23-rc3-mm1: skb_over_panic Randy Dunlap
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=1188051937.2493.21.camel@lov.localdomain \
--to=kay.sievers@vrfy.org \
--cc=akpm@linux-foundation.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
/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®