From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C9981D47B4 for ; Wed, 6 Aug 2025 18:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754503780; cv=none; b=h2GcADsGb3YwS7E+lb0T6MZCDbHu5sn5KsGH8tgoOjyKteNnfrs4wvLxp7f8JtculoKD2usQZku9llrvWjuLGVJMVMDhGaj/iOYzWE0xuNf/51OAqe3K7r5aVPpkPRYAX/Q7TRnlIuto/1vRsSKa1I0Xp2rKqd+8EmqAJNlpPlY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754503780; c=relaxed/simple; bh=XW4fJQKhpVWtLLRbURa2n6uS1OoOotVI/AulaQSKDw4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TiKRFakgqTgcIwTLK3pZydfO8HQje42tKMokDNJ75O6PPZXZ4VaNdmeF1nOs+4I8Us6oRzg5H0Et9vxm+b+7EnkpjedfdbdnHvevDSmKQWbp+DihrjBt1tI9zuX1fXxvT+2FzTDgHyghiG6yLqjfDEwENZzPLjOzwkEiIvv33vU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NhQjEvVt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NhQjEvVt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754503778; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lp/xzAZFz2QzCUmaidxOhS/oOucGpdCu8iObUTLz2sI=; b=NhQjEvVtUDelv1HZkaP5yzM2xlBgW8hgsI+9tJW8jzEuMyy5gIEA8W4B9gw2jNKq6CsOjz 6ejNkYPGkUudJC5VDDZTeo3DcqvxrlZ0oHvBpAf2q7//W22bXCAkoFmKyWMtPOWS3oid0R wX5nin7lh5/quWWjLpBsDP9v1h3gDPY= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-z01_Ie7uOFu0lPEMcgdx5Q-1; Wed, 06 Aug 2025 14:09:36 -0400 X-MC-Unique: z01_Ie7uOFu0lPEMcgdx5Q-1 X-Mimecast-MFC-AGG-ID: z01_Ie7uOFu0lPEMcgdx5Q_1754503776 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7e7fc5f1e45so28480785a.0 for ; Wed, 06 Aug 2025 11:09:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754503776; x=1755108576; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lp/xzAZFz2QzCUmaidxOhS/oOucGpdCu8iObUTLz2sI=; b=k91EhdDvyK6k0qA0hD7kakVKpmJmZbS340d2Eyu+YbqcEod2yW4eLpWThOtFHkiTiV zEI2rlo1ZZKiD8k1Udz8qR7VasfFFB+OF3rxBeNMnvHgIZf8XRkeuGTib20gQrkftEzs QAGZA69bJVOfkMWicbV0v0Zg1VW3YRKGOK3Se97lh5hyI9wzT5yCCaH/J24LawtQVIES j26nXVSq63avLTElWZyOhC55E4prI35llJgLBYGLDBVTE3U9SJOrbE2tQM9SeMmki+hb XiWvGFNyjMfQNgyTs6B76LfNRfJ+MvLUyjdj/VQYu9dB6e3iWmkNEm9xnIw0TCKuSy+9 bOQQ== X-Forwarded-Encrypted: i=1; AJvYcCXsMz1h5GwnqoMkTHtxBE1cNeHjA/hkU0YVrcu055hJtNSHNhC2pFrl41tQx7V0J68dfP4zPUaIVJaJW1Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0FpiC5ZMyWgZzFTWWpITuofDuoBC5DUmO6+NIYeGE+mO6oCSm 3FK5iRor4Nz+pibRCSKViPjbRPedSy7pOH/x2tULvAi//R6/AlepsBMlHZlXZESxyQrkSDzH6Cl eqX7iqIhERfm5EMUxv0wk4gBdReaIJdsyW/3enmAKsWmSeahEJEwFb/zqGxZgEV6NGA== X-Gm-Gg: ASbGncukD0Li6x7HM7K1d1glm/Ku6LGtpvaPTNIw9qoNrXhyzPYiAPnEa/1bBXgYOcd BL11upuC0FeM3dfzjrKxm1kddWW+wvT7TUpFxZtSzrhOVkpCtPhXj790q0X3GvkA3BDWXMwCQTT 8rxb7jcGqfTJp4D4q/6VLbt7kY0TEviWUR6fdTw8VY200FSo915AAabny6tmMkMToNf21kiG0fs 5LUABvn7KWDZpVujDWRlyzL26gV0aE5kphiRsMtGsy6zRwTAosD/SbIXIprAtfhFg0xFmLQCyst YtkN5t5GxSAuDyZPX3pc5pAywEm/AbYzfg7oPbIZa5UoJ6kBdIdHi/2kXaAYAwj7RQEH4M6JiiZ o4A95Y6fBbXwl8SzeEJfyqA== X-Received: by 2002:a37:f506:0:b0:7e6:4fc9:6457 with SMTP id af79cd13be357-7e820b11efdmr25046785a.54.1754503776317; Wed, 06 Aug 2025 11:09:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZUienyzEiTH73cCxQzcvtLeEUdg0Wbv5ywibHSA1otSIptcZDf2H9J5vbyp5qib/Hnxqflw== X-Received: by 2002:a37:f506:0:b0:7e6:4fc9:6457 with SMTP id af79cd13be357-7e820b11efdmr25042985a.54.1754503775800; Wed, 06 Aug 2025 11:09:35 -0700 (PDT) Received: from x1.local (bras-base-aurron9134w-grc-11-174-89-135-171.dsl.bell.ca. [174.89.135.171]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e81542b0d3sm145980085a.21.2025.08.06.11.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Aug 2025 11:09:35 -0700 (PDT) Date: Wed, 6 Aug 2025 14:09:32 -0400 From: Peter Xu To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, david@redhat.com, aarcange@redhat.com, lokeshgidra@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, syzbot+b446dbe27035ef6bd6c2@syzkaller.appspotmail.com, stable@vger.kernel.org Subject: Re: [PATCH v3 1/1] userfaultfd: fix a crash in UFFDIO_MOVE with some non-present PMDs Message-ID: References: <20250806154015.769024-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Aug 06, 2025 at 10:09:30AM -0700, Suren Baghdasaryan wrote: > On Wed, Aug 6, 2025 at 9:56 AM Peter Xu wrote: > > > > On Wed, Aug 06, 2025 at 08:40:15AM -0700, Suren Baghdasaryan wrote: > > > When UFFDIO_MOVE is used with UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES and it > > > > The migration entry can appear with/without ALLOW_SRC_HOLES, right? Maybe > > drop this line? > > Yes, you are right. I'll update. > > > > > If we need another repost, the subject can further be tailored to mention > > migration entry too rather than non-present. IMHO that's clearer on > > explaining the issue this patch is fixing (e.g. a valid transhuge THP can > > also have present bit cleared). > > > > > encounters a non-present PMD (migration entry), it proceeds with folio > > > access even though the folio is not present. Add the missing check and > > > > IMHO "... even though folio is not present" is pretty vague. Maybe > > "... even though it's a swap entry"? Fundamentally it's because of the > > different layouts of normal THP v.s. a swap entry, hence pmd_folio() should > > not be used on top of swap entries. > > Well, technically a migration entry is a non_swap_entry(), so calling > migration entries "swap entries" is confusing to me. Any better > wording we can use or do you think that's ok? The more general definition of "swap entry" should follow what swp_entry_t is defined, where, for example, is_migration_entry() itself takes swp_entry_t as input. So it should be fine, but I agree it's indeed confusing. If we want to make it clearer, IMHO we could rename non_swap_entry() instead to is_swapfile_entry() / is_real_swap_entry() / ... but that can be discussed separately. Here, if we want to make it super accurate, we could also use "swp_entry_t" instead of "swap entry", that'll be 100% accurate. Thanks, -- Peter Xu