Message ID | 20221215093930.22026-1-abelova@astralinux.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp250085wrn; Thu, 15 Dec 2022 01:46:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf7V6xKqaZVBdpDdlu2lPZJv7LnuP3j0sj6UfvP6bij0ATGnRSWZ81+R1tQa4Tn5e8jnP92C X-Received: by 2002:a17:906:37c4:b0:7c1:e7b:6460 with SMTP id o4-20020a17090637c400b007c10e7b6460mr25053638ejc.41.1671097615695; Thu, 15 Dec 2022 01:46:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671097615; cv=none; d=google.com; s=arc-20160816; b=sm9RM8FN3yqk1AVWxcv7kHx2OfyRT7MAjGmcn3GpB4XStO+ppsU7zxqSyLOIAMR06g AxTeazGMf5RiuBAesVvUEcho0DpDyvsblI1NSDPH08tE4hMAL2C6udmQ+pmQZ5hfTAiB Bn6rJkPfnNPX/Dy+W2O3pTM6Ro5lxDEVjqkgvbc6RKU+l4Tnghk2p/T1mKsSl38Nyotz 0QSgRC8Q76a/rIAArsdYQhp5Daeo12+3UT1JjDDAQQYVKGZ9SvSWDCmsJO3TOo6qp6bI HOI4qk8/oNjXAqRpKRbVztCaUu1Lktjp9mpkh6lv5nQJFlxBy09XBrZOImzjiwX+zPHR +/9w== 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 :message-id:date:subject:cc:to:from; bh=F5m7nbWmXtQ00V1Ym5WTyxR4ZLwIpw5WOZvn7+g3Rlw=; b=xnz6CatYAS3JR0ILIsRLjofUxZBgIdKnOLsOPifPMr/dcAlGrWo5kzq/DspmF+ckA0 uMw/hyxavZaRLAbGhfAaJ+AZeASKDxdxmYwyE8IGoMGTjz3c5aL/iZVNtXw8uOnu+c4G Qvqyf7xwmEsPKCQAbtteevxGvjMtmFe4MlOYq6JADeDTHYKbRBuKxb+FORMZpBTMHuV9 ySPNQ9yGZG/mv+oRKt3ZSldnC1OGvOFtgZ1B7qYp6hXBWOuUEdHH22noTcnaQmbRb9qV gPtse5Ml95alpUXoWLof9bSbAtk/iXFL4jp2NN8BizELhrtXX+lcq+YC77xVlj0DPOG6 BgQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xd2-20020a170907078200b007acf3aed468si13034774ejb.786.2022.12.15.01.46.32; Thu, 15 Dec 2022 01:46:55 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbiLOJjs (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Thu, 15 Dec 2022 04:39:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiLOJjr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 15 Dec 2022 04:39:47 -0500 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B06B1BEA5 for <linux-kernel@vger.kernel.org>; Thu, 15 Dec 2022 01:39:43 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id DA6A61863D96; Thu, 15 Dec 2022 12:39:38 +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 LOgah4IMWUXS; Thu, 15 Dec 2022 12:39:38 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 84C451863C60; Thu, 15 Dec 2022 12:39:38 +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 E2TjqXzuL3PY; Thu, 15 Dec 2022 12:39:38 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.20]) by mail.astralinux.ru (Postfix) with ESMTPSA id CAFF61863D96; Thu, 15 Dec 2022 12:39:37 +0300 (MSK) From: Anastasia Belova <abelova@astralinux.ru> To: Andrew Morton <akpm@linux-foundation.org> Cc: Anastasia Belova <abelova@astralinux.ru>, Max Filippov <jcmvbkbc@gmail.com>, Ingo Molnar <mingo@kernel.org>, Vineet Gupta <vgupta@kernel.org>, "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>, Geert Uytterhoeven <geert@linux-m68k.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] mm: Add check for NULL for unlocked in fixup_user_fault Date: Thu, 15 Dec 2022 12:39:30 +0300 Message-Id: <20221215093930.22026-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752272853539111484?= X-GMAIL-MSGID: =?utf-8?q?1752272853539111484?= |
Series |
mm: Add check for NULL for unlocked in fixup_user_fault
|
|
Commit Message
Anastasia Belova
Dec. 15, 2022, 9:39 a.m. UTC
Check unlocked for NULL before dereference.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d92725256b4f ("mm: avoid unnecessary page fault retires on shared memory types")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
mm/gup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Thu, 15 Dec 2022 12:39:30 +0300 Anastasia Belova <abelova@astralinux.ru> wrote: > Check unlocked for NULL before dereference. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > ... > > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -1282,7 +1282,8 @@ int fixup_user_fault(struct mm_struct *mm, > * could tell the callers so they do not need to unlock. > */ > mmap_read_lock(mm); > - *unlocked = true; > + if (unlocked) > + *unlocked = true; > return 0; > } I don't believe this is necessary unless the caller passed FAULT_FLAG_KILLABLE or FAULT_FLAG_ALLOW_RETRY in fault_flags. It's clear as mud and some code comments would help.
diff --git a/mm/gup.c b/mm/gup.c index f212d571b563..905d5fb64c4c 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1282,7 +1282,8 @@ int fixup_user_fault(struct mm_struct *mm, * could tell the callers so they do not need to unlock. */ mmap_read_lock(mm); - *unlocked = true; + if (unlocked) + *unlocked = true; return 0; }