Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1368382pxj; Fri, 21 May 2021 12:26:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUIiCs602HBvw4WQc2oWS7buuUr1h0vCx66Ptn3+cgj3e2jy/JkSRgyJIYzxGgx2RiszeX X-Received: by 2002:a17:906:4a81:: with SMTP id x1mr11518482eju.508.1621625182609; Fri, 21 May 2021 12:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621625182; cv=none; d=google.com; s=arc-20160816; b=e9urSOci2GZJA3G4JXn3HqX2Cgi3kaxQtucm9+iT5WL/VBrz3rOrDl6TAjVm0KeRJ0 kPh/y9zZtfqR7RIC2CLM+B2ljUPil81nWx3NfVxEsLmiSd0ajmwEhQql1t2OsJa9+KIP q1JGTPyBA82TzKSrX6SJPVJnQY4rE54YwlUNbYPMbslYyKWAO721T36KyqsH3NmKodS5 m50uYUYWzTlwN89hwRP5WH51hjCxYmFWe/vb2iOYzs2u+P1z7APSCdmpuQu5QLXU1xXw 4slCNrlAs3PgfzRqB9gzcIarrM07leCwnRWQhfdlLpd2ti6lgqvujI7+MWehS46v5733 G+/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=sQ6q5bpD39OO8dVOrRfEwWOIF9kvrl2cExcsZTVAoMM=; b=rKNAiHynBRuCEa3DfFtXAW2bjC55cvfugfb4WBYo5HUwH8bW22NHKbzuV5cNlHeAsf g6CPaf1Jab+DJH/4CZXffXpwhsPFnFlCQ2XKKwVGwg0G97NvxmmG4ZyIEybV9nO+1MNw L/s8/B49WE5Jtfq+BhG02x7Hq8sUaX9QjHb4uaoL8FqBLccosQ+x+M6w3maSp3Cv3GWu QcXyevLqVwxImJU3xZ3OQ6VLoN+aOBnWxM2+nnVimc77Q0XPiaz372a7DWTPyAawH8qE zD3dNLcttH+SuEHpM/EwqZ2rcltgfhXRyfUTlXExnlj8oehVw6Le0IyjQsw+fkI4ffGd nnQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y65si6597331ede.79.2021.05.21.12.25.59; Fri, 21 May 2021 12:26:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238711AbhETTiU (ORCPT + 99 others); Thu, 20 May 2021 15:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233380AbhETTiT (ORCPT ); Thu, 20 May 2021 15:38:19 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3C7C061574; Thu, 20 May 2021 12:36:57 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljoRy-00Gve2-KS; Thu, 20 May 2021 19:35:18 +0000 Date: Thu, 20 May 2021 19:35:18 +0000 From: Al Viro To: Petr Mladek Cc: Justin He , Linus Torvalds , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Jonathan Corbet , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , "Eric W . Biederman" , "Darrick J. Wong" , "Peter Zijlstra (Intel)" , Ira Weiny , Eric Biggers , "Ahmed S. Darwish" , "open list:DOCUMENTATION" , Linux Kernel Mailing List , linux-s390 , linux-fsdevel Subject: Re: [PATCH 08/14] d_path: make prepend_name() boolean Message-ID: References: <20210519004901.3829541-1-viro@zeniv.linux.org.uk> <20210519004901.3829541-8-viro@zeniv.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 20, 2021 at 04:53:38PM +0200, Petr Mladek wrote: > That said. vsnprintf() returns the number of characters which would > be generated for the given input. But only the "size" is written. > This require copying the characters one by one. Not really - that's more of avoiding trouble if the sucker gets renamed right under prepend_name(). Note that we have no way to guarantee that length and string pointer come from the same moment. This looking for NUL is about protection againts stepping off the end of allocated object.