Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35091394rwd; Mon, 10 Jul 2023 02:21:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFX/ODOBzW/WLSrYv9WbvuaD2+Ank1DU/hBbcH7a8jpfp3+ElERzg1+/G0EVhkX69ma3fhp X-Received: by 2002:a54:4184:0:b0:3a1:f026:6b40 with SMTP id 4-20020a544184000000b003a1f0266b40mr10723528oiy.23.1688980891684; Mon, 10 Jul 2023 02:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688980891; cv=none; d=google.com; s=arc-20160816; b=pn9dxTDUKqasaYtFK84Cz5TT5ymrRWsPXOdxoDomQNdndIGJFaM9JTmr6A5kLgXvrh 2+80iUvtudBNDU1WYrZZ4YMPEgOpbcTrBJUs3TLOAOA7S5QKtNlUBu/frKbmpu6K/5bF n6fkqEl/r4RbzguI7SR19XnkY/jyQqd40/YAabLAROC2W619T21fCVnvUOluOhnHC3zV KoSmF1nROFhf42PVH6qTKtOXBt5gBJz5Qu1v1e/5ocoDpOPsXudzGJgnILPSFgtBbWxy uVqbNiDiTb+aVBKjCmfz9rMiipmH0Dqv4oXn6Uc3cKmjElJoWpnGlwDffoXc1i1Ek1v5 BflA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=RY1Cf45ecIWbc7NEFgS5rEslIyMu9IK3gvaqBb6Duos=; fh=Tzlq5Bowr+jzFsnTG7Ir7GG49POBTWeKLrd62KRsl0Q=; b=ryfXv+ZbqqZFS3cVrJoLTBsuE7EYSGGM/7r353vmozRTRuWPGe+l4VZic+s6k8n+VL /PcL23KCLL/qCvDj8vCXrMNdMEb/RzF7m/P0HJ0DRB8dXUUkY++u6T245VrrtwQxI90Y XIPfWuyIEQgkWKT/YOhv3jW9BGsfXhBo3aYD1AzxeQUlJcNkvR7YBIaGbKw/xDrBOAoC 4mQrVzFFR6/2brI7Gu1rXu6o0C4mv4qAZwUnPHFWJjcHF4bHlzcYN8NynccYsvSdofNK 04tDIINsp2j1n4/YEA2CIeMdeuBzwhPefQiL5x70ntlNYRB/3YZirOXl4/+mjhJpd7A2 F8IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Rbr7ix11; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a630804000000b0055771146c25si8950525pgi.896.2023.07.10.02.21.19; Mon, 10 Jul 2023 02:21:31 -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=@gmail.com header.s=20221208 header.b=Rbr7ix11; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbjGJJDu (ORCPT + 99 others); Mon, 10 Jul 2023 05:03:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232922AbjGJJDc (ORCPT ); Mon, 10 Jul 2023 05:03:32 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645B72119 for ; Mon, 10 Jul 2023 02:02:33 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4fb96e2b573so6353476e87.3 for ; Mon, 10 Jul 2023 02:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688979750; x=1691571750; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=RY1Cf45ecIWbc7NEFgS5rEslIyMu9IK3gvaqBb6Duos=; b=Rbr7ix116IC3UXycX1Yvm0AS9UwmXGOaJGC+zn/J+Lk+p+rESDxtlvW5Lf5VTvzP8l 0O/YVAPm/Oq7XbAPQllEfAjy6iZJHC1uozpAd5SAEZFCDfO2EdgggUg0FwkSvOvFXTyg mFVLKabEUf0OUMOcoynH8KCa/F5luTZfwtkeKpV5/KKOgX8hasRE2cD0+ZF6vVh7xei0 1CxYHaZTj52h6+nBHZthpMTQd/v/4h8VjVspPu+Mo/mPD5sIJPRdBEDVfeQsVBSuTRmB SjRaDKgXQbS+tVcNcA2tC95EScaIEuaMedfmrmxMpfUeTx6Djg/U0kTL4/GHTQBE2Bi9 IiWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688979750; x=1691571750; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RY1Cf45ecIWbc7NEFgS5rEslIyMu9IK3gvaqBb6Duos=; b=N5T0vrsJpaWbNUw3iP+OCM3rNGJjW7pSD5/WFTdyeO88JQ3TbM9tWNO7hhybgn3Aof ztEavxLIJsYCC2v/WKOUcNJzYOOLcCQ5PvuIKtN1dUICTX1IemaM+/ssGbQWecoBjiGv X5qkc3n0qC/w/F9x7hQHc64v9cz7D9HnmyM2bE+9LuLTfAhvxNTbxF2iwpzupDVHvQ9o AxJMofE1CDFUeWIz2jsoBBBpChg1p7m18ANEgcx34MFOrD9HkQYMDOhWV7v7oFAeJAJu B4tq2pz1cKyQlpBt/UIi18QP9QkOrJwDeOuLQYSDrM1VF5f9O05su/zAH1yc/C0Rjctg Yh8A== X-Gm-Message-State: ABy/qLZ2j8bQiDJFI3VDUVMjRN8QLUz84Bhqo5kDi5ltZbLfB5mF2NCE bsr4PNwURX24Lrcfv7+DeA== X-Received: by 2002:ac2:4eca:0:b0:4f8:5604:4b50 with SMTP id p10-20020ac24eca000000b004f856044b50mr8378739lfr.64.1688979750142; Mon, 10 Jul 2023 02:02:30 -0700 (PDT) Received: from p183 ([46.53.254.107]) by smtp.gmail.com with ESMTPSA id y8-20020aa7ccc8000000b0051a2d2f82fdsm5488043edt.6.2023.07.10.02.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 02:02:29 -0700 (PDT) Date: Mon, 10 Jul 2023 12:02:28 +0300 From: Alexey Dobriyan To: lilinke99@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hugetlbfs: Fix integer overflow check in hugetlbfs_file_mmap() Message-ID: <36509a07-5ab0-44e8-85b3-5cf884a9aff4@p183> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,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 > --- a/fs/hugetlbfs/inode.c > +++ b/fs/hugetlbfs/inode.c > @@ -157,7 +157,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) > vma_len = (loff_t)(vma->vm_end - vma->vm_start); > len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); > /* check for overflow */ > - if (len < vma_len) > + if (vma_len > LLONG_MAX - ((loff_t)vma->vm_pgoff << PAGE_SHIFT)) > return -EINVAL; Proper fix is to make everything unsigned probably.