Skip to contentSkip to conversation

PM: hibernate: Fix partial snapshot reads

PATCH Applied Avi Weiss 2 participants 2 messages Nov 15 – Nov 20

Subsystems (2)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 PM: hibernate: Fix partial snapshot reads

After a partial read, snapshot_read() passes the remaining page length to simple_read_from_buffer(). The helper interprets this length as the total buffer size and subtracts the offset again, causing premature EOF while image data remains unread.

Pass PAGE_SIZE so the helper accounts for the offset only once.

Fixes d3c1b24c50e8 ("PM / Hibernate: Snapshot cleanup")
---
 kernel/power/user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/user.c +1 -1
index 6e4f40e49319..d5e2b8d0b55b 100644
@@ -154,7 +154,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
 		if (res <= 0)
 			goto Unlock;
 	} else {
-		res = PAGE_SIZE - pg_offp;
+		res = PAGE_SIZE;
 	}
 
 	res = simple_read_from_buffer(buf, count, &pg_offp,

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa

Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 20 lines · Avi Weiss

After a partial read, snapshot_read() passes the remaining page length to simple_read_from_buffer(). The helper interprets this length as the total buffer size and subtracts the offset again, causing premature EOF while image data remains unread.

Pass PAGE_SIZE so the helper accounts for the offset only once.

Fixes d3c1b24c50e8 ("PM / Hibernate: Snapshot cleanup")
---
 kernel/power/user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/user.c +0 -0
index 6e4f40e49319..d5e2b8d0b55b 100644

kernel/power/user.c static ssize_t snapshot_read(struct file *filp, char __user *buf, · line 160

Quoted 8 lines
kernel/power/user.c +1 -1
@@ -154,7 +154,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
                if (res <= 0)
                        goto Unlock;
        } else {
-               res = PAGE_SIZE - pg_offp;
+               res = PAGE_SIZE;
        }
 
        res = simple_read_from_buffer(buf, count, &pg_offp,

Applied as 7.5 material, thanks!