From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 052F84CDA0E for ; Mon, 5 Oct 2026 15:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791215927; cv=none; b=fugnZKnMkr86yQaT+3oxpb/CHFfLe/amqi/sHEnC2HBrrHvStNo0ble2E4dddQj+iR/X/guv4WPB53ED3Ih+MRxuOddpPej1bK6xNVxVDCVwBGeSzEdAWmaN7l3ck/Ydn0a7gXDroCZohla9/5Mdkt4tIg2I7uvume2WyqWZWAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791215927; c=relaxed/simple; bh=b4IJqXx+udUexVuL32KrcEb1C/aYXq6Fd7NuBJSyaa8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZnJ4FFyR3LSLSBiWRHhh4d8Rn+Fy+XGC2lQ/Lgg36PX5maUJGja9F3/PkJRO067TWOr7GpmakRBi1nI3gwm1ma6SOfegn55fbL4GP0UCOojUcXzVqMhwHSFNEYDtu1E5y+nFipJoYaSYafp5xTEmFwWXiomPmnz5Ti+uRbFYru0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cUbOBe1F; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cUbOBe1F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E01A91F000FF for ; Mon, 5 Oct 2026 15:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791215925; bh=unJVs8XKy/ViJvkyFC1zJx/IWmn39RPVHGP+T8Nd3dY=; h=Date:From:List-Id:To:Cc:Subject:References:In-Reply-To; b=cUbOBe1F1oX438ECD7HKQSO3EGlh1GpB4iBjF6SAKCF+LNcQMTapBMf93Q2PHkF/I yL9xwjxoW4e+2e6oJ75QXNvC8e5pGf0dGMMMBtZyE+NqGf3yGYh1rmtwcF8kZbyTyN zpAuamLJITs+uVfXiDjC1MU9rVAtY36Bbnndew2ERO1iH0zy9mi3se6YMSk39AJgQU UHH8Bcp294Jrdz+ghoATL3FGZkULryHWu5ZX18jl75xCpOwfncU/54aGXF08B8DWib yvIUuSPmv0d6MolclQyowliPvdESPsLv+dxc22LnynqV7LkrfFb8v+q99PC+Ucopmr 2V+MXwF1SkCZA== Date: Mon, 5 Oct 2026 08:58:45 -0700 From: Kees Cook To: Alejandro Colomar Cc: Andy Shevchenko , Bill Wendling , "Matthew Wilcox (Oracle)" , Andrew Morton , David Gow , Petr Mladek , Shuvam Pandey , Steven Rostedt , Jonathan Corbet , Sergey Senozhatsky , =?iso-8859-1?Q?G=FCnther?= Noack , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Masami Hiramatsu , Mathieu Desnoyers , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , "Christophe Leroy (CS GROUP)" , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Shivaprasad G Bhat , Thorsten Blum , Alison Schofield , Dave Jiang , Greg Kroah-Hartman , Guangshuo Li , Ira Weiny , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Vishal Verma , Randy Dunlap , Shuah Khan , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v4 05/11] seq_buf: Add seq_buf_strlen() Message-ID: <20261005155839.d5d200-kees@kernel.org> References: <20261003035906.too.263-kees@kernel.org> <20261003035921.1918874-5-kees@kernel.org> <202610040023.A3865A6@keescook> <20261005112209.1e47fa-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Oct 05, 2026 at 01:34:10PM +0200, Alejandro Colomar wrote: > > Yeah, reasonable. :) For v5 I've added this to seq_buf_str()'s kernel-doc: > > > > * A zero-sized seq_buf has nowhere to put a NUL, so the empty string > > * is returned instead of writing to @s->buffer. Any other seq_buf > > * returns @s->buffer, even when it holds an empty string, so callers > > * always get their own buffer back. > > Are such buffers actually used on purpose anywhere? Why not keep the > WARN_ON? Yes, though not often: the sched_ext debug dump builds a nested per-CPU seq_buf from seq_buf_get_buf(), which returns a size of 0 once the dump buffer has overflowed, and it handles that case on purpose (see the "$s may already have overflowed" comment in kernel/sched/ext/ext.c). Greg asked about the WARN_ON() in v2[1]: a size that comes from a device or from userspace would have to be checked before every seq_buf_init(), or it becomes a crash under panic_on_warn, and an empty buffer can just hold the empty string. So the accessors do that instead. [1] https://lore.kernel.org/all/2026091953-cherub-empty-ef35@gregkh/ -Kees -- Kees Cook