Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2042485imm; Mon, 16 Jul 2018 00:44:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdtK2vL1jkhD/Z3mv0l2u3QxAKxeZuIE0ZOUeAqO4w7VOzvPg47vZ0ijSkwUg27vqP7Sd0r X-Received: by 2002:a62:6941:: with SMTP id e62-v6mr17077869pfc.56.1531727092291; Mon, 16 Jul 2018 00:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727092; cv=none; d=google.com; s=arc-20160816; b=LvfFAqSdKp7MjyQn1rb4LXzRfPXHjPsJG+767NO6+PNPBb2KX1E2KwYlgy9BnBK0Ux Xe/KLiKYO/QZYDzWz+RyswLE7eOgN5ZE4tiOWRTfDJ4jeTKKm3JyJTtCmVFOFY3gUHpm yyoSdmVcCmGIPSZpgU4ZLo85GIPOzwrgJ1T8yXwJrfhm7CRgceHK16x8vI6ix6K6mYm1 5pyy9CWXM4CJ3hHO6XVo+h9mh8+x0NhA31lI4/uvQMavpvSX6FUqsB9o17U5e1V8uqVq EEDZPq/X6OpA09QcXseECSUoUjd9PCpKWrgvCGUzJoyz3QNuIMInpMv611NqsP3wP5EV hwhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OPVH3N+c9w8fyLPNrVWzw09UYjg5xccbgsQaH9chDMg=; b=FmlBn/l+8bXkyY8K4ZJFXdiihXvMYj1Hit4EIoFcvm4liBWmonneVJdbLrHmb/gVGS QUN7+MZ8PncAbR/RjdPd+yx7NweSbojd8T+yVyNLCRV6Digl42Qb2AjLXyVnLKLF93Xw CYbILLd6zWoYcOQ1lgrBMnMQCZPwrrltNJ+jZYmLBHbyjulXzgpah8AQonT+N07IAJFj PPpLAvwVp3q8ymJ5li0tU4JCOXHQI7EPSRyut01AIS3QHC/bYiiu8mU9aPcAaaBK3hH6 t/cgEa7lRCjrZxDnWWiRJLntj6cqTJa0UrkBhmsNYbv+t0axNQMnR13jELJw2YZZersN VtqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n15-v6si29560271pgc.309.2018.07.16.00.44.37; Mon, 16 Jul 2018 00:44:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389019AbeGPIJZ (ORCPT + 99 others); Mon, 16 Jul 2018 04:09:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47992 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbeGPIJY (ORCPT ); Mon, 16 Jul 2018 04:09:24 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 519E0CA0; Mon, 16 Jul 2018 07:43:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , syzbot , "Rafael J. Wysocki" Subject: [PATCH 4.9 30/32] PM / hibernate: Fix oops at snapshot_write() Date: Mon, 16 Jul 2018 09:36:38 +0200 Message-Id: <20180716073508.208481961@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073504.433996952@linuxfoundation.org> References: <20180716073504.433996952@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa 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 Reported-by: syzbot Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- kernel/power/user.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/kernel/power/user.c +++ b/kernel/power/user.c @@ -186,6 +186,11 @@ static ssize_t snapshot_write(struct fil 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)