linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gergely Nagy <algernon@gandalph.mad.hu>
To: linux-kernel@vger.kernel.org
Cc: Gergely Nagy <algernon@gandalph.mad.hu>
Subject: [devfs] Use before initialisation in devfs_mk_cdev()
Date: Thu, 17 Jul 2003 01:53:42 +0200	[thread overview]
Message-ID: <83he5mm3jt.wl@iluvatar.bonehunter.rulez.org> (raw)

Hi!

While playing around with implementing my first linux 2.5 module, I
stumbled upon a buglet in devfs (though, if used properly, it probably
won't surface ever). The problem - as I see it - is that
devfs_mk_cdev() first checks the mode passed to it, and if it thinks
it is not a char device, it prints a warning and aborts. Now, this
printing involves the local variable `buf' (char buf[64]), which is
not initialised at that point.

The problematic code is:

int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
{
	struct devfs_entry *dir = NULL, *de;
	char buf[64];
	va_list args;
	int error, n;

	if (!S_ISCHR(mode)) {
		printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
				__FUNCTION__, mode, buf);
		return -EINVAL;
	}

One option would be to try to initialise buf earlier, another would be
to just remove the "for %s" part, and the buf reference in the printk
(but that way, some information would be lost).

Anyways, I just noticed that when my buggy code called devfs_mk_cdev
(blah, 0, etc..) it printed garbage on module insertion, so I thought
I'd drop a notice.

Oh, this is with Linux 2.6.0-test1-mm1.

Cheers,
-- 
Gergely Nagy

             reply	other threads:[~2003-07-16 23:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-16 23:53 Gergely Nagy [this message]
2003-07-18 11:33 ` Christoph Hellwig

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=83he5mm3jt.wl@iluvatar.bonehunter.rulez.org \
    --to=algernon@gandalph.mad.hu \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [devfs] Use before initialisation in devfs_mk_cdev()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).