Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1093295rwr; Wed, 3 May 2023 10:04:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5URJjt6oVDh8b475g4kwi3BBw8Yt1cZkVF/CxVy7pxXNG/PNSTshiddP9sOsY4uQTXuWoe X-Received: by 2002:a17:90b:3e8e:b0:247:2152:6391 with SMTP id rj14-20020a17090b3e8e00b0024721526391mr20382809pjb.17.1683133455189; Wed, 03 May 2023 10:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683133455; cv=none; d=google.com; s=arc-20160816; b=QitPEbYNZwVuk85QFVPcTZFyP53ybF0xsnstCThCRYPDyWwGyH+vinDIuiEOwzsXyE gXpXyf4xBymkQT/x08nynSjGNNoKKeBD/x2zBgjlubAml+KXVN4Pf2YDfoTIJrBpLJCi z5jtNLobZnG9MDViDX7AbT07SsFTZTfvGe+gY0pHcVB/boKY+M3L7/Ncf1nwoIY0dCQK PwJ8tzhTyTUXirO6IFjypky62E1Nz5f1xOXWFdBKwAep6ZGrqnnX5D7D3rLMx3hhDDl0 Z76IB966mTomMKtGB02VWvbNYthk0DRQzOsCze5s4HgzmDG+tXeWtPpowxurcUzjONGB w37A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=aHVhQYzfld0G3Q00SBMgtA1efoI8gmOuzAdIqG+F6L0=; b=RSUa1PyB+s/4OUABrj7mjzKDLFDbR5/zD/qqutNjv/5hE0DlArlU3ZM52HWVjj3kPF 7F+IZV3We5kMBwMZu+NqRFHpgEMjZNU7/QBPhqyuP5nMF40wjT8shde/xK0rlyH+9KXG 0auI4ryBRigDpVl1ZNVO7LcFNGFj4rnXbLUWqHJy/TF7dHhDDvi4pqwOVcTMI+1PW8FS qTVEFycdv6wJSWoAFMPF/JY2TcTbwDV7fkg+lKdObk9pZa32N7DBWjlEZUrUXp8MM3WF 1ZvdJsuV5StesrZhvVi+g+CScxTdApwy8Ja/q7cihqkezpC/o2qOyaJdOcs4QdlwK6q/ aRqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=A3P42I+Z; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m24-20020a17090aab1800b0024e2bb99e67si1874783pjq.7.2023.05.03.10.04.03; Wed, 03 May 2023 10:04:15 -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=@linux-foundation.org header.s=google header.b=A3P42I+Z; 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 S229758AbjECQwW (ORCPT + 99 others); Wed, 3 May 2023 12:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjECQwU (ORCPT ); Wed, 3 May 2023 12:52:20 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57A2655AD for ; Wed, 3 May 2023 09:52:19 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-94eff00bcdaso1040674666b.1 for ; Wed, 03 May 2023 09:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1683132737; x=1685724737; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aHVhQYzfld0G3Q00SBMgtA1efoI8gmOuzAdIqG+F6L0=; b=A3P42I+ZvOl097Rp80s10pAIZb6piOqKWhBPqxaWRVb0MYtaIP81nlAQJsWyqO6AgR 8SBalUVQhlI1JVxK5M4FeYbOpU5F2LoLARsq/+0rry05Hj2ZANE6mxCXD34XOmRza+/Z DSOyGfGA2Br6QazuoIeXeIkX78RSjbRQpDrIg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683132737; x=1685724737; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aHVhQYzfld0G3Q00SBMgtA1efoI8gmOuzAdIqG+F6L0=; b=k0p1WLVtCLAApFC0ZPkI5Gx8Q9+1nWANVOu2vIgaZBvw9fKf4boIewAEvTBzTwY30z xqqEqpWnb3chliRYPfiyWpXPa1CGQT2YXRl9UxBNbd5bB0kR9QOET7MmACfqzE3WdnSt 4kHNZeEL8qHhnDzyiXRlf0hMOLf1y0Ma99GLo2EMC50Z7Zvi+gbxU9mxOlX+m2bc6inV Ny2rBWGqeQK/QWTxJ6cFKh4hEvPLP0iYt1IOuyIfDmSOYm3gTIF42ydNwFjkJTA0krJk hbCpmWnw9U8zY8+/Ki+d6/dpURrtQqvFcO9TfmDWli46QFvxan2X9xwMeZxLL9Ep7CV5 1qIg== X-Gm-Message-State: AC+VfDwqXAFyvm/W7Jtb5VCgMUKLdM/nfKDcyIu5uwymR7h41LaocpyR 1UtmndwPOGw8fDph+gya3iGIRNabIWeGHvO8OhxG0w== X-Received: by 2002:a17:907:70b:b0:94e:fa56:a74f with SMTP id xb11-20020a170907070b00b0094efa56a74fmr3466907ejb.14.1683132737499; Wed, 03 May 2023 09:52:17 -0700 (PDT) Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com. [209.85.218.52]) by smtp.gmail.com with ESMTPSA id jo2-20020a170906f6c200b009538cc79241sm17723830ejb.56.2023.05.03.09.52.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 May 2023 09:52:16 -0700 (PDT) Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-94a342f7c4cso1042918166b.0 for ; Wed, 03 May 2023 09:52:16 -0700 (PDT) X-Received: by 2002:a17:907:6d83:b0:95f:2046:d20d with SMTP id sb3-20020a1709076d8300b0095f2046d20dmr4171169ejc.2.1683132736505; Wed, 03 May 2023 09:52:16 -0700 (PDT) MIME-Version: 1.0 References: <20230427225647.1101172-1-dave.hansen@linux.intel.com> <20230429003822.n3mglslg666j3npp@box.shutemov.name> <641a9348-a052-6bb5-e6c7-64acb6405328@intel.com> <95f17f84-f172-417c-fe7e-ca0a07b205fb@intel.com> In-Reply-To: <95f17f84-f172-417c-fe7e-ca0a07b205fb@intel.com> From: Linus Torvalds Date: Wed, 3 May 2023 09:51:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] x86/mm for 6.4 To: Dave Hansen Cc: "Kirill A. Shutemov" , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 On Wed, May 3, 2023 at 9:45=E2=80=AFAM Dave Hansen = wrote: > > On 5/3/23 09:38, Linus Torvalds wrote: > > If somebody actually tries to untag a kernel address, that would be a > > bug anyway, as far as I can tell. > > Is it a bug? The do_madvise() path, for instance, is passing a value in > there that came right from userspace. That's still a "user address" - just not a *valid* one. So we do not want to mask the high bit off - because that is what will catch people later doing things like vma address range comparisons on it and notice "that's not a valid address", but it's also not a "kernel address" that we need to preserve as such. So yeah, it's a bit confusing in that it's _also_ true that "kernel addresses have the high bit set" and "user addresses have the high bit clear", and I'm basically using two different semantics for "kernel address". IOW: what I mean by "it's not valid to do 'untagged_addr()' on a kernel address" is that you can't take a (valid) kernel address, do 'untagged_addr()' on it, and expect it to still work as a kernel address. But at the same time you *are* supposed to be able to use 'untagged_addr()' on a - untrusted and possibly invalid - user pointer, and it's supposed to end up having the tag bits clear and still be usable as a user pointer. And yet still also be caught by any validity checks (ie a high bit set would never be a valid user pointer, not even after doing 'untagged_addr()' on it). Linus