Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2044359imm; Mon, 16 Jul 2018 00:47:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/d6o26OqfikXK0TTfvt2q9vWVzgMkqlTlZnurzsNeWHr6CoMTc+j6kq/apFWDMs3ELUJl X-Received: by 2002:a17:902:292b:: with SMTP id g40-v6mr15858091plb.273.1531727265051; Mon, 16 Jul 2018 00:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727265; cv=none; d=google.com; s=arc-20160816; b=hvB1KYxdSZEMn/tp/T9iWG9EEJogjxEFVAcrVpC1ifbAtXlhK+eaLiD3XwjXzOA/ZK 5caK7WzyevLo5bXPnzACALv5rTTbi+Rv81TuoXBhYJPdntSdxmVaVjCg2fflb/EaXdx3 b+TTSmXVuJBECUj/f/1hzBvm7d8VTLm85HEb3FbcRI7GLqih5YaTLeMYeTVWr4Q6fcjF DggNozAPTTJivX0ppdvnsexxLDThQTE1IZX7YqCE1k9zFBGf78jrDebM8WH5/Xsi1xQf hWOf8z1P+q0xjF2qdhXI138rGYQ2h3cbSAzuxg85IPjYi1uAahn3MDl14OcxQ0Wx59aY v01w== 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=ugSGGD5aBEyW2e3pxF76BXeGyo2tm4pvWAHGVKU5CQo=; b=D6scKITH1JTynuusw2w9U8qm4Z8euWWBy8zNw/X8fnkCY9WVhqk+vlylaB9PqhHXs1 lK0tQAmv0fCzEBXtpZpwJdq/OGqhWXfDCm/Lx4hDF2ptKI8wiHowMi74rOX14Ru/yzdH eT5CeiqgboC1xNXIzqO8ds7if+q3fut/CIeM0VwmfWOLhF5e9v0VzeqMBhDBGHZ/QAz7 zyXI+X5K46UxVfzwSbXvWcfDboCRbFbfShqI4FwXE2ezD9YDzQJTkTmCL1QT0/Jr5dU8 C1SKFyv91NkaJEUavhs7IDcAmyhxtQVnhZjMC/RLr0L9CCFTaQsZQmVGgTdkstdsStHe JEdQ== 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 b2-v6si4358546plk.111.2018.07.16.00.47.30; Mon, 16 Jul 2018 00:47:45 -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 S2389636AbeGPILf (ORCPT + 99 others); Mon, 16 Jul 2018 04:11:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49966 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389282AbeGPILe (ORCPT ); Mon, 16 Jul 2018 04:11:34 -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 E6656CA5; Mon, 16 Jul 2018 07:45:29 +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.4 41/43] PM / hibernate: Fix oops at snapshot_write() Date: Mon, 16 Jul 2018 09:36:46 +0200 Message-Id: <20180716073516.396575837@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073511.796555857@linuxfoundation.org> References: <20180716073511.796555857@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.4-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 @@ -184,6 +184,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)