Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6705846rwb; Wed, 18 Jan 2023 08:23:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBohudqgP7CnS8tyx001ijkz1t+/ExseOm6bbhnKBreg2k7Ivz0tHiXgE+b9Btslqc14mz X-Received: by 2002:a17:90b:1211:b0:229:2964:53ad with SMTP id gl17-20020a17090b121100b00229296453admr21315226pjb.1.1674059021136; Wed, 18 Jan 2023 08:23:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674059021; cv=none; d=google.com; s=arc-20160816; b=Z9TT342BdJOBNT84QTD1cowboe+DuRd5e8ijL8W6lYpgjMpbUt+HyB+BMwyOiZN6m2 Wtt98w6SDVeoYOk9pbaGNxZQjXLFQPjexzcGne1dZhh2Ioy/f+UPxNeE4Ub+hjuQ0gPl rNVWppBiMkXj8xFOJRM/aZN0yV8bGWJNy/KKKF9odVt41UeTwbE1TrMl0zKJnq4ZLkqO Y3JXE1Eb/aKn7YiWnrXqt8DmshKlLH1xQidYn33mbzTlBGQ4xZCY4Om2aOTcUR52tQlv xv03hN+IB/fpNXtzPdJU8ZHEOyQKj+infi/+L3fQK7dPKoHwQSQZEts3GFHyR6cSCjdg GULg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yMnfiDl90nDMp75zhCoCphPVt5I3scvrOc1ITYVkfYQ=; b=v6c6Lb2uI69OX1DEV+erYc1DyD4v9RotRWiK+tfvpFColcBMLj3vqP5973QgOQCy/8 +koKD3hK1TvhM4o/fWRadGgzLhI8h14PKb7MaleBTCieN0STDHPzQtQzoEuYTfLkm7VJ J+TWzOb4vowp+cb0xf1Gsp6sGQHQNf87Hxxl8B7lUaw8m4aX0IdGHyLt4a5QrTX6MpP4 y5wpDHH/m9vID259lkxWUjpBT/4xXo8THhnWPY/TItNmUd3zAzAQqP5Wchjj/LyDCXw8 L+vU1czBzxlyETI3ajziR9q7Kxo+LjpYjs0IElMpV79At85UC5Uqww8DqSbUx3NGwYQz fbIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=PdMtFWv6; 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 qi10-20020a17090b274a00b00215dedefc32si2384815pjb.163.2023.01.18.08.23.35; Wed, 18 Jan 2023 08:23:41 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=PdMtFWv6; 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 S230395AbjARQEP (ORCPT + 47 others); Wed, 18 Jan 2023 11:04:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjARQDl (ORCPT ); Wed, 18 Jan 2023 11:03:41 -0500 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE11F56EE4 for ; Wed, 18 Jan 2023 07:59:40 -0800 (PST) Received: by mail-qv1-xf2d.google.com with SMTP id q10so24032271qvt.10 for ; Wed, 18 Jan 2023 07:59:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=yMnfiDl90nDMp75zhCoCphPVt5I3scvrOc1ITYVkfYQ=; b=PdMtFWv6YOkJKhAG4gLjZhgFPo65DsYbGhXsa3xdtPIKBIPTic0rHcEQ3CdiRbooys MtFyqsMqZIIgHuIoVgVIVuT6YoFxNTQ2CcVt6GhEwOcXD09vu8nJ2n4BB6fo3/kBhPt2 JxhySlSm6v/yV+rqY6m/f6nNkvkEhQaiHRo6M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=yMnfiDl90nDMp75zhCoCphPVt5I3scvrOc1ITYVkfYQ=; b=uTeypvjs0CEL8OIAquveHulL5TZBL8Uzqji+HTfQAD0RjmVM7MWQXrsL7/eb8vaYhJ tM0EvsA36bQ3ha1TdvV+nDn2G05LVGm5ZkKoyDWbUcHuLtHc5XunkrBX7PAqOUAnI+0A gSFwu/2VqKjBrhjZ/Ln4IVakVu0Im5nHgcuxBrCpSdyS7XkN9dh0ZaGNd9H3lZWzcxU3 +0khY+1j6U06zt3YK6qZtpQ9rwvrFYqezp3VspOeGcH76bpPHLio7ZdX5GkdXOBRM1xl DYwkLJej5Np/FN8ORTzFg8yYCGlUgwaPE/Psjd1nAoGZwdjy+lPWZNIQdL+esjszc+GI Kefw== X-Gm-Message-State: AFqh2krxiRrGEmv94SaRpKzuU8XVn5heB16340qjCpA9A8FbKHVITK+l x07shYXn8qndYV7dDOWp6VcCDshwBcNpcxX/ X-Received: by 2002:a0c:ef4f:0:b0:531:c196:3dfb with SMTP id t15-20020a0cef4f000000b00531c1963dfbmr36338668qvs.25.1674057579632; Wed, 18 Jan 2023 07:59:39 -0800 (PST) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com. [209.85.222.177]) by smtp.gmail.com with ESMTPSA id u8-20020a05620a430800b006b615cd8c13sm22698539qko.106.2023.01.18.07.59.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jan 2023 07:59:38 -0800 (PST) Received: by mail-qk1-f177.google.com with SMTP id d13so9514795qkk.12 for ; Wed, 18 Jan 2023 07:59:38 -0800 (PST) X-Received: by 2002:a37:6387:0:b0:706:92f4:125 with SMTP id x129-20020a376387000000b0070692f40125mr423230qkb.72.1674057577814; Wed, 18 Jan 2023 07:59:37 -0800 (PST) MIME-Version: 1.0 References: <20230111123736.20025-1-kirill.shutemov@linux.intel.com> <20230111123736.20025-2-kirill.shutemov@linux.intel.com> In-Reply-To: From: Linus Torvalds Date: Wed, 18 Jan 2023 07:59:21 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv14 01/17] x86/mm: Rework address range check in get_user() and put_user() To: Peter Zijlstra Cc: "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , Bharata B Rao , Jacob Pan , Ashok Raj , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 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, Jan 18, 2023 at 7:50 AM Peter Zijlstra wrote: > > On Wed, Jan 11, 2023 at 03:37:20PM +0300, Kirill A. Shutemov wrote: > > > If an address with bit 63 set is passed down, it will trigger a #GP > > exception. _ASM_EXTABLE_UA() complains about this. Replace it with > > plain _ASM_EXTABLE() as it is expected behaviour now. > > here I don't. The new logic basically squishes every kernel address to > -1L -- a known unmapped address, but getting that address in > {get,put}_user() is still a fail, right? > > We used to manually branch to bad_get_user when outside TASK_SIZE_MAX, > now we rely on #GP. > > So why silence it? We don't silence it - for a kernel address that turns into an all-ones address, the the _ASM_EXTABLE() will still cause the -EFAULT due to the page fault. But it's not the high bit set case that is the problem here. The problem is a "positive" address that is non-canonical. Testing against TASK_SIZE_MAX would catch non-canonical addresses before the access, and we'd return -EFAULT. But now that we don't test against TASK_SIZE_MAX any more, non-canonical accesses will cause a GP fault, and *that* message is what we want to silence. We'll still return -EFAULT, of course, we're just getting rid of the WARN_ONCE(trapnr == X86_TRAP_GP, "General protection fault in user access. Non-canonical address?"); issue that comes from not being so exact about the address limit any more. Linus