From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D4B6ECE58D for ; Fri, 11 Oct 2019 18:18:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3382820673 for ; Fri, 11 Oct 2019 18:18:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728826AbfJKSSA (ORCPT ); Fri, 11 Oct 2019 14:18:00 -0400 Received: from foss.arm.com ([217.140.110.172]:39344 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728587AbfJKSR7 (ORCPT ); Fri, 11 Oct 2019 14:17:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3764F1570; Fri, 11 Oct 2019 11:17:59 -0700 (PDT) Received: from [10.1.196.105] (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4B3BD3F703; Fri, 11 Oct 2019 11:17:57 -0700 (PDT) Subject: Re: [PATCH v6 03/17] arm64: hibernate: check pgd table allocation To: Pavel Tatashin References: <20191004185234.31471-1-pasha.tatashin@soleen.com> <20191004185234.31471-4-pasha.tatashin@soleen.com> From: James Morse Cc: jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, bhsharma@redhat.com, linux-mm@kvack.org, mark.rutland@arm.com Message-ID: Date: Fri, 11 Oct 2019 19:17:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191004185234.31471-4-pasha.tatashin@soleen.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavel, On 04/10/2019 19:52, Pavel Tatashin wrote: > There is a bug in create_safe_exec_page(), when page table is allocated > it is not checked that table is allocated successfully: > > But it is dereferenced in: pgd_none(READ_ONCE(*pgdp)). Check that > allocation was successful. > Fixes: 82869ac57b5d ("arm64: kernel: Add support for hibernate/suspend-to-disk") > > Signed-off-by: Pavel Tatashin Nit: Please remove the stray newline so all the tags appear together. > diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c > index d52f69462c8f..ef46ce66d7e8 100644 > --- a/arch/arm64/kernel/hibernate.c > +++ b/arch/arm64/kernel/hibernate.c > @@ -217,6 +217,11 @@ static int create_safe_exec_page(void *src_start, size_t length, > __flush_icache_range(dst, dst + length); > > trans_pgd = allocator(mask); > + if (!trans_pgd) { > + rc = -ENOMEM; > + goto out; > + } > + > pgdp = pgd_offset_raw(trans_pgd, dst_addr); > if (pgd_none(READ_ONCE(*pgdp))) { > pudp = allocator(mask); > Thanks for splitting [0] into two ... but this fix depends on the previous patch - which isn't an issue that anyone can hit, and doesn't match Greg's 'stable-kernel-rules'. Please separate out this patch - and post it on its own as a stand-alone fix that can be sent to the stable trees. Mixing fixes with other patches leads to problems like this. It isn't possible to pick this fix independently of the cleanup in the previous patch. Thanks, James [0] https://lore.kernel.org/linux-arm-kernel/ddd81093-89fc-5146-0b33-ad3bd9a1c10c@arm.com/