mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Liu Dalin <liudalin@kylinsec.com.cn>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Liu Dalin <liudalin@kylinsec.com>,
	Deng yingchao <dengyingchao@kylinsec.com.cn>,
	Qin yungao <qinyungao@kylinsec.com.cn>,
	Luo Qiu <luoqiu@kylinsec.com.cn>
Subject: Re: [PATCH] mm/gup: add NULL check for unlocked parameter in fixup_user_fault()
Date: Wed, 26 Aug 2026 11:10:32 -0300	[thread overview]
Message-ID: <20260826141032.GE1449020@ziepe.ca> (raw)
In-Reply-To: <D1CF78FF9DD1C630+20260826062943.3255351-1-liudalin@kylinsec.com.cn>

On Wed, Aug 26, 2026 at 02:29:43PM +0800, Liu Dalin wrote:
> While the current callers either pass a valid pointer or explicitly
> pass NULL (indicating they don't need the unlock notification), it is
> safer to add a defensive NULL check before dereferencing. This prevents
> a kernel crash if any caller passes NULL and handle_mm_fault() returns
> VM_FAULT_COMPLETED or VM_FAULT_RETRY.
> 
> Fixes smatch warnings:
> - mm/gup.c:1597 fixup_user_fault() error: we previously assumed 'unlocked' could be null (see line 1573)

It would be better to remove the previous check:

        if (unlocked)
                fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;

And update the kdoc if it is now true that the unlocked parameter
cannot be null

Jason

  reply	other threads:[~2026-08-26 14:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26  6:29 Liu Dalin
2026-08-26 14:10 ` Jason Gunthorpe [this message]
2026-08-26  6:31 Liu Dalin
2026-08-26  7:49 ` David Hildenbrand (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260826141032.GE1449020@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=dengyingchao@kylinsec.com.cn \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liudalin@kylinsec.com \
    --cc=liudalin@kylinsec.com.cn \
    --cc=luoqiu@kylinsec.com.cn \
    --cc=peterx@redhat.com \
    --cc=qinyungao@kylinsec.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®