Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4453634rwb; Tue, 6 Sep 2022 07:46:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR7BbNfTgB6BdGmSxmmJSVZyOnrWdXAVeyPsBy/PwRgS6Q+zkmhr8jFtip8UJAbxI78jugeH X-Received: by 2002:a17:907:6eac:b0:76e:e69d:edce with SMTP id sh44-20020a1709076eac00b0076ee69dedcemr3727239ejc.256.1662475566390; Tue, 06 Sep 2022 07:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662475566; cv=none; d=google.com; s=arc-20160816; b=IC2IbEh8sT7X1/GEFKZT/zR9o+R07fWMcy81QPo6ECsZ9u3Prs2hX9lPzeUgrV2wTN 58eS0Cz5zWDY8Z22TZdiQ13V6cZNuwPU6lyyW0/51IcmQaV4N/AlKykBB8jN/Jh3Gb6q TQr0RSQ/ffgpRHTvD1l5v9hIT+FgUEdYMeAEHEybvHooeTa640BZ/m08VSPuyydN7fTw io4KzZj2mSmN7OtPNBn5v+g4huVpPXrwuhQxdS/HU3V3OhUEnrGrgiNaHiHtghU827yx Vf+gFHmxueOnSyEv1LHKc+TCep8UDi0GKxsVcHWL7sT1j8ow/eHsMX7klh9dgNDHe3bF uMeA== 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=F18dgQPafHxUdCnWLp6FMpmpgMyv8OkaiQnqb8lCQMY=; b=BcDrm7dZ+kbJBxw1pcymIxFYi7vq9MeMbyJs4uvI8lvs0y7dPL7j9CVj31/OBC/tck cc24KOuJtLkvw0vnbZMYUotspJ7qh6XszMCfKUl5grrzg2/B5aJKyupGnrN8FZwqwiFQ 90AfpAEyWVe9J40wEoZs6N32wFSuXfY3nsSIF3GmItIvytVAmHgdmDU0CWUvYW3zyEDH WKXlIj2QE2H8CC0rsB7BpPQxh+F1cpV7ZqPIghI2BbtGb1iinaHahV+OodVYDMubXBUp FEK0ISO+qrDx6zbISEaEjxXIr8CLn1y8vmtR1bfEMxPfVvzdx1UY3iN49U78lJ6c9UsT axng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hrg4Z8C1; 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 kw6-20020a170907770600b0073101ba70bdsi9079863ejc.927.2022.09.06.07.45.38; Tue, 06 Sep 2022 07:46:06 -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=hrg4Z8C1; 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 S238588AbiIFNsC (ORCPT + 99 others); Tue, 6 Sep 2022 09:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233664AbiIFNoy (ORCPT ); Tue, 6 Sep 2022 09:44:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D992418B3D; Tue, 6 Sep 2022 06:38:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 931FD6154E; Tue, 6 Sep 2022 13:36:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BB0BC433D6; Tue, 6 Sep 2022 13:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471373; bh=A2SlET5mA2JB6GyGY8Cy5ilZkG92iGR0V0gDf6pDXZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hrg4Z8C1kAUcRu502swNfJyDhiJfWBpGH/p3YntnQrygEJanfR4uZpuFM4rKPQmwx 9DrKfqTfiIiWI6qEVvheU7f1mno0boIRdAr38e/KJ7NaGlVeb7TGXuVzPlUH3ie4iT SQSeCheAdUzVCKnNzG6pHFv9D7iMib3/geVvU0l4= 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 5.10 60/80] s390/hugetlb: fix prepare_hugepage_range() check for 2 GB hugepages Date: Tue, 6 Sep 2022 15:30:57 +0200 Message-Id: <20220906132819.563491929@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@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 @@ -28,9 +28,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; }