mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -mm 0/2] swsusp fixes
@ 2006-02-15 13:34 Rafael J. Wysocki
  2006-02-15 13:45 ` [PATCH -mm 1/2] swsusp: userland interface fixes Rafael J. Wysocki
  2006-02-15 13:51 ` [PATCH -mm 2/2] swsusp: fix writing progress meter Rafael J. Wysocki
  0 siblings, 2 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2006-02-15 13:34 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Pavel Machek, LKML

Hi,

The following patches fix some bugs I've found recently in swsusp.  They don't
affect the mainline code.

Please apply.

Greetings,
Rafael


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH -mm 1/2] swsusp: userland interface fixes
  2006-02-15 13:34 [PATCH -mm 0/2] swsusp fixes Rafael J. Wysocki
@ 2006-02-15 13:45 ` Rafael J. Wysocki
  2006-02-15 13:51 ` [PATCH -mm 2/2] swsusp: fix writing progress meter Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2006-02-15 13:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Pavel Machek, LKML

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)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH -mm 2/2] swsusp: fix writing progress meter
  2006-02-15 13:34 [PATCH -mm 0/2] swsusp fixes Rafael J. Wysocki
  2006-02-15 13:45 ` [PATCH -mm 1/2] swsusp: userland interface fixes Rafael J. Wysocki
@ 2006-02-15 13:51 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2006-02-15 13:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Pavel Machek, LKML

Due to the wrong value passed to load_image() in swap.c the writing progress
meter could run over 100%.  Fix it.


Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/swap.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

Index: linux-2.6.16-rc3-mm1/kernel/power/swap.c
===================================================================
--- linux-2.6.16-rc3-mm1.orig/kernel/power/swap.c	2006-02-14 23:08:49.000000000 +0100
+++ linux-2.6.16-rc3-mm1/kernel/power/swap.c	2006-02-14 23:09:26.000000000 +0100
@@ -467,7 +467,6 @@ int swsusp_read(void)
 	struct swap_map_handle handle;
 	struct snapshot_handle snapshot;
 	struct swsusp_info *header;
-	unsigned int nr_pages;
 
 	if (IS_ERR(resume_bdev)) {
 		pr_debug("swsusp: block device not initialised\n");
@@ -482,10 +481,8 @@ int swsusp_read(void)
 	error = get_swap_reader(&handle, swsusp_header.image);
 	if (!error)
 		error = swap_read_page(&handle, header);
-	if (!error) {
-		nr_pages = header->image_pages;
-		error = load_image(&handle, &snapshot, nr_pages);
-	}
+	if (!error)
+		error = load_image(&handle, &snapshot, header->pages - 1);
 	release_swap_reader(&handle);
 
 	blkdev_put(resume_bdev);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-15 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-15 13:34 [PATCH -mm 0/2] swsusp fixes Rafael J. Wysocki
2006-02-15 13:45 ` [PATCH -mm 1/2] swsusp: userland interface fixes Rafael J. Wysocki
2006-02-15 13:51 ` [PATCH -mm 2/2] swsusp: fix writing progress meter Rafael J. Wysocki

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®