From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29407C63797 for ; Tue, 17 Jan 2023 07:57:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 858546B0071; Tue, 17 Jan 2023 02:57:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 808DF6B0073; Tue, 17 Jan 2023 02:57:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CF986B0074; Tue, 17 Jan 2023 02:57:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5D3FF6B0071 for ; Tue, 17 Jan 2023 02:57:30 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1D0B1401FE for ; Tue, 17 Jan 2023 07:57:30 +0000 (UTC) X-FDA: 80363536260.07.04E991A Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by imf03.hostedemail.com (Postfix) with ESMTP id 157FB20002 for ; Tue, 17 Jan 2023 07:57:26 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf03.hostedemail.com: domain of eesina@astralinux.ru designates 217.74.38.119 as permitted sender) smtp.mailfrom=eesina@astralinux.ru ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673942247; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DWiE/4/AAfKMIRo0wVLpBbkYkUincTXhOfS0DjRO1/4=; b=RXOXC7I/ioqIOf0f1u6PmiCwpuOMTlLWPODp+EPOWtmBunx4ma/rBflVz8g+EXMn42wqom NFrKMFOcQt0xyJUP6dH0zNIQPEKY767Y/VqOSEii5EZvUlh5almZZ49osiJNRQDvMnr3FP A6zik0EGi6ZO+cJFfrCjJ0sytU3bByo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf03.hostedemail.com: domain of eesina@astralinux.ru designates 217.74.38.119 as permitted sender) smtp.mailfrom=eesina@astralinux.ru ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673942247; a=rsa-sha256; cv=none; b=x/XD0UcIeiVheTIsL8n48OuuCb1evbDWkP/9/uyrvvK0Pwcp7aYpmTas1T6hyZP35W2zlx 0PtbJACXcnLTjWQRh9s4D3egJe5Ze2e4D6PxDktM/cA4m7+Mmt7yZavVYZDPZV4GeUEqlI pX0BeYURY5ChrLJ59GcL5S6uZGwtDng= Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 6D0181862FF8; Tue, 17 Jan 2023 10:57:24 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Yn49oI055lij; Tue, 17 Jan 2023 10:57:24 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 048EB1863EB6; Tue, 17 Jan 2023 10:57:24 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Z5woGg05I0RF; Tue, 17 Jan 2023 10:57:23 +0300 (MSK) Received: from rbta-msk-vsrv-mail01.astralinux.ru (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id B2DC41862FF8; Tue, 17 Jan 2023 10:57:23 +0300 (MSK) Date: Tue, 17 Jan 2023 10:57:22 +0300 (MSK) From: =?utf-8?B?0JXQutCw0YLQtdGA0LjQvdCwINCV0YHQuNC90LA=?= To: Mike Kravetz Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Message-ID: <1573070216.376764389.1673942242274.JavaMail.zimbra@astralinux.ru> In-Reply-To: References: <20230116103947.73153-1-eesina@astralinux.ru> Subject: Re: [PATCH mm v2] mm: hugetlb: Add checks for NULL for vma returned from find_vma. MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_49205ac2-97ab-4ac2-80bd-8174440ab240" X-Originating-IP: [10.177.177.35] X-Mailer: Zimbra 9.0.0_GA_4258 (ZimbraXWebClient - yandexbrowser22 (Linux)/9.0.0_GA_4258) Thread-Topic: hugetlb: Add checks for NULL for vma returned from find_vma. Thread-Index: wfzUoR3T+bDCxr70pqeyZBG0HC75iw== X-Rspamd-Queue-Id: 157FB20002 X-Stat-Signature: myu75gdc9yi7zr6ipp1t1kduxd794grg X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1673942246-774808 X-HE-Meta: U2FsdGVkX18K0QnHEKiPlv9k/v9LatMhc+Xpr84shdqcbW5gXgIbx+B8/fgHtbSQvY3SLSCwGdtjAJSBOve9uIyeHRsRL5vu51mwHrStOndJjelYpdi00FjOf15Xc7oKNakOYCGObVMRxjD56fnuMa9SFjX/4JB83VHaw/6y9R7AhYshbuHamzl7OpoZixXoTUxRu7R9wrLa+90isTmzIwbjJd1s53PpNk+0dtjD5Q1/weDhfJfhjXdf+yBPxEt/Jrs2CqTPv5SMdkQdjX1rT6du3rX/ofE0j/Oo9WyG2JKvgDAvaAY87oQc7FZg8DcxE2kq78P277Y3pjyj9Z3FMETA7Ii7e97h1poO1zipLCsBU550TUV4Txo7Q9Pl6MPdpwkxrh+mOwQ1u6a7oFApOzyJXWV//qKGAo1UEifvZ2BQEqyZPdj929+HJyaVqwe352+7m0wn3JaAnPnP7l8XjYCaTlfeheXtuPIOWhBeEfV7r6AEKijBOffNpOyUo+fvc4vyOz6qIXV4lpriYSdrlGfGgqTd26SVXje1+Dt0nycXoKWaGeyTNTsM4kSyWjtlupsDcmcgRFytoepz7O+lfAlErOd/9ZbVaWrznLdkqZVGwjgTGQ/S6zSywoaGgxqeHeyWk2hHYiGURlhHUOAeb6Buwh2dxxaG5919LWiwyuFZet9YiGoDni7zLV0JzeMfK94MYpsC2kmEvMF0jtmvjfWDCP0OV9Dj73kqCTFgOGpxWUNONIWAhTlrfMyebVMfcktxnim70OsevBW31IDSG9FIfU6oP/D7+v/s2xTiZwr24mjEdqe7MtdCqZ6Uc02gAanYseD4YzEYsu2z8Dr+9vq5N+9PeU8NQcdN8fijfhubFqq7vfbKGTR5O957xKutYOyh7dGsxSgb6X51LCnFfF18vhRT0nVMcsQvPbYj9ca549rCvzHqYftBIw99fixEgHPWN1rI1t2RyS4umYk ohUyMzMs fP2Y1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000042, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --=_49205ac2-97ab-4ac2-80bd-8174440ab240 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The patch can be applied up to 5.12 version and in 5.13 the logic of the fu= nction huge_pmd_share changes. And in later versions vma is passed as a fun= ction argument.=20 =C2=A0=20 Best regards, Ekaterina Esina=20 =C2=A0 =20 =20 -----Original Message----- From: Mike To: Esina Cc: Andrew ; linux-mm ; linu= x-kernel ; lvc-project Date: Monday, 16 January 2023 9:30 PM MSK Subject: Re: [PATCH mm v2] mm: hugetlb: Add checks for NULL for vma returne= d from find_vma. On 01/16/23 13:39, Esina Ekaterina wrote:=20 > find_vma may return NULL, that's why its return value=20 > is usually checked for NULL. vma should be checked before dereferencing= =20 >=20 > Found by Astra Linux on behalf of Linux Verification Center=20 > (linuxtesting.org) with SVACE.=20 >=20 > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")=20 > Signed-off-by: Esina Ekaterina =20 > ---=20 > mm/hugetlb.c | 32 ++++++++++++++++++--------------=20 > 1 file changed, 18 insertions(+), 14 deletions(-)=20 This is not the latest version of the code. What version are you=20 targeting?=20 I would claim that find_vma() can not return NULL in previous versions=20 of the code which this patch seems to target. Why? This routine is=20 called with mmap sema held and we know addr is part of the vma.=20 --=20 Mike Kravetz =20 --=_49205ac2-97ab-4ac2-80bd-8174440ab240 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
The patch can be applied up to 5.12 v= ersion and in 5.13 the logic of the function huge_pmd_share changes. And in later versions vma is passed as a functio= n argument.
 
Best regards,
Ekaterina Esina
 

From: Mike &= lt;mike.kravetz@oracle.com>
To: Esina <eesina@ast= ralinux.ru>
Cc: Andrew <akpm@linux-foundation.org= >; linux-mm <linux-mm@kvack.org>; linux-kernel <linux-kernel@vg= er.kernel.org>; lvc-project <lvc-project@linuxtesting.org>
Date: Monday, 16 January 2023 9:30 PM MSK
Subject: = Re: [PATCH mm v2] mm: hugetlb: Add checks for NULL for vma returne= d from find_vma.

On 01/16/23 13:39, Esina Ekaterina wrote:
> = find_vma may return NULL, that's why its return value
> is usually c= hecked for NULL. vma should be checked before dereferencing
>
&g= t; Found by Astra Linux on behalf of Linux Verification Center
> (li= nuxtesting.org) with SVACE.
>
> Fixes: 1da177e4c3f4 ("Linux-2= .6.12-rc2")
> Signed-off-by: Esina Ekaterina <eesina@astralinux.r= u>
> ---
> mm/hugetlb.c | 32 ++++++++++++++++++-----------= ---
> 1 file changed, 18 insertions(+), 14 deletions(-)

This= is not the latest version of the code. What version are you
targeting?=

I would claim that find_vma() can not return NULL in previous vers= ions
of the code which this patch seems to target. Why? This routine is=
called with mmap sema held and we know addr is part of the vma.
--=
Mike Kravetz
--=_49205ac2-97ab-4ac2-80bd-8174440ab240--