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=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 CC42FC4727E for ; Tue, 22 Sep 2020 19:47:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32C2B23787 for ; Tue, 22 Sep 2020 19:47:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="m2iYWrQa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32C2B23787 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 668D96B0003; Tue, 22 Sep 2020 15:47:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 618E56B0055; Tue, 22 Sep 2020 15:47:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52F666B005A; Tue, 22 Sep 2020 15:47:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 39FF16B0003 for ; Tue, 22 Sep 2020 15:47:53 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E9EB7181AEF00 for ; Tue, 22 Sep 2020 19:47:52 +0000 (UTC) X-FDA: 77291732784.11.play41_1a0156d27150 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id C0BBB180F8B80 for ; Tue, 22 Sep 2020 19:47:52 +0000 (UTC) X-HE-Tag: play41_1a0156d27150 X-Filterd-Recvd-Size: 2467 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 19:47:52 +0000 (UTC) Received: from X1 (unknown [216.241.194.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F396520888; Tue, 22 Sep 2020 19:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600804071; bh=MqlXCLEZquChpaBvVYye8Wj9L6hvnijd7TNDRmPo42U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=m2iYWrQa06vGlD6u9Pxv1j23pQGigrIJ6W9hx/BIbyOUnxz/oLVWjrqbYF5VButKN e8+dXDDxntZ68M5Tb/r8309LZYt1Yg/ESNTRsiaBzCKik7GBadAYCDlbe8nV00H8fy 2E01dAKomwCYXai5m7tUk3B0RizOheqGXe4Gsy90= Date: Tue, 22 Sep 2020 12:47:50 -0700 From: Andrew Morton To: Rafael Aquini Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, ying.huang@intel.com Subject: Re: [PATCH] mm: swapfile: avoid split_swap_cluster() NULL pointer dereference Message-Id: <20200922124750.67a20d9764ec098b17705407@linux-foundation.org> In-Reply-To: <20200922184838.978540-1-aquini@redhat.com> References: <20200922184838.978540-1-aquini@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 22 Sep 2020 14:48:38 -0400 Rafael Aquini wrote: > The swap area descriptor only gets struct swap_cluster_info *cluster_info > allocated if the swapfile is backed by non-rotational storage. > When the swap area is laid on top of ordinary disk spindles, lock_cluster() > will naturally return NULL. > > CONFIG_THP_SWAP exposes cluster_info infrastructure to a broader number of > use cases, and split_swap_cluster(), which is the counterpart of split_huge_page() > for the THPs in the swapcache, misses checking the return of lock_cluster before > operating on the cluster_info pointer. > > This patch addresses that issue by adding a proper check for the pointer > not being NULL in the wrappers cluster_{is,clear}_huge(), in order to avoid > crashes similar to the one below: > > ... > > Fixes: 59807685a7e77 ("mm, THP, swap: support splitting THP for THP swap out") > Signed-off-by: Rafael Aquini Did you consider cc:stable?