summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2018-05-26 09:59:36 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-17 11:39:32 +0200
commit140eae92cf7023422aec3a1647f78c1e0bdd6bf8 (patch)
tree2281ba31911675d25c080f7954442c173dba4877
parent6f9f5797fc7de2e9f801b2f7af0726e1349d33a4 (diff)
downloadlinux-stable-140eae92cf7023422aec3a1647f78c1e0bdd6bf8.tar.gz
linux-stable-140eae92cf7023422aec3a1647f78c1e0bdd6bf8.tar.bz2
linux-stable-140eae92cf7023422aec3a1647f78c1e0bdd6bf8.zip
PM / hibernate: Fix oops at snapshot_write()
commit fc14eebfc20854a38fd9f1d93a42b1783dad4d17 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--kernel/power/user.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 22df9f7ff672..69017a569f30 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -186,6 +186,11 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
res = PAGE_SIZE - pg_offp;
}
+ if (!data_of(data->handle)) {
+ res = -EINVAL;
+ goto unlock;
+ }
+
res = simple_write_to_buffer(data_of(data->handle), res, &pg_offp,
buf, count);
if (res > 0)