From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796232541; b=tTQ3i/YiibLQmfh644sESvF3l3MWT12ZSsWNTfFTe435oX7oJiprF+fl74PE9w3yFHhH RBYdih47wMaWqnVRi9ApS+YJ4Gs1HOqMDN9yw2HgLEYr9/i0wI1vmhpQDJ8smhWY+R5dC U4ZEEMvbTy0Zy1OEYO4haAJBDtN62z1/tkgXyZsLPa4MZIDeo31dHVxNDrnwBnNyjQpvs JgdRXfLkuIm7ooDhg4cdaIMFJJC3WLbhVXPDxR4PLycXs6BIFjfb6TplBhI0/J0n+/cvJ fwdoYiMk/qVOEKhaGEcYo4Dra3a+JwTYfv3Uhpk21BShDQlpB/4eTeepySnmNL1gydA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796232541; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=yZSoTVHN/Pi1Ab+vqq+A8ChSxn9Jqwmgx3qN8Pp8pZM=; b=G+InAjBQ7BLCmTcccaIz0yr6JSgy6Cp6vzbhA1XnKD2bnG0lZ4hFnkaXT8UFTeW55dmP 5U3ERBPbWJTQsA6zo/5vXYZFZoRSEYk2Y2sAsIfiPDuYS1cLXaXIbi5VcUoUnRcoPv5SQ TWTRJQhpbsOmQ6+cVamGBKNpWNeHkEPKcBSUwThXf5jQadYS9GfNJQIASw7lsdOfHlElV VMV+ecIqCGEboRNdG9BxcRwpobY255dP49hkKC3I2Onk35VX1+I0EJO47Q0+Sa8TsjnXD Ftv4n0zjlZV0W2zLey4vHQClklNQKC+40JqsA3aO9Td3rE6QCYBDNOYo5nws/ufJeXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=lZe+Z9Qr; arc=none smtp.remote-ip=209.85.128.42 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 061B7606A33A for ; Wed, 2 Dec 2026 17:29:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 061B7606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=lZe+Z9Qr Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4bb72b44a97so116090295e9.0 for ; Wed, 02 Dec 2026 09:29:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796232539; x=1796837339; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yZSoTVHN/Pi1Ab+vqq+A8ChSxn9Jqwmgx3qN8Pp8pZM=; b=lZe+Z9QrfWMHDz2WR08hVnH7JqNFQBSaVWmKMhfJhsKIklw8TzYpI0MNSM52p2OkGr vjUgqybW9YTWiNtb1+K3F1002QiZuNRUrWv/wxwg+0t9D7ojQSgvHrZh8Cz/OVPu6mNf QPFM0YhEuHljGo3GOjOKGlTn/r66k61qFDzm75mDOZEUy5MX8xbHxHM71NEpBbM6jbv8 Vn73VUrG4mh0khOSqTSFyArRDrrncN8vPBJRqV5w53eB2ME0dL/xUbDlyMpDyLdGajcS FBNUghLtxXCIgyPBlSFzPBsqmLpBZyyxl2HuZrrM6+H715WH3OP6M6RS02YJE52LMH2h jZXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796232539; x=1796837339; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yZSoTVHN/Pi1Ab+vqq+A8ChSxn9Jqwmgx3qN8Pp8pZM=; b=iPy8GGK+N+QhP5HH6BfNRgSdJTUCWebDFHholVj5NoKxOnON0QQqEaZdAdznlZHQ7l lJOj6W1KZysc3UHNimb8sQsBu5R46WOqYM3STDazARrWxwWYkoljHMVvEV9yydl7Of/i fdmR3jOST7FIzLAonccOtxPF/ipCyYUxC3J8lyrnE+XhUgbSbOUh9BpkdkSI8g6dbESZ O8g3RHLIhxL0Eywvnh0WI1gIDwugDRFpBQ7wJpnmyB51SwHG54XiLJjXvDMfb3dpK1Ln yQDRsY6e3xjcgVOq+7TTCvZozkugR8qLdoxHvy1Q1VzuvPbjgQ0aEumZdAw6+o9rES4D 2KpA== X-Forwarded-Encrypted: i=1; AL+hErEN2OUgkq/VWRO24GW0WN77DKga574mkCXKrNylTGouU+bGlnU3Abp4rj0aOS+QL1EJV2u9AvDOZcbMAQ==@vger.kernel.org X-Gm-Message-State: APuU4Z/dxQPCRZhfT0qrp/fLsL1O2yclCkrQJD7k9zNgJsKKaJlWZBPA v3vvJ6yjkFsdVtZWnq1MGfrjHGMqN3cMWP2ocKrXGe8IT78sgUhJGMMo X-Gm-Gg: AZFdTZfkxYLcUzD1+XBSp2/AXhLdOENkMunYf6qMuUpyj6igsyDgGY6RC3dscnfL00B nofN3ScOOhAYoTCcQv5d1YboHpxFkp5aFqUmfJKy+EDP5VdYI2ar9czK5z9fSjtgc117nzqbCZq cN/fCs8WyhqRTaeykXWcnEry/t3he7NshibGosIfFK63zvS/9uOhagPHPewY0CL7ihFE/2ayN6W y96Jc/H6D4eOBCmYL3prrL7dQbRsncasfB+q97437xm0gcVIzgSSl+QoYS72yZ1MHLUif9Y15ge BU69/z8CrOfnWceyK4b1+8FJT7b/rNStHkiFaJVMogzACI48D5Z/a/lVDH/F/huIoMyTwqAuFAQ 610fvSOURiEv5UVs8v6GvwWq61b3dauX/Ht1R6JQ8ooxIDc//oAOqAORmdDsYUs3yxJE38747E6 mSU8L62TVrh4u0eoaHKZHh236gzKnB4dRrg0zDSZB4k/oHW/6Lc7I+EshmMTZRkDKXcuOuS5uc/ 5HYDwC3m0FcwIwSJld53i7Wkz8TLw81/81/8GEFIAF485fqSvnb9QAnZVX8pXjvfv8Hc7fB7yKW saegXOaU3KySIn0yDVj0GoaGV2ADi2bmbNXAabkHvrtR3zXoE8oSuEBTS0960/vR X-Received: by 2002:a05:600c:1389:b0:4bb:6519:477e with SMTP id 5b1f17b1804b1-4bb88813b35mr834255755e9.17.1796232538885; Wed, 02 Dec 2026 09:28:58 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe00a30absm1882605e9.10.2026.12.02.09.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 09:28:58 -0800 (PST) Date: Wed, 2 Dec 2026 17:28:52 +0000 From: David Laight To: Steven Rostedt Cc: James Houghton , Andrew Morton , Alexander Viro , Arnd Bergmann , 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 , 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 Subject: Re: [PATCH v2 07/12] tracing: Don't read user memory without an mm Message-ID: <20261202172852.4b1c5227@pumpkin> In-Reply-To: <20261202083259.6a20484c@gandalf.local.home> References: <20261202023920.595207-1-jthoughton@google.com> <20261202023920.595207-8-jthoughton@google.com> <20261202083259.6a20484c@gandalf.local.home> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 2 Dec 2026 08:32:59 -0500 Steven Rostedt wrote: > On Wed, 2 Dec 2026 02:39:14 +0000 > James Houghton wrote: > > > #ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > > - if ((unsigned long)str_val < TASK_SIZE) > > - ret = strncpy_from_user_nofault(str_field, (const void __user *)str_val, STR_VAR_LEN_MAX); > > - else > > + if ((unsigned long)str_val < TASK_SIZE) { > > + /* > > + * Synthetic events may fire in any context, including > > + * kernel threads, which have no user memory to read. > > + */ > > + if (unlikely(!current->mm)) > > + ret = -EFAULT; > > + else > > + ret = strncpy_from_user_nofault(str_field, > > + (const void __user *)str_val, > > + STR_VAR_LEN_MAX); > > + } else > > #endif > > Instead of adding all these crazy checks, and then we need to play > whack-a-mole when we add a new one that triggers the warning, can't you add > a helper function for this? > > strncpy_from_user_trace_nofault()? > > Where it can be used by places that do not care if there's an current->mm or not. > > If you are reading user space for tracing purposes, it may be done from a > kernel thread too, and that's not a bug. It should simply return -EFAULT. Is there anywhere where it is valid to call strncpy_from_user_nofault() when current->mm is NULL? So the check could be moved inside. Unlike access_ok() (and friends) this is a slow function and no one will notice the extra check. Thinks more... I'd also have thought that kernel threads won't have anything mapped for user addresses, so the access will fault, the fault handler will see the flag that 'nofault' sets (or itself check current->mm) and return -EFAULT instead of trying to fault-in the missing page. So the extra check only affects threads that have mapped user addresses but don't have current->mm. David > > -- Steve > From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16198606A332 for ; Wed, 2 Dec 2026 17:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nM7Zyy3O; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BryKaatn DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=2sNsyY+/V2+c4goSuy6BkTcw7TUzNe9Jx5oXdTKopus=; b=nM7Zyy3OPkQfV5ABoEnSomrNH0 6cEv8z+VXDSb03tjVCM34bDeIel+LYDNpKgHGlyZDeGArXQGADx5snbMQhWAUjJ+D22Ga8ciLyjLW s9KPRDBsm4qyYOwoTnurH68AVqsEBMN5aAXBS0YfTrw0L3z39oDntIuBojoavJYe2GWXSCo4P1t1u xko5UQDek8ffl9Kc1CDjD2pHiaS9gNkUruMNC+T0AEL64P+C8uTl19+S07lmKy3A9T47wSk8TqgBJ cqBI4LUgWRsRxlQT+9ZiVDw7u9glwGdsoPjRdLFDuC3CWpxqBrePc6F6hv84RxxDm5AumraZxT35l pTjMjXbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYo8f-0000000CMm8-0KLC; Wed, 02 Dec 2026 17:29:05 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYo8a-0000000CMkX-48Kr for linux-riscv@lists.infradead.org; Wed, 02 Dec 2026 17:29:03 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4b79502c27aso135947975e9.1 for ; Wed, 02 Dec 2026 09:29:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796232539; x=1796837339; darn=lists.infradead.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yZSoTVHN/Pi1Ab+vqq+A8ChSxn9Jqwmgx3qN8Pp8pZM=; b=BryKaatnBdQ3iPj1k7JtT/TOgd7vl+KZzF3K/GMl+nCHD7q1jdP0VY9NBDVvcEo3As fkMN9ZCaSi+zUneokASCSPTNMjFWCPZbkJ8e+WJZtNyXgv3H6cFUHAoKC8aeqFz8ZztG rgZp062EVU2P71qWmgJgAZvMr4eDlgv6RSxq0HxsfW8IQ2rf9nwiabMQkeZy7BkZgeuh 7axRcEn/Uaw14P2nPh7eH9EILYj0EixSTRjnhP3qiJahAJtDCAEV55TlpxlC1WvWUmIp S2m4968ZSBLBFmP7jMAJ5aLVwTI93bp2GPavpOmXf1qhgvt+HTEzGaSUADURRV6NXroG EfCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796232539; x=1796837339; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yZSoTVHN/Pi1Ab+vqq+A8ChSxn9Jqwmgx3qN8Pp8pZM=; b=uBM/01zxkGovIl7FX0x5bm/1mk95D4L+t7l3pfFc5Q+UjhTxxfpt6Wq5w9a3lfdQTy S1pJthlFNQyc+PjWUdFbHu+6C3D576hJaOAngtba4wzn+cIzZuPV9dBTwWSYFAjuH1wA hsKDcZQWboWqcacikcyPyHtIjwvusKE+0PXsJkdbzfI84L25UUD3Db9Dnac6EAzVekmH GPTnOdbwPwACeuHZOHB8K9bTQ0GKWrBFPujFTQdGl4je5gDkIxCrf2BXZXNN8qVaem5T AfmobLRjV4JgKKZXxm/B5Yr1X4fW/9iZ/3FOJyEelWhFXSGqaezvvGmumkgNPK6CPCGS C9lg== X-Forwarded-Encrypted: i=1; AL+hErHN24tv3pRm65kf31MUefU2OfixNm3pBr17oKuoLQSUOaRBwGACk/rlT7cFevrmwZyyTyC0BC5sjkrRZw==@lists.infradead.org X-Gm-Message-State: APuU4Z/LZdbkCeoB3vSlGjDQZsJ0JlxAAHyjfUo8OF/Qp17ZW1QWOe/7 Q+/tgz1fz+5iFswELQXvS4DbaClEWnOgOfhZ2bLKI5oLpnFnlpj5j0ss X-Gm-Gg: AZFdTZexGXI/Iz/LVGZKX9IOspPgV8qfxBHc7AGZuIpUoA84BzYT67fwDF3dWel2dNS dlvzbhu9s9n2knzudWBw6ATqsIjHjY7gADMnJRoSRIrBVB0f74bchUN4uWXJy5gHWtUJZ1V+9Ww eQNV8mYcDetiWy7L/tXjonsaaoS8Wrl6LFU8cSy+YZ0grgdgayxYHAWd3PJiJJgmcXABUP3AD3q Pc/ooSrHituSzs41z1USc1dq/fyYQGYuUQsXDg53tT0w6WZIvF8GOlXg62OGil2xuSJCaIYjqj8 kZJ0j/B8plDrzIw05ngEBfVQv0yI3XF5E9HVl6XTfWSLm2TVPSCa6s/6gwCEcgNUjqZvQwOyy3e UlprEN5WIoGjEeayI9m3C5MErjWsmZgLEDIJbnxLIDSVZGBGSuHZ9mvepXlBo3ZkNAGi7b3sG4L 3ikjEMlTKb9n0Ls/mAX8Yp7CeVyZGHiPwEpRfBSSCWvmD64D1LPwkzrYftNq2NhnCia0XnwikI4 pLZhUPaG3GuDpg55Jtu+4wGCVyqSCRWKQOVeWyqLrX16b3sFiVC5EREA/bBES/n+y2jddjEMizb rItnuT1Ct1/BbnfmC8lkx+QxnOMf4JEaPaVoqi0rEbY4AaenOM50jyDdAnoUp+29 X-Received: by 2002:a05:600c:1389:b0:4bb:6519:477e with SMTP id 5b1f17b1804b1-4bb88813b35mr834255755e9.17.1796232538885; Wed, 02 Dec 2026 09:28:58 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe00a30absm1882605e9.10.2026.12.02.09.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 09:28:58 -0800 (PST) Date: Wed, 2 Dec 2026 17:28:52 +0000 From: David Laight To: Steven Rostedt Cc: James Houghton , Andrew Morton , Alexander Viro , Arnd Bergmann , 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 , 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 Subject: Re: [PATCH v2 07/12] tracing: Don't read user memory without an mm Message-ID: <20261202172852.4b1c5227@pumpkin> In-Reply-To: <20261202083259.6a20484c@gandalf.local.home> References: <20261202023920.595207-1-jthoughton@google.com> <20261202023920.595207-8-jthoughton@google.com> <20261202083259.6a20484c@gandalf.local.home> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) X-Archived-By: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_092901_045061_18324506 X-CRM114-Status: GOOD ( 25.57 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" X-Spam-Status: No, score=-2.3 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, 2 Dec 2026 08:32:59 -0500 Steven Rostedt wrote: > On Wed, 2 Dec 2026 02:39:14 +0000 > James Houghton wrote: > > > #ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > > - if ((unsigned long)str_val < TASK_SIZE) > > - ret = strncpy_from_user_nofault(str_field, (const void __user *)str_val, STR_VAR_LEN_MAX); > > - else > > + if ((unsigned long)str_val < TASK_SIZE) { > > + /* > > + * Synthetic events may fire in any context, including > > + * kernel threads, which have no user memory to read. > > + */ > > + if (unlikely(!current->mm)) > > + ret = -EFAULT; > > + else > > + ret = strncpy_from_user_nofault(str_field, > > + (const void __user *)str_val, > > + STR_VAR_LEN_MAX); > > + } else > > #endif > > Instead of adding all these crazy checks, and then we need to play > whack-a-mole when we add a new one that triggers the warning, can't you add > a helper function for this? > > strncpy_from_user_trace_nofault()? > > Where it can be used by places that do not care if there's an current->mm or not. > > If you are reading user space for tracing purposes, it may be done from a > kernel thread too, and that's not a bug. It should simply return -EFAULT. Is there anywhere where it is valid to call strncpy_from_user_nofault() when current->mm is NULL? So the check could be moved inside. Unlike access_ok() (and friends) this is a slow function and no one will notice the extra check. Thinks more... I'd also have thought that kernel threads won't have anything mapped for user addresses, so the access will fault, the fault handler will see the flag that 'nofault' sets (or itself check current->mm) and return -EFAULT instead of trying to fault-in the missing page. So the extra check only affects threads that have mapped user addresses but don't have current->mm. David > > -- Steve > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv