Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4489929rwb; Tue, 6 Sep 2022 08:13:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4mfwc8soLSiur+fOn+j5PX01nmFzRQjdfUZ3Ds52Pw6WobmqSZ6AFiBKabf3S5Ky5fPoi6 X-Received: by 2002:a05:6a00:2291:b0:539:d5b8:4ecc with SMTP id f17-20020a056a00229100b00539d5b84eccmr37020084pfe.79.1662477181977; Tue, 06 Sep 2022 08:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477181; cv=none; d=google.com; s=arc-20160816; b=pxq8o8akiVJvoaPBUNzPzyRH64nmNl9AOh0KCLRIDISkGKKBeWin9V7dLzsBOjj5kL 7VBWLKD0GPJCEJErMoI/7B9H/AzgyziFFxpGOk3O2VaYdgG140lRxOrDep3VX37B5Z7X lSLXYrUlq3v6NqKXRxgLjjlYwlTbkpkS0ebyyRaB4uTTz4wh63k2w4QcoONyUxB0mqS2 mLewEXS25H/y6k4XTbQ1ebGj2ByT1Llbwzmf+TmFbKwQtBYujvIVlD8tXkkczCVyBfZm vlM1uUppp+towGv3wCejd7AdZGf3Wf/naurdJ0HVRkA4h9uxt25+s1v62gal3WMdg9gQ K8PA== 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=E3omGE24lUHj+5z26wmlTkuQRjrEnbesoGQhTT+EUbVLXYLJ5C5a0BJOJXgYAsL76f JKFYyAToh9JgsJRnsZdiGRRGhZa6kIjtkGQxZIlai1YtzPV5+rWoJareZXyNbRpLoybL JL/7m2yj2kPe87U/YyWAQm8ZNxe24pH1Ox85p/JEu9UgSU6CBOHRVtlkBoze8Y08Tme9 I2d2jtJNY133xiBYSALjr9r7tjmYJpGt8kTiiQ+YIuNpKpcYuqCJk1LQ5c2e+lD9vcn+ ft0PALUtdSo9wnxJyMwpLJnSBkIfSnsbDO9mVebOzGlGAsgZqLoN0l7YSvYMcy/ssVMV Fl6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WhYSa2wk; 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 g64-20020a636b43000000b0041ce62de18esi13877538pgc.611.2022.09.06.08.12.49; Tue, 06 Sep 2022 08:13:01 -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=WhYSa2wk; 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 S241351AbiIFOM2 (ORCPT + 99 others); Tue, 6 Sep 2022 10:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241579AbiIFOKQ (ORCPT ); Tue, 6 Sep 2022 10:10:16 -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 39D9687685; Tue, 6 Sep 2022 06:47:26 -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 D17E961552; Tue, 6 Sep 2022 13:47:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC2C1C433C1; Tue, 6 Sep 2022 13:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662472045; bh=A2SlET5mA2JB6GyGY8Cy5ilZkG92iGR0V0gDf6pDXZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WhYSa2wkm7S72P63Ne6T3vyZFD93NoVnZCjtFvb1IeO9Q+7sNKQnOsm9hbpYnat2/ MvXiQVMBhEeZFFPt9TYvUAf/uuk3S8r95s3j0Jf1U8n/woPue+atuIKh7laAuXmH+c 3QisGAmDPvwtbMNH4RAZGvgyBl9SMCAaxO/z7rJA= 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.19 128/155] s390/hugetlb: fix prepare_hugepage_range() check for 2 GB hugepages Date: Tue, 6 Sep 2022 15:31:16 +0200 Message-Id: <20220906132834.852956422@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@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; }