Skip to content

Commit fc14eeb

Browse files
Tetsuo Handarafaeljw
authored andcommitted
PM / hibernate: Fix oops at snapshot_write()
syzbot is reporting NULL pointer dereference at snapshot_write() [1]. This is because data->handle is zero-cleared by ioctl(SNAPSHOT_FREE). Fix this by checking data_of(data->handle) != NULL before using it. [1] https://syzkaller.appspot.com/bug?id=828a3c71bd344a6de8b6a31233d51a72099f27fd Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Reported-by: syzbot <syzbot+ae590932da6e45d6564d@syzkaller.appspotmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 62fc00a commit fc14eeb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/power/user.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
186186
res = PAGE_SIZE - pg_offp;
187187
}
188188

189+
if (!data_of(data->handle)) {
190+
res = -EINVAL;
191+
goto unlock;
192+
}
193+
189194
res = simple_write_to_buffer(data_of(data->handle), res, &pg_offp,
190195
buf, count);
191196
if (res > 0)

0 commit comments

Comments
 (0)