From: Pavel Machek <pavel@ucw.cz>
To: Alexander Viro <viro@math.psu.edu>
Cc: Anders Gustafsson <andersg@0x63.nu>,
Linus Torvalds <torvalds@transmeta.com>,
linux-kernel@vger.kernel.org
Subject: alloc_struct()? Re: [RFC/PATCH] lvm sanitation in 2.5
Date: Sun, 26 May 2002 18:43:27 +0200 [thread overview]
Message-ID: <20020526164327.GB269@elf.ucw.cz> (raw)
In-Reply-To: <20020523011519.GA8521@h55p111.delphi.afb.lu.se> <Pine.GSO.4.21.0205222153040.4507-100000@weyl.math.psu.edu>
Hi!
> > I have started cleaning up lvm. The following patch contains the first
> > steps. It disables a lot of functionallity but the basic things are
> > there, I'm actually running a kernel with this patch right now, with
> > /home and /var on lvm. The vg_t/lv_t..-structures are now available in
> > to versions, one exported to userspace (and that should remain
> > constant through versions) and one used in kernelspace containing
> > stuff that should not be exposed to userspace (struct block_device,
> > kdev_t and such). (this also allows more flexibillity making changes
> > in the driver without changing the userspace interface). Should i
> > finish this patch? Would davej accept it?
>
> That's _very_ nice to see. I don't know about -dj, but it's definitely
> a step in right direction for the main tree.
>
> Other things that need to be done:
>
> a) propagate struct block_device * on the kernel side. It's not a trivial
> change - unlike kdev_t struct block_device * might leak. So you will need
> to add proper refcounting to uses in lvm*.c and from my fighting with
> lvm code I can say that it won't be easy.
>
> b) check all copy_{from,to}_user() in lvm for buffer overruns. The damn thing
> is choke-full of them - e.g. it happily assumes that
> n = <get a number from userland>;
> p = (struct foo *)kmalloc(n * sizeof(struct foo), ...);
> if (!p)
> return -ENOMEM;
> for (i = 0; i<n; i++) {
> copy_from_user(p+i, user_p+i, sizeof(struct foo));
> ...
> }
> is OK. It isn't - if value of n is slightly above 2^32/sizeof(struct foo)
> you will get fairly small argument of kmalloc() (multiplication is done
> modulo 2^32) and kmalloc() succeeds, allocating <small amount> instead of
> 4Gb + <small amount> assumed by the loop below.
Maybe p = alloc_struct(n, struct foo, GFP_WHATEVER) (and then using
this macro) is right way to tackle this problem?. Or maybe even
alloc_struct(p, n, GFP_WHATEVER)?
Pavel
--
(about SSSCA) "I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
next prev parent reply other threads:[~2002-05-26 16:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-23 1:15 Anders Gustafsson
2002-05-23 2:19 ` Alexander Viro
2002-05-26 16:43 ` Pavel Machek [this message]
2002-05-23 7:45 ` Joe Thornber
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=20020526164327.GB269@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=andersg@0x63.nu \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
--cc=viro@math.psu.edu \
/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®