From: greg@kroah.com (Greg KH)
To: lm-sensors@vger.kernel.org
Subject: [PATCH 2.4] i2c-dev user/kernel bug and mem leak
Date: Thu, 19 May 2005 06:24:12 +0000 [thread overview]
Message-ID: <20030814190954.GA2492@kroah.com> (raw)
In-Reply-To: <20030806100702.78298ffe.khali@linux-fr.org>
On Thu, Aug 14, 2003 at 11:44:08AM -0700, Robert T. Johnson wrote:
> Thank you for looking at my bug report and proposed patch with such
> careful scrutiny! I think the mem leak fix you propose is fine, but I
> had an ulterior motive for writing the user/kernel fix as I did.
>
> The user/kernel bug was discovered by our automatic bug-finding tool,
> cqual, and my patch allowed i2c-dev.c to pass through cqual with no
> warnings. The new patch does not, because rdwr_pa[i].buf is sometimes a
> a user pointer and sometimes a kernel pointer, e.g. on i2c-dev.c, line
> 248:
>
>
> data_ptrs[i] = rdwr_pa[i].buf; // rdwr_pa[i].buf is user pointer
> rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL); // now it's kernel
>
>
> Cqual is not just a bug finder, it can verify the _absence_ of bugs. I
> think this is pretty cool. Imagine a kernel that can be automatically
> verified to have no user/kernel bugs. You'd never have to worry about
> user/kernel bugs again!
Hm, much like Linus's sparse does already? :)
> But like all automatic code verification tools, cqual imposes certain
> limits on the types of code you can write. For example, cqual doesn't
> allow a variable to sometimes hold a user pointer and sometimes hold a
> kernel pointer, like rdwr_pa[i].buf now does. The original patch avoids
> this, but the new patch doesn't for performance reasons. FWIW, I think
> Linus' checker will also fail to check the new patch.
His checker missed the 2.6 version of this, for some reason, I haven't
taken the time to figure out why.
How is cqual going to handle all of the tty drivers which can have a
pointer be either a userspace pointer, or a kernel pointer depending on
the value of another paramater in a function?
> So there's a trade-off here between performance and automatic code
> auditing. Considering that
>
> 1. The performance cost of the original patch is minor.
> 2. i2c-dev.c has had user/kernel bugs in the past.
> 3. This user/kernel bug was tricky and time consuming to understand.
4. no one really uses i2c-dev at all...
> After looking at your rewritten patch, I thought of a possibly cleaner
> way to make i2c-dev.c pass cqual without warnings. I've included it
> below. I'd like to work with the i2c developers to find a solution
> which can be automatically audited and that you like.
If you want to change the kernel to user interface like this, I suggest
you do this for 2.6 first, let's not disturb that interface during the
2.4 stable kernel series.
Want to re-do this patch against 2.6.0-test3?
Actually, why not just create a i2cfs for stuff like this and get rid of
the ioctl crap all together... Almost no one uses this (as is evident
by a lack of 64 bit translation layer logic), and ioctls are a giant
pain (as evidenced by the need for the 64 bit translation layer.) It
also forces users to program in languages that allow ioctls.
Anyway, just a thought, as I really do not like the logic in i2c-dev.c
at all...
Oh, this should be discussed on lkml too, not just the sensors mailing
list.
thanks,
greg k-h
next prev parent reply other threads:[~2005-05-19 6:24 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-03 17:23 PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and mem leak Jean Delvare
2005-05-19 6:24 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and Jean Delvare
2003-08-04 15:32 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and mem leak Sergey Vlasov
2005-05-19 6:24 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and Sergey Vlasov
2003-08-05 8:32 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and mem leak Jean Delvare
2005-05-19 6:24 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and Jean Delvare
2003-08-05 14:10 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and mem leak Sergey Vlasov
2005-05-19 6:24 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and Sergey Vlasov
2003-08-05 21:07 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and mem leak Greg KH
2005-05-19 6:24 ` PATCH: 2.4.22-pre7 drivers/i2c/i2c-dev.c user/kernel bug and mem Greg KH
2003-08-06 8:07 ` [PATCH 2.4] i2c-dev user/kernel bug and mem leak Jean Delvare
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Greg KH [this message]
2003-08-15 2:01 ` Robert T. Johnson
2005-05-19 6:24 ` Robert T. Johnson
2003-08-15 21:13 ` Greg KH
2005-05-19 6:24 ` Greg KH
2003-08-15 22:17 ` Robert T. Johnson
2005-05-19 6:24 ` Robert T. Johnson
2003-08-15 23:51 ` Greg KH
2005-05-19 6:24 ` Greg KH
2003-08-18 0:54 ` Robert T. Johnson
2005-05-19 6:24 ` Robert T. Johnson
2003-08-18 21:05 ` Greg KH
2005-05-19 6:24 ` Greg KH
2003-09-10 23:02 ` CQual 0.99 Released: user/kernel pointer bug finding tool Robert T. Johnson
2003-08-28 1:17 ` [PATCH 2.4] i2c-dev user/kernel bug and mem leak Robert T. Johnson
2005-05-19 6:24 ` Robert T. Johnson
2003-08-29 16:21 ` Jean Delvare
2005-05-19 6:24 ` Jean Delvare
2003-08-29 17:30 ` Robert T. Johnson
2005-05-19 6:24 ` Robert T. Johnson
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Greg KH
2005-05-19 6:24 ` Robert T. Johnson
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=20030814190954.GA2492@kroah.com \
--to=greg@kroah.com \
--cc=lm-sensors@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.