Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1947392pxj; Sun, 30 May 2021 08:20:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWNxPIJA6q2epmOtV0NKWN9vxkfjuroU7E09883iHYaEYzkOXcDgT0KRmgtXEbDkrLV1wO X-Received: by 2002:a02:ca0d:: with SMTP id i13mr16653392jak.98.1622388043720; Sun, 30 May 2021 08:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622388043; cv=none; d=google.com; s=arc-20160816; b=hiDk5OGsynBC0gzGDCmOlAOXLK4srGE0c7RuStBzO/pKJv+Lcx7golOHTkSd4LuHaP 7KvMGIkCBfdzb2o2nv2i0al1laVvXgNiN/6mmAJfwm/QLeQaUbEJ9BwIy8mSjqmPtCEQ DVThMWLjOWa0Mdex84z9GsYPpF5flHDEgcgGARpUFVM0QH12/kH+qQiFhIHJfSRjTX9K 9DrJpVL+Ac9eFBxBi3SY3iK4ETkCC5xCBjR3rRB5ROUcV9fzydvrDeKo4a5LheWQV5Vp eMG4Y0F5F4a1ZpccTeKr5pBzynJxrM/8C4wRLFBoLNsJo8wfnmsMoioyxAdt4m7ORcv4 zX5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=y3DXZLXagxiVtFwWPQ3/eHYfS2BTxh16gXAXVZkHbvs=; b=zL4ORFtPSghyuQkJ3dhadc+Ou7nm6ITgATnu7HAzDYvSMZjTU5SAO5TaTOVxIOxkFn 1iW1EU/02MIdtpX0wQknza7yHneGJmbhuFU5e29Hf+3bMJQLXOH7u7c7ANihf7EystLd d+qunGfkN4F+uBg6p7iuxJQskfBCJDpvrbvuLKdzjqeBg3FkugQXK+pgZxyoDx2exVaU cH6MrbaTRXpG5exQWiJcE2+idv88w2erJc6HQbOSHDStrIK+Ukq9C83ve3vAfioGh8Ci QFSOSYRwW+dErSCz/JwI1gfd5Q+MHxzADQokO4uT1lAf+Rla3PQaTNjRGpvgWjRYSSwI z/6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ERoCFxV5; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 h6si11717459jaj.29.2021.05.30.08.20.24; Sun, 30 May 2021 08:20:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ERoCFxV5; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbhE3PVI (ORCPT + 99 others); Sun, 30 May 2021 11:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbhE3PVH (ORCPT ); Sun, 30 May 2021 11:21:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 389A4C061574; Sun, 30 May 2021 08:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=y3DXZLXagxiVtFwWPQ3/eHYfS2BTxh16gXAXVZkHbvs=; b=ERoCFxV5SBNYHz1mskauOJriQG y0EBj4Br/zzwvWrtLk3vX22nZllTohRJ5TQZXvvoR/DlZWEdD3+J+aWd0D3MjDgXqjeMomuoREo15 Cfme5ehFNPenJvMiyHyXZhqmVhuziWXecTBPN2yyAErWv0+ZAjvCLEpJ92Ql6y1m+BoQ6Laiocewj hDPS6WoBh9JirO2W57C45f6LVKRUSZVMBQx/E/OIb+lhnSF5lAShLs5xdPXkA101Cn4AzSahmxMsp NXTwIOgJlFR9nzMnOPnnJ3kTwfN5Ap8ZJoaS1yNCQw5RN7dpPBfESQiaB/yYHdk3cdZr0ikeOD0Kl eA1SFVtg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lnNCp-008Dun-I2; Sun, 30 May 2021 15:18:26 +0000 Date: Sun, 30 May 2021 16:18:23 +0100 From: Matthew Wilcox To: Rasmus Villemoes Cc: Justin He , Linus Torvalds , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Jonathan Corbet , Alexander Viro , Luca Coelho , Kalle Valo , "David S. Miller" , Jakub Kicinski , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Johannes Berg , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-s390@vger.kernel.org" Subject: Re: [PATCH RFCv2 2/3] lib/vsprintf.c: make %pD print full path for file Message-ID: References: <20210528113951.6225-1-justin.he@arm.com> <20210528113951.6225-3-justin.he@arm.com> <89fc3919-ca2c-50fd-35e1-33bf3a59b993@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <89fc3919-ca2c-50fd-35e1-33bf3a59b993@rasmusvillemoes.dk> Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, May 28, 2021 at 10:06:37PM +0200, Rasmus Villemoes wrote: > On 28/05/2021 16.22, Justin He wrote: > > > >> From: Matthew Wilcox > > >> How is it "safer"? You already have a buffer passed from the caller. > >> Are you saying that d_path_fast() might overrun a really small buffer > >> but won't overrun a 256 byte buffer? > > No, it won't overrun a 256 byte buf. When the full path size is larger than 256, the p->len is < 0 in prepend_name, and this overrun will be > > dectected in extract_string() with "-ENAMETOOLONG". > > > > Each printk contains 2 vsnprintf. vsnprintf() returns the required size after formatting the string.> > > 1. vprintk_store() will invoke 1st vsnprintf() will 8 bytes space to get the reserve_size. In this case, the _buf_ could be less than _end_ by design. > > 2. Then it invokes 2nd printk_sprint()->vscnprintf()->vsnprintf() to really fill the space. > > Please do not assume that printk is the only user of vsnprintf() or the > only one that would use a given %p extension. > > Also, is it clear that nothing can change underneath you in between two > calls to vsnprintf()? IOW, is it certain that the path will fit upon a > second call using the size returned from the first? No, but that's also true of %s. I think vprintk_store() is foolish to do it this way.