From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796223909; b=JqfbUVAoaHBrp7RguKqpckA2fz1XGE9V+WLjSS6yuIcFR6GLrdbovf1qAlWlFlW4WD6j Mnp22C/E5TxLajTcWlG/lQsAFhcgooXr47Ed7xqFiCytBGk1bUbJItn7pkaVbwSsyEIpx qYqkLMuorRNud0Z0wdeepEvy5AGOG7LLlz1Peqk9/8sxcLb4ce4peUmGXe3rknnMPHD7A BN45KOHD509VUFYCOOi7BtBEmFJzqAuwXX8V6qUF24gNRIR+cA75bIQrAhyJ1bjGFiGyj ZOXD+SjsIGN4C9Zj55/BNnoyVstbEB1Lfc9wzge6JB6aLlKuhXARJ0XZBGZTJkSWtNw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796223909; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=MwioD7d0fAzPxxW2/QIGQhUJm38wJXEosronTT0s9iM=; b=wLpSs+xqHw5xs/Y2M+/007gC9vl2imUbTzQ/lQOSBGp2KoYi2kI6MPZCx1pZG986R15I seiCsvpBh4tKJOUBhR9zRpYw54CU6bJ1cL/PhXTPgvifU0QHWIVBdp864QqCFmmrBxS0q 5qP6NK/RZ6D8lIrMmCJiEK+Xrt52zWaj+OPNKTanWId2kV3aY/VZnINCQMB+YTEgofZAq 5XtK/K4BcYNBYZtDAeJk8FaiqXm0TfV+0L+ZvpawvSaVWyzk04Z4by5x9RPA0TdUN6kw4 NuE0dtyHlmv7ui56tLL+5NKu2fPbsqz+daGvMI9Dls8SmZLsP3YJPIZaJ1bv8NpQmLw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ONb3FUWH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DA12606A322; Wed, 2 Dec 2026 15:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ONb3FUWH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3500E1F00893; Wed, 2 Dec 2026 15:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796223908; bh=MwioD7d0fAzPxxW2/QIGQhUJm38wJXEosronTT0s9iM=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=ONb3FUWH1jNxbULVFXZZD0cPgZkB3i5SuLU4tuJbXOyZcyGtTCoZxH7B3oMko7XN3 qVbnU0GaRJCRZh9JPXaB9meD1FskBdu83q5U1pqdw6wCqOMVEo9lrBOW9ieXNXO5Me L50d2useofWwNM86rgRBj7jRlLkJMgLDZZI98gTCCXMPsHIfyP8iB/einvP189GH2o jtPthSWxZ3ehqd+kgh2un8Yg8syyakoEQedxofMv5nXULF0scZ1ZtcCne3yHstdEU+ f4Ijph3l981X+zKFqK8tHVX7s2n72xWHAtI9mdnEsES5a0BjQCxvNi7cRqDHQqcK6B C9CH8qfeFPP+g== Message-ID: Date: Wed, 2 Dec 2026 16:04:50 +0100 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 00/12] uaccess: Refuse and warn on user accesses when current->mm is NULL To: James Houghton , Andrew Morton , Alexander Viro , Arnd Bergmann Cc: Sean Christopherson , Paolo Bonzini , Jim Mattson , Jens Axboe , David Hildenbrand , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , Madhavan Srinivasan , Chris Zankel , Max Filippov , Dinh Nguyen , Simon Schuster , David Sterba , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , KP Singh , Matt Bobrowski , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Steven Rostedt , Masami Hiramatsu , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, io-uring@vger.kernel.org References: <20261202023920.595207-1-jthoughton@google.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20261202023920.595207-1-jthoughton@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi James, Le 02/12/2026 à 03:39, James Houghton a écrit : > Hi everyone, > > This series comes out of a set of bugs that were found in KVM where the > kernel can sometimes write to a random process's user memory[1]. Sean's > KVM fixes for those have since been merged, e.g. commit 2520694e6048 > ("KVM: Reject user accesses to guest memory if current->mm != kvm->mm"). > They are still required with this series, as they also handle the case > where the VM is destroyed from another process, which this series can't > detect. > > We hit one of the KVM bugs in production, and it was challenging to > debug. This series makes such bugs, where the kernel is doing uaccess > without an mm, much more obvious. > > The beginning of this series includes fixes for similar bugs found > through static analysis with Claude Opus 5.5. > > The main change in v2 is where the new check lives. Following Arnd's > suggestion[2], it is now in access_ok() itself, plus the masked user > access paths and the unchecked __copy_{from,to}_user{,_inatomic}() > accessors, instead of in each generic copy helper. This covers more > (e.g. get_user(), put_user() and clear_user() on most architectures), > and makes most new user access code get the check automatically. See > "Changes in v2" below for the full list. I'm a bit concerned with this change. It impacts hot pathes. All has been done to get access_ok() as light as possible over the years, and nowadays we are on the way of removing __get_user() with the argument that access_ok() is so light that there is almost no difference between get_user() and __get_user(). It looks like your series goes in the opposite direction. Also about the masked user access path, the principle of that path is to be branch-less, the whole purpose was the remove the test/branch from access_ok(). With your new check it is not anymore branch-less For a very simple function like: long mytest(long *ptr); long mytest(long *ptr) { long val; if (get_user(val, ptr)) return 0; return val; } Without your patch it is: 00000000000030b0 : 30b0: 39 20 ff ff li r9,-1 30b4: 79 29 04 80 clrldi r9,r9,18 30b8: 7c 23 48 40 cmpld r3,r9 30bc: 41 c1 00 14 bgt- 30d0 30c0: e8 63 00 00 ld r3,0(r3) 30c4: 4e 80 00 20 blr 30d0: 38 60 00 00 li r3,0 30d4: 4e 80 00 20 blr With your patch it adds two memory reads to read paca->__current->mm: 00000000000030e0 : 30e0: e9 2d 06 58 ld r9,1624(r13) 30e4: e9 29 04 b0 ld r9,1200(r9) 30e8: 2c 29 00 00 cmpdi r9,0 30ec: 41 c2 00 24 beq- 3110 30f0: 39 20 ff ff li r9,-1 30f4: 79 29 04 80 clrldi r9,r9,18 30f8: 7c 23 48 40 cmpld r3,r9 30fc: 41 c1 00 18 bgt- 3114 3100: e8 63 00 00 ld r3,0(r3) 3104: 4e 80 00 20 blr 3110: 0f e0 00 00 twui r0,0 3114: 38 60 00 00 li r3,0 3118: 4e 80 00 20 blr