From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796350689; b=m5uQrXxwlWTPP8K/sfCbCgaV4YkBsevuL9RMebomGbMvLd6oHnY0fzUUQjuEhrSDV7uD loGMl2KBtuzHl7bpTdet1UP/9fWhuqSEOQhleLQKbIaYnFn8FIJSsjLBbVafaBPMOgD32 dZ+E2ssK906lmqnidt646S7buVaQrgEDqoxhfdgRB7xeDJYwnK50uBH4/4IpGmRIfT7C8 gGHCS7K68GQCWPj62Yxxkyx9EgHQbRLKPVXPqFaW4s9YZXDVEgabOCTlJgcqSsFHArPUD EWwXziTfm3r9ptE/KsNTNRaP4AVfBxbgq5C34ScUVDvyiNOlDaYMLKzxCkYcgDYx1JA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796350689; 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=lskAjMt02yDOboEFb7ii4TTd4T+LDvnNAY94zqfInSI=; b=BKyucXXDHHRL56Tu2E9Iyd61fLJyKPJJSS43KZSmG3SG5aMnLnTS+vF6V69PJUHTpL4D JU/d7Iwy+tC52MXxZg8l+MvrCybmHVKTiKGxTINtDIrInfQ1iDUcSA4oCKfyb2ZGBDWoP yO0oxcPeTLgd0CgtRU+GhW+hItPIeLaUHTS3afyXVZb/IfySH5ZoN3u2jxqgMsp7V4hu2 d4nybbF7TIOIUdwuqmrD/O5kcZh6JosWbu4d0EhdXJSUhsnwkyM1XNUM4HcPuXAOETAom kq4f5Y6jw+6duBkS4UyJzU2hgBs/UdBQjT1RAwTMAiMz+kJnQfNC1QO+rH1KJ43rOIA== 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=exUUlRRB; arc=none smtp.remote-ip=209.85.128.181 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 33ECF606A338 for ; Fri, 4 Dec 2026 02:18:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33ECF606A338 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=exUUlRRB Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-8b503e2a87bso4656647b3.3 for ; Thu, 03 Dec 2026 18:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1796350688; x=1796955488; 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=lskAjMt02yDOboEFb7ii4TTd4T+LDvnNAY94zqfInSI=; b=exUUlRRBwN60jUxLWQ/EONLhbY3DARgamuH6rYte0EF+TsEvpXAbhzGIDwZ9oSdKnz r/KQbDBg1OJZjZaDEjtk0hGmGbK2OUaFw8OPnpOfkZN7gEzc/rzYvXKl2FVSsr9KfLFa xvvyZmXavbPPTzPgraRRot10G7XoadFO8tHEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796350688; x=1796955488; 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=lskAjMt02yDOboEFb7ii4TTd4T+LDvnNAY94zqfInSI=; b=1qp3DDXisD0p4w5A8lFBm2IOfn0sUllsF5aKRkbScW0xXjEF3XZrUmxuFl5npe8EEu cHQDbb0eQ+xb4kP6sV9GZOXoWKXIQ9wGjjA4sEqgkxqDPxWWuIwxromkaH2uXVO9vVIm O4ovTcFHCCLtwelmGs3zfGX5uyj8ATQlzSqYJwf6fnxqEKUlt8zUVX+9xGt3OROhWjvn 0Prw+AwQkEhZkJL6bbPN2WRviWK0bvVNqZZ3yeF/SiyvAF+vxzie8GNmbcODXrl81V4m fE1ZmjGjOPugb7b/3sgxrxxxKT8pnI1jD3hxq3vkya2f6HVUdctu3DTwfgvZEqDrscti /cqw== X-Forwarded-Encrypted: i=1; AL+hErGg5ejVhBiNoEnuV+I+bLW/ZKR7lriRkaeoVQcUC2GFcB/HJPrQkpyLctdTsfukdjuZ4jOSwpTb/WR+9/g=@vger.kernel.org X-Gm-Message-State: APuU4Z9gqrVyevmvlmbvlT0lQWgOkF3GyGDGhM78N7kjuHgZ/GbiAnnt Pey05XHJmSxQmRGOqUDeNCnFXf/UeG2qwWR/4mqsihJZ9nl6jzkF+T7uJjpL8qME6FY= X-Gm-Gg: AZFdTZdPPuA8RPKIXvU/OsfqR7xg7IDZnALbg18PspCorrrs4VSX9lnFi8eEjxC4/zs WgZoFaT6MP39Wc5nAk3eSlVQR5OAfODF1Ghv8MrVvuHhdmdA8/9sNaS8Wttab32tnqpkW/w/syR zIuKtp43hwqkOjLYVFUIkd39CfUqpTGTJpRrpe1UVJcfslsei0oM7qrdOQrFv+RQ9VCZ9mKrv0z QN3l+ZRJ1q+yECi6lg+unoB0bvyQtnJ2e436GZ/ej1qDlxBZS8qJGyzUvkU9XiD/49G1f6HnkUC FhYu9JeUoUSJ7ZZGpO7LjutycOR8hQ9S6OLqTVqbxEgl9/tNTdJqKrUII1lUTbw3RQ+5AoweXZL yenv6loH9QkAkCoOizZGg8cbTiGT1mD/CK/Ga1DzoemtLKDrOThCVRyL7+KglYb4o4na6EVWirW 2rUn2zJGd9b/gWbI9BfEG2is9HRk8IVrW2KExDUIC85tLnLqn6fIREoiqf5ZOE4JM1lcy+J7fAB DbaJr1Un2Twv4QEuW6Cb34gA1fRJkmk500+QSEAJvt/Nr8s3jDuC8PzL5WM5bYVbxTKbyo53ivq EqTIGnePU7I/dqTr1oP02KfkJ95e7b1+qS/gzQmE3AGBacJp2mXxLGtRN7HrUu0PrQSaqew1IZ9 th7Zl5GpTwEM4J9lTkudGVl3fqY3WXJlpjNeRZAayw2nDnuAp3/Z8VO/5zM7kxTmPV2bADzTBm/ GuOGnnT8HDfMb4ULOaHvquXwAcygvx4jKeNvyBD8DdL36fMDxjS2Bhs/EXj9lPXoVCeRj77Pv9a Ey9R6GWI2J1SxbLiKSYgV8= X-Received: by 2002:a05:690c:3608:b0:8b0:df71:44cf with SMTP id 00721157ae682-8b660662a9emr5060777b3.15.1796350688133; Thu, 03 Dec 2026 18:18:08 -0800 (PST) Received: from [172.18.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b660d5c3d3sm3868687b3.22.2026.12.03.18.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 18:18:06 -0800 (PST) Date: Thu, 03 Dec 2026 18:18:04 -0800 Message-ID: <13002a6c2eb14ec996c921acb97dcb8ef28d7cdc.1796349991.git.chris@chrisdown.name> In-Reply-To: References: From: Chris Down Subject: [PATCH v2 1/3] 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, sashiko-bot@kernel.org, kernel-team@meta.com 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. Since commit 775abaa42585 ("mm: do not call vm_ops->access with FOLL_ANON"), this also keeps get_cmdline() away from device mappings with a vm_ops->access handler. Fixes: a90902531a06 ("mm: Create utility function for accessing a tasks commandline value") 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