From: Anton Blanchard <anton@samba.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Christoph Hellwig <hch@infradead.org>,
Arjan van de Ven <arjan@infradead.org>,
Roman Zippel <zippel@linux-m68k.org>,
David Brown <dmlb2000@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
gdb@sourceware.org
Subject: Re: PAGE_SIZE Availability Inconsistency
Date: Thu, 8 Mar 2007 15:46:12 -0600 [thread overview]
Message-ID: <20070308214612.GB4154@kryten> (raw)
In-Reply-To: <20070308214236.GA4154@kryten>
Hi,
> Our current swap layout has issues with variable page size kernels.
> Instead of using the page size at runtime, base it on the minimum page
> size the architecture supports.
A hacked up patch to userspace utilities to test the kernel patch. BTW
It looks like there are some real bugs here:
int pagesize = getpagesize();
int rd;
char buf[32768];
rd = pagesize;
if (rd < 8192)
rd = 8192;
if (rd > sizeof(buf))
rd = sizeof(buf);
if (lseek(fd, 0, SEEK_SET) != 0
|| read(fd, buf, rd) != rd)
goto io_error;
if (may_be_swap(buf+pagesize) ||
may_be_swap(buf+4096) || may_be_swap(buf+8192))
type = "swap";
If page size == 64kB wont we read past the end of buf?
Anton
Index: util-linux-2.12r/disk-utils/mkswap.c
===================================================================
--- util-linux-2.12r.orig/disk-utils/mkswap.c 2007-03-08 14:52:53.000000000 -0600
+++ util-linux-2.12r/disk-utils/mkswap.c 2007-03-08 14:58:09.000000000 -0600
@@ -169,7 +158,11 @@
#ifdef PAGE_SIZE
defined_pagesize = PAGE_SIZE;
#endif
+#ifdef __powerpc__
+ kernel_pagesize = 4096;
+#else
kernel_pagesize = getpagesize();
+#endif
pagesize = kernel_pagesize;
if (user_pagesize) {
Index: util-linux-2.12r/mount/get_label_uuid.c
===================================================================
--- util-linux-2.12r.orig/mount/get_label_uuid.c 2007-03-08 14:52:53.000000000 -0600
+++ util-linux-2.12r/mount/get_label_uuid.c 2007-03-08 14:58:09.000000000 -0600
@@ -79,7 +79,11 @@
static int
is_v1_swap_partition(int fd, char **label, char *uuid) {
+#ifdef __powerpc__
+ int n = 4096;
+#else
int n = getpagesize();
+#endif
char *buf = xmalloc(n);
struct swap_header_v1_2 *p = (struct swap_header_v1_2 *) buf;
Index: util-linux-2.12r/mount/mount_guess_fstype.c
===================================================================
--- util-linux-2.12r.orig/mount/mount_guess_fstype.c 2007-03-08 14:52:53.000000000 -0600
+++ util-linux-2.12r/mount/mount_guess_fstype.c 2007-03-08 14:54:25.000000000 -0600
@@ -462,7 +462,11 @@
if (!type) {
/* perhaps the user tries to mount the swap space
on a new disk; warn her before she does mke2fs on it */
+#ifdef __powerpc__
+ int pagesize = 4096;
+#else
int pagesize = getpagesize();
+#endif
int rd;
char buf[32768];
Index: util-linux-2.12r/rescuept/rescuept.c
===================================================================
--- util-linux-2.12r.orig/rescuept/rescuept.c 2007-03-08 14:52:53.000000000 -0600
+++ util-linux-2.12r/rescuept/rescuept.c 2007-03-08 14:55:49.000000000 -0600
@@ -510,7 +510,11 @@
size = s.st_size / 512;
}
+#ifdef __powerpc__
+ pagesize = 4096;
+#else
pagesize = getpagesize();
+#endif
if (pagesize <= 0)
pagesize = 4096;
else if (pagesize > MAXPAGESZ) {
next prev parent reply other threads:[~2007-03-08 21:47 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-05 23:55 PAGE_SIZE Availability Inconsistency David Brown
2007-03-05 23:59 ` Eric Dumazet
2007-03-06 0:01 ` Randy Dunlap
2007-03-06 0:03 ` David Miller
2007-03-06 0:04 ` David Brown
2007-03-06 0:26 ` David Miller
2007-03-06 2:21 ` H. Peter Anvin
2007-03-08 21:08 ` Avi Kivity
2007-03-08 22:21 ` H. Peter Anvin
2007-03-19 19:39 ` Eric W. Biederman
2007-03-06 9:29 ` Christoph Hellwig
2007-03-08 2:18 ` Roman Zippel
2007-03-08 5:28 ` David Brown
2007-03-08 8:32 ` Christoph Hellwig
2007-03-08 9:00 ` Christoph Hellwig
2007-03-08 15:53 ` Arjan van de Ven
2007-03-08 16:08 ` Christoph Hellwig
2007-03-08 16:21 ` Daniel Jacobowitz
2007-03-08 17:05 ` H. Peter Anvin
2007-03-08 17:12 ` Christoph Hellwig
2007-03-08 17:57 ` Anton Blanchard
2007-03-08 18:04 ` H. Peter Anvin
2007-03-08 21:42 ` Anton Blanchard
2007-03-08 21:46 ` Anton Blanchard [this message]
2007-03-08 21:48 ` David Miller
2007-03-09 2:43 ` Anton Blanchard
2007-03-09 4:18 ` H. Peter Anvin
2007-03-09 4:27 ` David Miller
2007-03-09 4:31 ` H. Peter Anvin
2007-03-09 4:36 ` David Miller
2007-03-21 2:12 ` Anton Blanchard
2007-03-21 2:48 ` H. Peter Anvin
2007-03-08 22:22 ` H. Peter Anvin
2007-03-08 21:03 ` David Brown
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=20070308214612.GB4154@kryten \
--to=anton@samba.org \
--cc=arjan@infradead.org \
--cc=dmlb2000@gmail.com \
--cc=gdb@sourceware.org \
--cc=hch@infradead.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zippel@linux-m68k.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