Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6766707rwn; Tue, 13 Sep 2022 08:45:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Cg3cDI7VloipFRNHQ5nYqyjap2xExBLoSI0GPahVbLEMohPylY6O7PEY9cPSqLFuWxOxZ X-Received: by 2002:a17:907:2d8a:b0:730:6880:c396 with SMTP id gt10-20020a1709072d8a00b007306880c396mr21896612ejc.192.1663083910994; Tue, 13 Sep 2022 08:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663083910; cv=none; d=google.com; s=arc-20160816; b=0vT+kReoeB9fke7BZrG2we7gzpEFAXB/Q4gjNnUTilBzeJJiEFy8reTJehLXIMAI58 rMIGtpQ5sPj+IAADJwpgwnyiAm9hzPB3//tNeOXgXLHX0GFpyerq/AdmKo8p2quwYYLg sqn+g++OGFjicR9JZYbmfEFil0Y5Ns2w6A2c1caI0tP86EF/KbGIZ7tzFghaL6LeDlZM bqJBZQ+Qt506RxPzIu/E+gA5QyVI1fJdLw7TJIAcgjJvAorww9TdQdbI2KM1bZRI/v2q 2YBJWgS3DqBdOG4vxNFCHzCaON4UojvynFRe/yEIIu/JZiCx86/aAEKbUV9Hj2cEuPqX cx+w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6vdc/GaRtsBWHM87Qbh1hXIh6SWJ6Ko0JZBgC1R5JJg=; b=bb2wjNmLI3MoeFQXj4/RTy8pqXSvPqvdNhbEgTSoXpH1gusp+CI5egJuBwKDiJKldk 8ZZxmT380a92ge1jgpP330Bl4IKi4qkSRy+Vg/w5vENDohcbLXPOEPIQsVQUBxu/ANpz IM34HoXOnNW7nly4BAizmy5gqDzjnHiCNOy5V+HQRb/4yUQFqEfQxWE3gZ21HHRIgdo7 NS65k4R5qeKnxIi6R3W3KReXc5gyc8IE2fR05IJl43YaCkM/sik6xBIh0RkI/W4n/e6e SA6nNFevd5bGcOxQAGzOE7hNdkmoYTxUQTDQHDCmHHFadPZG92ZwxRiYygQFnhlY8Uw1 2NXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rgLM9NhK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du18-20020a17090772d200b007315809ec84si10873447ejc.398.2022.09.13.08.44.41; Tue, 13 Sep 2022 08:45:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rgLM9NhK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbiIMPPH (ORCPT + 99 others); Tue, 13 Sep 2022 11:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbiIMPMi (ORCPT ); Tue, 13 Sep 2022 11:12:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8912577E9E; Tue, 13 Sep 2022 07:32:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5D388B80F6F; Tue, 13 Sep 2022 14:31:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4325C433C1; Tue, 13 Sep 2022 14:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079474; bh=wbhwPkgVfB0u/ecYJDpzWyQrjPmGXlonw19X6uHaZ7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rgLM9NhKeX+VytBn9hvXyrS60sgEYWbM48/c68WFliCbtUHgSLILscCoJ4H4t5XII Gx/boem3nJB0rZwabTKTG+VU7KsOCgQtGfNAwKka8pLlxX+uMv4FHP5mIovCyclYv/ F1KNbBvrzIgEykfmEQc/REMi1lWl+wamWeyT2Z6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Gordeev , Gerald Schaefer , Vasily Gorbik Subject: [PATCH 4.19 41/79] s390/hugetlb: fix prepare_hugepage_range() check for 2 GB hugepages Date: Tue, 13 Sep 2022 16:06:59 +0200 Message-Id: <20220913140350.893428702@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140348.835121645@linuxfoundation.org> References: <20220913140348.835121645@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gerald Schaefer commit 7c8d42fdf1a84b1a0dd60d6528309c8ec127e87c upstream. The alignment check in prepare_hugepage_range() is wrong for 2 GB hugepages, it only checks for 1 MB hugepage alignment. This can result in kernel crash in __unmap_hugepage_range() at the BUG_ON(start & ~huge_page_mask(h)) alignment check, for mappings created with MAP_FIXED at unaligned address. Fix this by correctly handling multiple hugepage sizes, similar to the generic version of prepare_hugepage_range(). Fixes: d08de8e2d867 ("s390/mm: add support for 2GB hugepages") Cc: # 4.8+ Acked-by: Alexander Gordeev Signed-off-by: Gerald Schaefer Signed-off-by: Vasily Gorbik Signed-off-by: Greg Kroah-Hartman --- arch/s390/include/asm/hugetlb.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -30,9 +30,11 @@ pte_t huge_ptep_get_and_clear(struct mm_ static inline int prepare_hugepage_range(struct file *file, unsigned long addr, unsigned long len) { - if (len & ~HPAGE_MASK) + struct hstate *h = hstate_file(file); + + if (len & ~huge_page_mask(h)) return -EINVAL; - if (addr & ~HPAGE_MASK) + if (addr & ~huge_page_mask(h)) return -EINVAL; return 0; }