Article View: linux.kernel.netdev
Article #11115[PATCH v2 13/51] sched/psi: don't drop the last byte of a trigger write
From: Christian Brauner
Date: Wed, 04 Nov 2026 17:46
Date: Wed, 04 Nov 2026 17:46
39 lines
11358 bytes
11358 bytes
psi_write() copies at most 32 bytes of the write into its buffer and
terminates the buffer by overwriting its last byte. For a write shorter
than 32 bytes that is the last byte the writer sent. A trigger written
without a trailing newline loses its last digit then, "some 150000
1000000" turns into "some 150000 100000", and a shorter one like
"some 150 10000" fails with -EINVAL because the window doesn't fit
anymore. Only writes that end in a newline parse as intended.
Copy at most 31 bytes and terminate behind them.
Fixes: 0e94682b73bf ("psi: introduce psi monitor")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
kernel/sched/psi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 7c5381423334..8b59635e95d4 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -1566,11 +1566,11 @@ static ssize_t psi_write(struct file *file, const char __user *user_buf,
if (!nbytes)
return -EINVAL;
- buf_size = min(nbytes, sizeof(buf));
+ buf_size = min(nbytes, sizeof(buf) - 1);
if (copy_from_user(buf, user_buf, buf_size))
return -EFAULT;
- buf[buf_size - 1] = '\0';
+ buf[buf_size] = '\0';
seq = file->private_data;
--
2.53.0
Technical Details
Message-ID:
<20261104-work-procfs-bugfixes-v2-13-bbf7d5546809@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356645-linux-kernel-netdev=dewy.ruReferences:
<20261104-work-procfs-bugfixes-v2-0-bbf7d5546809@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356645-linux-kernel-netdev=dewy.ru From: brauner@kernel.org (Christian Brauner) Newsgroups: linux.kernel.netdev Subject: [PATCH v2 13/51] sched/psi: don't drop the last byte of a trigger write Date: Wed, 4 Nov 2026 18:46:59 +0100 Organization: Usenet Network Message-ID: <20261104-work-procfs-bugfixes-v2-13-bbf7d5546809@kernel.org> References: <20261104-work-procfs-bugfixes-v2-0-bbf7d5546809@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3445169"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:xsU39eTJY6GU1TLSZ4KVgDVT8hc= sha256:S7qgVtIndylZS54+0p4yJ+Gr8gcWAjEOzZYNspxqt0A= sha1:mMosa+sfJTwQuqdL4306tO/dY0c= sha256:zqWWU/INy4PjS7EcgPVmKPbRRjQq8g4pZtrebWRNgxs= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 8DBE8112628; Wed, 4 Nov 2026 20:52:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.301 X-Spam-Status: No, score=-2.301 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u6qNvoMwsgUV; Wed, 4 Nov 2026 20:52:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356645-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 34D49112CB2; Wed, 4 Nov 2026 20:51:53 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 6973437F83; Wed, 4 Nov 2026 17:48:13 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793814489; b=HoobXVWqGL7eTN6bO+r+XtZ38K8W4T438pOvfa1OHBkszIv5qjwkOsxCkRQom9pFB6tg tUplR8hTjSyia1oRrdu+q5suoP7QgemgJRG0Ga8eGvdIEUE73IiTQdGyBzmVSU9y0FRRN mWdAOGMmvnM1ZOqEHIejh84E8en+oC93TqSeachqnhODggQ0ta4FhisZDkKU8rRzIkNGP PvVKKBWwj/sIuKUyFFsb5uQgzI+ltPCS7kEC2yEcsXMhFPN1bDNyuvGFxpj/ojoTjkI2q Vmk1u+UoAtCeYhU9go/iAFIzPMAjsy1EweAjaDEoHRmJEJp89UnIOxoc2kMhWxcOklA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793814489; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:In-Reply-To:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:X-Mailer:X-Developer-Signature: X-Developer-Key:Content-Transfer-Encoding; bh=+QMuJvtMuQ+CXnn6xLeWoxU7H9VJY0mzKEyTXi76/+M=; b=JZ22sohPeH2+XGifs9s6jvQ9t9xha2lSXgGmc+hfSo+FATBhUJyrJDhjWeUcFwktfbaO owGiZnYkIHRDUSlVTEpnwSTG9ojDGglqn2jQTRtoer8li+U6ak0lFVTRYbZxnUvdrUgKN +op4Bs68uQPGQ3noopCFNDlvERKMP0MQg4B9lXJ770DS5Gw6LbV44YLoFbxRMqrnDrY6O FBQhBkT4m/JdHeFOcZnY1mDNsGPhSA/6iU1r0hGjSFqnG698UYFskrKIZOUBYMZSTUcGm NrCPnEt0/RAejkkZg29Cxox7KX01WUObgUmhsYoD4j9eKR0SA9RtOT9sIJwkEgKmyVg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DVG35mDd; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F429606D82A; Wed, 4 Nov 2026 17:48:09 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DVG35mDd X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793814488; b=c7cHNwmaXjlJlojtvVBXY5mMWCLkrpSKIrZDhcat1tbrKgLV1wKqZFPLwUzfLvyGFZwY QDhJsMVJzaTPBog8qOBsEE4hnQRfaV3n16Fb8QCfQlZ7+nFty1oLYYDMe50TX9UYBRKQT ibNwIC26XrSO/LORMWfo+dpd7mwA/tySO/ExO3o+JUPuxpqpk9MjDMH95iwqA/HhrJtSZ dyqxbwn8HqBVP3UHeEH+fmL7HuHB4I2mhUyfiIoFMyJbSkZsQSSkT7ErzLLh5OjWC1Fa0 NWO08OxIyj1ebrGMwY8+w8Ma/V1OYp7Lg/NDbua87J/Hp0gVWO6LyvjeJ43NPYoTyjA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793814488; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: In-Reply-To:References:MIME-Version:Content-Type:X-Mailer: X-Developer-Signature:X-Developer-Key:Content-Transfer-Encoding; bh=+QMuJvtMuQ+CXnn6xLeWoxU7H9VJY0mzKEyTXi76/+M=; b=s4jk7OESovVO/5e90NI+zzQ3NqhtLIhsJqzRszvhHQPbcm5d8E0lUQVDnnufzwPAiDIS avkwQNq8hqjcBDiJG4stPXxwZGOmWH1QcdTNmXiQhhu33RbxRBGm/57XhfyHfN6B7HrFp CYaeJ+JCTdLVPcG5SZiDR98P0USRPXROykZ01q2j6x8cVyhc7S9V79UBv6n/vJfBDboej fafTvUWDa66Nf+759eIa1TsJ3DL6hELgXxSZyVHDAW61/pijfzkqRu7dzvndeFizTUl94 fUx70AD2SO82tVa1yXVo1WfqETo8dqqinqJOZldkNAlP++V892YVxt9pU9zlqyy/X5Q== X-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=DVG35mDd; arc=none smtp.remote-ip=100.103.45.18 X-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 EE995606A31B; Wed, 4 Nov 2026 17:48:07 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E9FB1F00919; Wed, 4 Nov 2026 17:47:49 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793814487; bh=+QMuJvtMuQ+CXnn6xLeWoxU7H9VJY0mzKEyTXi76/+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DVG35mDdrJ+w70lYp9CqgpxTuoGTpj4temyLsY3vuBl9elVVBnmHrviotaVGY/ppP UdOgypZXpDWtJ7enRd3iIIX4vWx3xyqPaHPzOZWq/P4JUJrwgIpI4MwtSTSz/6po8R Yvz02Y/vDREj2xNfVXWxFSvrw7Bvuiwjqz0knxKP5rsjzaWDW5qaKyJ9F3yEnh+EWh A3TtW5nyoi8NpYae3YAaKFmJ3QPX5Rij2cVvQ/1JMiWehFHBZSo4em6YfVuXhfiqDi JqHLo3hhdvujnwykhoFrIyHzHBnGpPwJgUwVLui5mJv4lfTVDRPXKF7pOVu2XHYste DuNdex110TFZw== X-Cc: Linus Torvalds <torvalds@linux-foundation.org>, Jann Horn <jannh@google.com>, Josef Bacik <josef@toxicpanda.com>, Chris Mason <mason@kernel.org>, Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>, Eric Dumazet <edumazet@kernel.org>, Thomas Gleixner <tglx@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>, Jonathan Corbet <corbet@lwn.net>, Christoph Hellwig <hch@lst.de>, Greg Kroah-Hartman <gregkh@suse.de>, Joel Granados <joel.granados@kernel.org>, Kees Cook <kees@kernel.org>, Jan Kara <jack@suse.cz>, Jan Kara <jack@suse.com>, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-um@lists.infradead.org, linux-wireless@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, ntfs3@lists.linux.dev, platform-driver-x86@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, linux-sound@vger.kernel.org, netfilter-devel@vger.kernel.org, dri-devel@lists.freedesktop.org, ibm-acpi-devel@lists.sourceforge.net, jfs-discussion@lists.sourceforge.net, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cifs@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linux-usb@vger.kernel.org, samba-technical@lists.samba.org, sparclinux@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-doc@vger.kernel.org, linux-serial@vger.kernel.org, linux-atm-general@lists.sourceforge.net, Takashi Iwai <tiwai@suse.de>, linux-input@vger.kernel.org, linux-raid@vger.kernel.org, linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org, linux-debuggers@vger.kernel.org, "Christian Brauner (Amutable)" <brauner@kernel.org>, Chuck Lever <cel@kernel.org>, stable@vger.kernel.org X-In-Reply-To: <20261104-work-procfs-bugfixes-v2-0-bbf7d5546809@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1310; i=brauner@kernel.org; h=from:subject:message-id; bh=/5ST8groFWC3ZYrB9+5K2L5OtN8hrslkTr6MpvXzbng=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS9zjv/59LFdb+4Nqzr+cU3P2cS7+L2yauySvlfWb8/9 eufsCjT0o5SFgYxLgZZMUUWh3aTcLnlPBWbjTI1YOawMoEMYeDiFICJmJkw/FM9sG/u0ochUvwi r25NnfqcY/Wv3m+1Rk6yc5TfvmHn3j+V4X8gx3Wx2Wp7OP7b/lW+zLTMQ+Qde1X2zk2aTqESmTX LCxkA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624