From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795931498; b=OUuT950VfJBoUD0ntUgyMz7tu/xTrPfJoQ6hwrwQ2NkkrCrSeNEBCAvMz4OmWPj75Wvy x3AEnNLDOPzdXZHTsT11Ac5tmUnl3Ek5sw/EYGk4jtBBvMeH8r3lqQUIZ6HELzhLkyBkw LhsQUgPcL4Hk3XstxOzoyBUbKPOl6QhTnn7CGLX2A1RDzOl7dtYLwIxoIiVvoldentILo SmB1a4hOC9V41mzyEBa7c3DU+qNhfizthJV2RPE7Ef+KPE+FkBC63xTVrP4caWkMMoRuk y4tLLtobNZfLuZxKBH/k9MeDYq6CviruIcArJzc/trs39mONl2hMhf20UWHY8LpMiIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795931498; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:In-Reply-To:References:From:Subject:To:Cc: MIME-Version:Content-Type:Content-Disposition:User-Agent; bh=fDiJt3Qa2qkK9peHAViHxCJNzh/Hj0uhNvgw/EOhWBw=; b=18jtCx98Q97qVjjVQnbu3X57otIqSWxGOiRwxOeVwN9m9tlIqJYQZjmnAis+feJj0H6H OhA142u8WSkOL3KJfy0FlJuaQjrA8d/FHA0/El4F7uFItPu9he+EBG6nxCQV22T0ZrLaO x2glEVFwnyqCl5zHcVf3oNeIDut5TO3z2IKKZ/5ognjW4RtQClTTvoqbUdwHxSfyfaLwC cR9WVIzwVsfhgA1bQhZmOgUF0qh+szzM0dsEYKB5zBRnn74oT1+YnV+fG1FPGsTdKCfD4 rHO+hAP/A4dGdyyci4AhBGJ38gVOl27lLkS8t2NfJ6QeDxLtmCfg/iHshfPIBAWhCIA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=sTE+WWsa; arc=none smtp.remote-ip=74.125.224.53 Received: from mail-yx1-f53.google.com (mail-yx1-f53.google.com [74.125.224.53]) (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 38490606A32A for ; Sun, 29 Nov 2026 05:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 38490606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=sTE+WWsa Received: by mail-yx1-f53.google.com with SMTP id 956f58d0204a3-67db6d4054eso10113389d50.1 for ; Sat, 28 Nov 2026 21:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1795931497; x=1796536297; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=fDiJt3Qa2qkK9peHAViHxCJNzh/Hj0uhNvgw/EOhWBw=; b=sTE+WWsaX6Se7doQb5sLiUplvrgSidgOqPJlIgf5mSSRqumspoNukl0KIlxQEOjh84 aFodLAwfjuEqmSKNwaD/nr2LINXpYMD19ahUyBL6yIryGYm26CYgzbmQGPPZEhrrQtl6 jFYC4COiOx8VSjCCuidVa7GoWpuAqqvaaPjeU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795931497; x=1796536297; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fDiJt3Qa2qkK9peHAViHxCJNzh/Hj0uhNvgw/EOhWBw=; b=b6l+etsHgS0FqtlAqInVmC/IUt81wyrcirOnox1lNdvzjA1gcRFFiV2WFDh7q07sge PvQJ/6ruFrkO2JSfYPYvKvQI9/23u5sQf2T24z2oLtWX9Dywcben2zhAvWoVHN06tBWH hFH8u2Z+pKMnSQrFBlCwEK5POijCatJLadOYDIQhX3U0+lNTtCCRT3Q0QSr6uSIK9kfo Q91RWcObQdxuDPzlZ3sa2XmY+Z2ERx4+Q54snxT1R/DmFFzN2kmvZDpC1X5FoeBe1IeM P2BrGFCfhCgj/gZFw4sahmW7tNxKF0FHnZ7nY3MyGjQmiqITyDZIn+Yoh4nJ3q9VEcBE OgWw== X-Forwarded-Encrypted: i=1; AL+hErE83MV+BA534DEgN8sw7raLLG2VIPxKqTxJ5eX+1NGEX1d4b36O0Azx/x1OoPAKj1RfJgnLD0OGhDU3yPA=@vger.kernel.org X-Gm-Message-State: APuU4Z9w5W2Sw3DVonpHc1O805wwHjYfgxCITP0oYrcvd4qiX/yqm3uA gGPI8B48H39VnrwLqCDZQVfU2p/XpgqXOEdmN5wH4wIwWCNnBz222L0qvBvDpKz/IfA= X-Gm-Gg: AZFdTZdo9zMO4EpU1wFrwFyU0YJP//aSm6hTQHgTgM4ggD1acwZEdYKtNdYA8mWBR8c t9aONI4EP9g2Vy0LQyITxgkK4IgZRFoZC4C7JfUds+RSz+l8N0218pifsJE6y2uHIEWOYWfXncq fcUnxLMbDwrDG9p69H73ijDk2qg3lwABfZTSv19aZb0+i5tRFx4GBiU5DZL6YuU0FKJDQS1WeW2 E9gIHkxhp3uq83ifFG2m5vgYurZ/F9q2Q/d1h2RNTC/bqbvxEtrD8L+HOpn5z4Bb5TmPJKkR2s6 3DbWO/foAkao/6pyfu+UZMy55T0t/2BTXdZiGVutEbKGjg6LnMmS4a6uPMir4WTzbuM7sTZAtuo 2vbseN6OcQ1j9DVLbY3rvt0lDAqg9cheJBz1uMArdn18EyQqhFhXaE1E8g4zsp4vzc9EFl1iJwM YbqdDd7KYZlae2kZ1WLtLWP1+eeDcS4GRln5UVMLIQKJGzKv6aOsaMOKTrtg+1QhdpWYz4T6YcA 3g96WVI8s5b6eEdOYoYN4ZTA2av3MG2Z21SEo/SA8k+vy1iu5GPdSTCi1KCuwGSgMnDxPfaDaTE sqNSr8zxWWlkrsGz+8hmp0qR+xj763IQE121O5BQSBZim+SpYojBV/+plo9Wc3RCkgubn3gdr2A ELFglNuARtD74qZ6gfzWTUpOcAyvcBZomFQ1HsUauSXyHxLGttVz8R6K2hqHkaqHpLIYXz7wQnH lXsNmdYxKCgCAs1W9pnecHysaTwZwcRsLuAcSpKshsdIgZoy0x0qMWJ/tASI9dilb6uzaOLQwLE rGQnPoY5qPK6CsLip+vxRdw8+3SWvTCeCK8AFD9GaW2 X-Received: by 2002:a05:690c:9b01:b0:8b4:e2dc:3f18 with SMTP id 00721157ae682-8b5203294d4mr132989647b3.3.1795931497187; Sat, 28 Nov 2026 21:51:37 -0800 (PST) Received: from [172.20.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b5202fb0a2sm111392567b3.27.2026.11.28.21.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 21:51:35 -0800 (PST) Date: Sat, 28 Nov 2026 21:51:33 -0800 Message-ID: <3b7ddf9df487575f1fafa7c35d8653ba0181329e.1795891579.git.chris@chrisdown.name> In-Reply-To: References: From: Chris Down Subject: [PATCH 1/2] mm/util: don't let get_cmdline() stall on file-backed arguments To: Andrew Morton , David Hildenbrand Cc: Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Mason , Paul Moore , Kees Cook , Willy Tarreau , audit@vger.kernel.org X-Mailing-List: linux-kernel@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-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) get_cmdline() reads a task's arguments with access_process_vm(), and in the setproctitle() case reads on into its environment. Since commit 7f7ccc2ccc2e ("proc: do not access cmdline nor environ from file-backed areas"), /proc/pid/cmdline and /proc/pid/environ pass FOLL_ANON so that they only read anonymous memory, but get_cmdline() was left alone and still faults in whatever is mapped there. The task decides what is mapped at arg_start. It can mmap() a file over its arguments, or move arg_start with prctl(PR_SET_MM_MAP), which needs no capability. If that file is on a FUSE filesystem whose server the user runs, the read blocks for as long as the server holds back the reply. That matters when the reader is somebody else. Yama reads the target's command line when it reports a denied ptrace attach, and the msm and etnaviv drivers read the command line of the task whose job hung the GPU from their hang recovery path, msm with gpu->lock held. So the task that hung the GPU can also hold up the recovery. For example, take a FUSE server that waits three seconds before it answers a read, and an unprivileged task that maps a file from it and points arg_start there. When another of the user's tasks tries to attach to it and Yama denies the attach, ptrace() takes the full three seconds to fail: PTRACE_ATTACH returned -1 (Operation not permitted) after 3.002s ptrace attach of "FUSEARGS x"[109] was attempted by "/tmp/cmdtest file /tmp/fm/f"[110] Let's pass FOLL_ANON here too, so that get_cmdline() reads the same memory as /proc/pid/cmdline. A task whose arguments are not in anonymous memory gets an empty command line (audit logs proctitle=(null)), as /proc already shows it. The task decides what its arguments say anyway, so this doesn't let it hide anything from audit. With this applied, the attach above fails straight away. This doesn't help device mappings with a vm_ops->access handler. GUP already refuses those, and __access_remote_vm() then falls back to ->access whatever the flags. [1] stops that fallback for FOLL_ANON, and with both applied get_cmdline() no longer reaches device memory either. [1]: https://lore.kernel.org/r/20261122-access_shite-v2-1-808d8d2aa700@kernel.org Fixes: 7f7ccc2ccc2e ("proc: do not access cmdline nor environ from file-backed areas") Cc: stable@vger.kernel.org Signed-off-by: Chris Down --- mm/util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/util.c b/mm/util.c index 338f259b0035..c250aa088046 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1048,7 +1048,8 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) if (len > buflen) len = buflen; - res = access_process_vm(task, arg_start, buffer, len, FOLL_FORCE); + res = access_process_vm(task, arg_start, buffer, len, + FOLL_FORCE | FOLL_ANON); /* * If the nul at the end of args has been overwritten, then @@ -1064,7 +1065,7 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) len = buflen - res; res += access_process_vm(task, env_start, buffer+res, len, - FOLL_FORCE); + FOLL_FORCE | FOLL_ANON); res = strnlen(buffer, res); } } -- 2.56.1