Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4195405pxk; Tue, 22 Sep 2020 12:49:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1TgYqwu1dQqe1kLeQ6IyINNGKxOfmnE31298udrkcbriV2pMey7B7Kc9J4pTTJKdA5qMv X-Received: by 2002:a17:906:ae50:: with SMTP id lf16mr6525988ejb.343.1600804169447; Tue, 22 Sep 2020 12:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600804169; cv=none; d=google.com; s=arc-20160816; b=h3uQ9E5WbT9up9YVCuhWqVpKHzHUgB4aMKf+ItE/Ppo80LDR2AtmJrWVbRulpQfMUP sixLguv2lybdxT8277UgS3tZGADR2Soc3oGUOG6KJ7JcMMPGYJdMV2vN1MDuBya1xkxj qM8cSsB5sNaFJhWl3D5WucWNM5M+xOacYZaoKUUUEXUVnXtoKuST1Ur9mhACM95GEWjb ux7r40Md584n7terhVVcE1cnD+yoP+9wGwP/00iMiAPmnf47O4p7aJhXgWux82/XMBuc o1XNcGpG876vy/YVuL0JSWtIBZEIdtVKx2ou19h9iIfCYJgVLreiogcbAoWgDokd0Pcc iInQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=fXulnQdPNEu+f3aEyCt1kciTcRug3i8YDdabAGEXyPU=; b=f6tjD9Q9h8WsvVEx76XNwOQ2L9hiWIylCTEeG76+UkliSo0JIvgLbD2+27s4Xe2Fn8 MwQDetyDZ7qkwmKcdHMi1ruh6GhxGUTklW7yxUYDym3xZOPRxGIQx8NTW2GXv4ClrmXQ HmA2ezeALfXK90ozWfLsiLOLhOnXD5DJv/Q0VZFolEbqej9kxapvAy/48ARwmm6GDayy OsFqlUpkHuAz/v2Z+zHg9LDBphq0ILoeB13nQqYjzApqJAlQcRBmQ2jR+u8h+lDm/K2W Qbjnmw3+muhvJ1C8qtfo1jYjKHP68DbXyUiF2NfPXv60nrrBgk4wO21pSR46OGHZcImT zshw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m2iYWrQa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si11188060ejd.363.2020.09.22.12.49.05; Tue, 22 Sep 2020 12:49:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m2iYWrQa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726650AbgIVTrw (ORCPT + 99 others); Tue, 22 Sep 2020 15:47:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgIVTrv (ORCPT ); Tue, 22 Sep 2020 15:47:51 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?