From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A8C73783C0 for ; Mon, 11 May 2026 13:26:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778506013; cv=none; b=MZR/HmbODJ/ojNeAjM/Z/OhOkaaZHcVHTVyluk3JDSH0pub5t+JEeUP4wVsErn2LOGReTt43LcPQacY5Yd/PO9yir2roIATc6Cxidvch0miU5r5h/rA5di1ChJLefNfS3cL6v8nPf2IPedhAGuL+TO0I6VauSjt1L/pq8MZo1RI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778506013; c=relaxed/simple; bh=z1hwDVt92XOAnihS7s6RxQLFhGGvzqHcP+pj4GoLieI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pM7Sf6TRQ5phXs1Tqg1zPQCEyk5S616AXoyl/w2YZDBBvyZPzbulIEgWoTk+FVd2we3fuZ0DoQojIOZ6J9I4GXyg4W32WI2KjDsPXqI6/8UGbE+9TcByLupLBejb+89x+iJiHyp9k/S6QCzQ3BxubvNS8bkOkaVkN/74GfliOxM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U9xQ3b8d; arc=none smtp.client-ip=209.85.128.44 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.b="U9xQ3b8d" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4891b0786beso28348125e9.1 for ; Mon, 11 May 2026 06:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778506011; x=1779110811; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=2mzrS4VJwJCC0yKNEXMEo8xy6/BimLXjTtOtcr2CuV4=; b=U9xQ3b8dehb4HpbBamWXYPXXriLPmK0wxf9ygRRaBUbwoP7HwrvB665GfnY+gbFkY7 bZTjeT4cQiz+8rN3lcosfc5JrqznAOytUemSR6eatB1VSMnnP35rwYxX6qgZAac0JNok stjFTTK8K56xhLmJBiNjtbdgWgfP17mF0bgi4+Lhpg6JGODIVL22kmwXje+Y/yhavl+M 85PoO18U7hupM1SS3EYvG0vXl4s+IpBSVHj7pdL6n7tzgKLr/OM6ZzWMhPSZQjQkNgRf lBO5Rvip4sp6UQGmp4Qk2fmpb6mTAeMa4nfSNlxGAipe1kBSDhe52aE4qvA9X1gxYCY5 7LEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778506011; x=1779110811; h=content-transfer-encoding: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; bh=2mzrS4VJwJCC0yKNEXMEo8xy6/BimLXjTtOtcr2CuV4=; b=AnUB6cSFyThJlEAr5ii/3QE33Ey2RtVBJl6C0AuNTIJo8Dq+754p9RuiCK/CdzKHH4 81qDTFZAnN4M2nf85Q+IuAJB4L1psbirg4RjjWmErAbi7hS7VMwt8E4QQlGDbFyaIZnm osxzcPR6W3RQjXjZk1j10wJfYTdMgOOWhvA6sXpYep/882QTM1jRynkn9UvJSmj7MVnk BkIzk0RUYOePi0BZ20bJh+bkyep3wU1aGOxDAeYrqgnitA3aLDyomH6dZrxR/hZbZ7Cm JUTp5EiVAY+i/dZHEYTlUJUyfJkMrijlkmN6b6XZi9qw5TbcZW266qBglNLqieCqJ2f9 bOMg== X-Forwarded-Encrypted: i=1; AFNElJ+DQz6K8XowNvPiVPEq2zP35L0B4Di4Bkepm5VkIo2VjYjjzd30klWQsAMChlxq9vQml3mU/EJ63E+Zrx8=@vger.kernel.org X-Gm-Message-State: AOJu0YwuftClpdbwUep+YaCDQQHDJm+wI7S0T/G1eXPWSq+JFRN09ENF 8LNu2qQX6L+W6QDoI23lfrnWKdF6eVS/8aVuUKgkqw+fxvq4t2fmefi/ X-Gm-Gg: Acq92OG5e0gM4Gvgzki/Tfu811853bC6no4cWhoITDUcIltp0XTEy64Is7oxbAMe1kd E0USIwm0opb1yiNRh4SjzXgeWNxD0/awudximLB8ticuLYXm4S/LSJghdCRKxvXjhB9Y/vdCuS9 HfMk4qefPwFi7xMqjSWNXHNkG5YvmC2y1+tGnReeJ2qhK+nTs0ofrSDZRFSuIonr5DryTq6Pt4I gqs1BX3x26aTWg3ezyV3z9ix+TtIElGmCXzScf04+xyE4e2l4y3xdRuifh0OvSbkHKp3dXS3PcX eLvQUnJI0XrecsraUpAkXI+uEmu4mKIWYfhUsFKmfNdqQsgGv2j82x5DiTFZZ6REaO4GSAwanOl ivlYDXIMr363+Zi7MwrE2OeDlwqKzsesPKvH8sLLAy0h/C6hJdKfvn5QZoepnoTEnPO2l2N/Fon fCxlbLeE3UsTHsbvUo/JKQUpnBEbwNFfK4OngleniPlcNth9AsC34YnPAiVhvM X-Received: by 2002:a05:600c:c094:b0:488:b14f:b8ed with SMTP id 5b1f17b1804b1-48e51dd89ffmr280640045e9.0.1778506010795; Mon, 11 May 2026 06:26:50 -0700 (PDT) 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-48e6f9fbf12sm200982065e9.0.2026.05.11.06.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 06:26:50 -0700 (PDT) Date: Mon, 11 May 2026 14:26:49 +0100 From: David Laight To: Geert Uytterhoeven Cc: Manuel Ebner , andy.shevchenko@gmail.com, apw@canonical.com, corbet@lwn.net, dwaipayanray1@gmail.com, joe@perches.com, kees@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com, skhan@linuxfoundation.org, workflows@vger.kernel.org Subject: Re: [PATCH 1/2] [PATCH 1/2] Doc: deprecated.rst: add strlcat() Message-ID: <20260511142649.463c3ea5@pumpkin> In-Reply-To: References: <20260510164907.57176-2-manuelebner@mailbox.org> <20260510165159.57457-2-manuelebner@mailbox.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 11 May 2026 13:40:55 +0200 Geert Uytterhoeven wrote: > Hi Manuel, > > On Sun, 10 May 2026 at 18:52, Manuel Ebner wrote: > > add strlcat and alternatives > > Thanks for your patch! > > > --- a/Documentation/process/deprecated.rst > > +++ b/Documentation/process/deprecated.rst > > @@ -162,6 +162,12 @@ if a source string is not NUL-terminated. The safe replacement is strscpy(), > > though care must be given to any cases where the return value of strlcpy() > > is used, since strscpy() will return negative errno values when it truncates. > > > > +strlcat() > > +--------- > > +strlcat() must re-scan the destination string from the beginning on each > > +call (O(n^2) behavior). Alternatives are seq_buf_puts(), seq_buf_printf(), > > +snprintf() and scnprintf() > > The last two not only require the caller to keep track of the offset > in the buffer, but also using "%s" when storing passed strings. Which also means they are significantly slower. Mind you, some code has: strlcat(buf, "\n", SIZE); return strlen(buf); which carefully scans the string twice. Since the '\0' isn't always needed (eg 'show' functions), this can be: len = strlen(buf); buf[len] ='\n'; return len + 1; Of course, the code could often easily get the length by other means. -- David > > I hope we won't see mindless conversions lacking the "%s", > introducing new security issues: > > -strlcat(buf, s, size); > +scnprintf(buf + off, size - off, s); > > > + > > %p format specifier > > ------------------- > > Traditionally, using "%p" in format strings would lead to regular address > > Gr{oetje,eeting}s, > > Geert >