Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2039822imm; Mon, 16 Jul 2018 00:40:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcE3tQbAqZvjCmOa/OP3HGWBmJtrJAunm1WgA1qwRV08D5SGsi8CP/bCnpKnFgU0x2jwq+j X-Received: by 2002:a17:902:e281:: with SMTP id cf1-v6mr15674441plb.293.1531726858393; Mon, 16 Jul 2018 00:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531726858; cv=none; d=google.com; s=arc-20160816; b=daQIKDD+jaX+XHREcRkIPP1UdMKTL26i+i90q9bnEJmDrsO0EUSP/hWnsOHXdXrivj pDaZTx2J+n7jXcTSG8atkPvT93yk/z9UQLjEuA9Ilojol/ndr+baug/bWvLNtKdrmD/i gvHdbSb5msxy4TXi+q1HDMmcZES5ynr2uMNMmbHlPSTZxjJz940zR9Ras0PPpdp79rS6 UOMvaLJd9EhDfsH7d7a6wCrGqxaxvVJzFYsJQhUj5HMCt2ybL/ejbEAs0o7p1jWQnCr5 riy1hpf97eq9vypveO9tjlbzCpwLpMso5ZnwaZuDTJhRHEB5eayEMoAzSS+mFap4IILO APyA== 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=SWiIMEJFJsxcLeF2qFpHaR4vD/6IDFx7QJp5ybDhHKY=; b=N/llT2YGVNhFQkQ4IzZoQPIUSELM0uu56CajdAufpTkZ4RcayNM89mdJ3W0wm3t+Ei z4W1iTqP+0EDPvNXyAixVuAQNL31oHttjDcXh8wfvBVqxGQvrwIVRtvmr769XVPq54pw tWVnBosQM6BMDo+d/AKkzJVW9ZcUeID+VYdxAofpozYeecYQQA29iDoFOZ1pdR0Y26YG TUT5ajug+QhPgJ8SL8gsZll+HOj92HJAqjR5SrhK5HTGwr40c9S5A5Cnzozto2SJ58Dp KGk/Tl87I9dVZP92fMYRwxTwHlnVFnbsp9Np5eA5lTCPC8oRCMRTwEqNGO16KArJ8h+y FiLg== 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 k15-v6si9469093pls.463.2018.07.16.00.40.43; Mon, 16 Jul 2018 00:40:58 -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 S2387801AbeGPIE4 (ORCPT + 99 others); Mon, 16 Jul 2018 04:04:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47024 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726898AbeGPIEz (ORCPT ); Mon, 16 Jul 2018 04:04:55 -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 390AAC03; Mon, 16 Jul 2018 07:38:54 +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.17 59/67] PM / hibernate: Fix oops at snapshot_write() Date: Mon, 16 Jul 2018 09:35:28 +0200 Message-Id: <20180716073453.114498284@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073443.294323458@linuxfoundation.org> References: <20180716073443.294323458@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.17-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)