From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@osdl.org>
Cc: Pavel Machek <pavel@suse.cz>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH -mm 1/2] swsusp: userland interface fixes
Date: Wed, 15 Feb 2006 14:45:09 +0100 [thread overview]
Message-ID: <200602151445.10395.rjw@sisk.pl> (raw)
In-Reply-To: <200602151434.03575.rjw@sisk.pl>
Fix two bugs in the swsusp userland interface:
1) Prevent the SNAPSHOT_FREE_SWAP_PAGES ioctl from leaking swap pages
due to the wrong condition.
2) Pevent snapshot_write_next() and snapshot_read_next() from using a freed
page (this could happend if the snapshot ioctls were called repeatedly
without closing the device, eg. when attempting to create the image for the
second time with image_size = 0).
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
kernel/power/snapshot.c | 5 ++---
kernel/power/user.c | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
Index: linux-2.6.16-rc3-mm1/kernel/power/user.c
===================================================================
--- linux-2.6.16-rc3-mm1.orig/kernel/power/user.c 2006-02-14 22:37:24.000000000 +0100
+++ linux-2.6.16-rc3-mm1/kernel/power/user.c 2006-02-14 22:38:07.000000000 +0100
@@ -237,7 +237,7 @@ static int snapshot_ioctl(struct inode *
break;
case SNAPSHOT_FREE_SWAP_PAGES:
- if (data->swap >= 0 && data->swap < MAX_SWAPFILES) {
+ if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
error = -ENODEV;
break;
}
Index: linux-2.6.16-rc3-mm1/kernel/power/snapshot.c
===================================================================
--- linux-2.6.16-rc3-mm1.orig/kernel/power/snapshot.c 2006-02-14 22:46:17.000000000 +0100
+++ linux-2.6.16-rc3-mm1/kernel/power/snapshot.c 2006-02-14 22:47:02.000000000 +0100
@@ -37,6 +37,7 @@
struct pbe *pagedir_nosave;
static unsigned int nr_copy_pages;
static unsigned int nr_meta_pages;
+static unsigned long *buffer;
#ifdef CONFIG_HIGHMEM
unsigned int count_highmem_pages(void)
@@ -421,6 +422,7 @@ void swsusp_free(void)
nr_copy_pages = 0;
nr_meta_pages = 0;
pagedir_nosave = NULL;
+ buffer = NULL;
}
@@ -573,8 +575,6 @@ static inline struct pbe *pack_orig_addr
int snapshot_read_next(struct snapshot_handle *handle, size_t count)
{
- static unsigned long *buffer;
-
if (handle->page > nr_meta_pages + nr_copy_pages)
return 0;
if (!buffer) {
@@ -779,7 +779,6 @@ static int create_image(struct snapshot_
int snapshot_write_next(struct snapshot_handle *handle, size_t count)
{
- static unsigned long *buffer;
int error = 0;
if (handle->prev && handle->page > nr_meta_pages + nr_copy_pages)
next prev parent reply other threads:[~2006-02-15 14:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-15 13:34 [PATCH -mm 0/2] swsusp fixes Rafael J. Wysocki
2006-02-15 13:45 ` Rafael J. Wysocki [this message]
2006-02-15 13:51 ` [PATCH -mm 2/2] swsusp: fix writing progress meter Rafael J. Wysocki
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=200602151445.10395.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
/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®