From: Marcus Sundberg <marcus@cendio.se>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] removal of "static foo = 0"
Date: 27 Nov 2000 22:27:00 +0100 [thread overview]
Message-ID: <vey9y5umvv.fsf@lipta.cendio.se> (raw)
In-Reply-To: <200011270556.VAA12506@baldur.yggdrasil.com> <20001127094139.H599@almesberger.net> <200011270839.AAA28672@pizda.ninka.net> <20001127182113.A15029@athlon.random> <20001127182113.A15029@athlon.random> <20001127123655.A16930@munchkin.spectacle-pond.org>
In-Reply-To: meissner@spectacle-pond.org's message of "Mon, 27 Nov 2000 12:36:55 -0500"
meissner@spectacle-pond.org (Michael Meissner) writes:
> On Mon, Nov 27, 2000 at 06:21:13PM +0100, Andrea Arcangeli wrote:
> > On Mon, Nov 27, 2000 at 12:39:55AM -0800, David S. Miller wrote:
> > > Also I believe linkers are allowed to arbitrarily reorder members in
> > > the data and bss sections. I could be wrong on this one though.
> >
> > I'm not sure either, but we certainly rely on that behaviour somewhere.
> > Just to make an example fs/dquot.c:
> >
> > int nr_dquots, nr_free_dquots;
> >
> > kernel/sysctl.c:
> >
> > {FS_NRDQUOT, "dquot-nr", &nr_dquots, 2*sizeof(int),
> >
> > The above is ok also on mips in practice though.
>
> That needs to be fixed ASAP to use an array (not a structure). It is simply
> wrong to depend on two variables winding up in at adjacent offsets.
This reminded me of an old bug which apparently still hasn't been
fixed (not in 2.2 at least). In init/main.c we have:
extern int rd_image_start; /* starting block # of image */
#ifdef CONFIG_BLK_DEV_INITRD
kdev_t real_root_dev;
#endif
#endif
int root_mountflags = MS_RDONLY;
and then in kernel/sysctl.c:
#ifdef CONFIG_BLK_DEV_INITRD
{KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int),
0644, NULL, &proc_dointvec},
#endif
Because rd_image_start and root_mountflags are both int-aligned,
this happens to work on little endian platforms. On big endian
platforms however writing a value in the range 0-65535 to
/proc/sys/kernel/real-root-dev will place 0 in real_root_dev,
and the actual value in the two padding bytes...
(Yes, I'm one of the few that have actually used this feature. ;-)
Unfortunately proc_dointvec() doesn't support shorts, so what is
the correct fix? Changing:
kdev_t real_root_dev;
into
int real_root-dev;
is a perfectly working solution, but is it acceptable?
//Marcus
--
-------------------------------+-----------------------------------
Marcus Sundberg | Phone: +46 707 452062
Embedded Systems Consultant | Email: marcus@cendio.se
Cendio Systems AB | http://www.cendio.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-11-27 21:57 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-27 5:56 [PATCH] removal of "static foo = 0" Adam J. Richter
2000-11-27 8:41 ` Werner Almesberger
2000-11-27 8:39 ` David S. Miller
2000-11-27 9:08 ` Werner Almesberger
2000-11-27 17:21 ` Andrea Arcangeli
2000-11-27 17:36 ` Michael Meissner
2000-11-27 19:06 ` Andrea Arcangeli
2000-11-27 19:34 ` Richard B. Johnson
2000-11-28 0:28 ` Andrea Arcangeli
2000-11-28 11:25 ` Horst von Brand
2000-11-28 3:10 ` kumon
2000-11-28 3:28 ` Andrea Arcangeli
2000-11-28 3:35 ` Alexander Viro
2000-11-28 4:15 ` Michael Meissner
2000-11-28 9:55 ` Andreas Schwab
2000-11-28 15:16 ` Andrea Arcangeli
2000-11-28 16:09 ` Andreas Schwab
2000-11-28 19:29 ` Andrea Arcangeli
2000-11-28 16:44 ` Michael Meissner
2000-11-27 21:27 ` Marcus Sundberg [this message]
2000-11-28 0:49 ` real_root_dev Andries Brouwer
2000-11-27 18:11 ` [PATCH] removal of "static foo = 0" Richard B. Johnson
2000-11-27 18:01 ` Michael Meissner
-- strict thread matches above, loose matches on Subject: below --
2000-11-26 17:53 Elmer Joandi
2000-11-26 18:36 ` Alexander Viro
2000-11-26 19:11 ` Elmer Joandi
2000-11-26 22:49 ` Rogier Wolff
2000-11-26 15:15 Adam J. Richter
2000-11-25 20:19 Andries Brouwer
2000-11-25 21:07 ` Russell King
2000-11-25 21:29 ` Andries Brouwer
2000-11-26 1:19 ` Russell King
2000-11-25 22:11 ` Herbert Xu
2000-11-25 22:46 ` Andries Brouwer
2000-11-25 22:53 ` James A Sutherland
2000-11-25 23:55 ` Tim Waugh
2000-11-26 3:10 ` James A Sutherland
2000-11-26 10:37 ` Tigran Aivazian
2000-11-26 14:52 ` Philipp Rumpf
2000-11-28 0:01 ` Peter Samuelson
2000-11-27 4:00 ` Michael Meissner
2000-11-25 23:02 ` Jeff Garzik
2000-11-26 2:08 ` Andries Brouwer
2000-11-26 9:22 ` Martin Mares
2000-11-25 23:33 ` Herbert Xu
2000-11-27 10:03 ` Helge Hafting
2000-11-27 20:33 ` Albert D. Cahalan
2000-11-27 22:57 ` Russell King
2000-11-29 1:46 ` Albert D. Cahalan
2000-11-29 3:21 ` Peter Samuelson
2000-11-29 7:25 ` Russell King
2000-11-25 22:27 ` Tigran Aivazian
2000-11-26 1:32 ` Andries Brouwer
2000-11-26 2:11 ` Georg Nikodym
2000-11-26 4:25 ` Alan Cox
2000-11-26 5:01 ` John Alvord
2000-11-26 5:10 ` Andre Hedrick
2000-11-26 6:22 ` Keith Owens
2000-11-26 6:28 ` Andre Hedrick
2000-11-26 10:43 ` Tigran Aivazian
2000-11-26 10:52 ` Tigran Aivazian
2000-11-24 7:47 ` Pavel Machek
2000-11-26 14:32 ` bert hubert
2000-11-26 10:52 ` Rogier Wolff
2000-11-26 14:13 ` Philipp Rumpf
2000-11-26 15:19 ` Georg Nikodym
2000-11-26 20:47 ` H. Peter Anvin
2000-11-27 21:12 ` Kai Henningsen
2000-11-26 6:21 ` Werner Almesberger
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=vey9y5umvv.fsf@lipta.cendio.se \
--to=marcus@cendio.se \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox