Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1537163pxa; Thu, 13 Aug 2020 10:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQstN/szuUn95TwHk4foW1HbjZkitGNKzDwC1HrfpVz2SWT6JBe2uXpz0CGwLj17aNKc8u X-Received: by 2002:a17:907:1191:: with SMTP id uz17mr6089249ejb.184.1597340011779; Thu, 13 Aug 2020 10:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597340011; cv=none; d=google.com; s=arc-20160816; b=ypYzv31vu8igNBAtWow91myYgMoEWivlNGe44aM1hTqO2Rp0VhP9FnMvqsNu9JTRG/ UXOMSzPQdz75F7ZKhe5bkh1XR2B/F8rjWkb0Bx1ofTP1rdnBaCT72Q3sNN6LJBSuVF3H K5eWdm9tSazpqzfVdK7kkNoUcnA2Ftr8+8DFxChchhK5BwJsZ7Z8pBpXzEbETzEHUIUL IVuMM/m9/DD4JNZ+9ky7e6qPHgims/XSvEzrcou03YtVM0eEP0qYL26KibajXnpRNvkq FOM1jDSp7qpBiOwV7W8F8yGQUkmV2s62d8Wxs/PaU9Stp/F/PckXbAy0G2bK26vH2i5X lcEA== 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=PSmgLg2UxH/ZJJGmL16ctyxYmYR/mpHDdHcTnAPh9cw=; b=Jdg+tcxi8zq2/oBjmozzUhjREfFzqykwKoObkyuB+Q7lv2oPTkiMo/SHFs6amNU6WH 6bxTi6j0J+jTT+mcru+e13nhCx0wkyPy9fKFOj2XQjjOQwonuIaJIuPCL8rfGlQiFnFv cRZjPdFhJp71QBhg8ekr9IQb8dr52KCdJACRIHQJ5imkqv+O1AjBJjbPJTr96icQezVg 7aXkp3aISwaON4O8irt85vp6BRzzZzpSZAPimxJ1K145GlfBkqW8FZdP9iC8o3au0OZ1 RDRvspYUJK6gHB21azU8/J47tZPyC+BNbgR0BXJS/SAM0+wsAbGIVBtuselrzpOHT62L d4rg== 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 lr3si3907152ejb.251.2020.08.13.10.33.08; Thu, 13 Aug 2020 10:33:31 -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 S1726632AbgHMRcF (ORCPT + 99 others); Thu, 13 Aug 2020 13:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgHMRcF (ORCPT ); Thu, 13 Aug 2020 13:32:05 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D164C061757; Thu, 13 Aug 2020 10:32:05 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6H51-00F8jY-9s; Thu, 13 Aug 2020 17:31:55 +0000 Date: Thu, 13 Aug 2020 18:31:55 +0100 From: Al Viro To: Josef Bacik Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-team@fb.com, willy@infradead.org Subject: Re: [PATCH][v2] proc: use vmalloc for our kernel buffer Message-ID: <20200813173155.GZ1236603@ZenIV.linux.org.uk> References: <20200813145305.805730-1-josef@toxicpanda.com> <20200813153356.857625-1-josef@toxicpanda.com> <20200813153722.GA13844@lst.de> <974e469e-e73d-6c3e-9167-fad003f1dfb9@toxicpanda.com> <20200813154117.GA14149@lst.de> <20200813162002.GX1236603@ZenIV.linux.org.uk> <9e4d3860-5829-df6f-aad4-44d07c62535b@toxicpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9e4d3860-5829-df6f-aad4-44d07c62535b@toxicpanda.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 13, 2020 at 01:19:18PM -0400, Josef Bacik wrote: > > in sunrpc proc_dodebug() turns into > > left -= snprintf(buffer, left, "0x%04x\n", ^^^^ left + 1, that is. > > *(unsigned int *) table->data); > > and that's not the only example. > > > > We wouldn't even need the extra +1 part, since we're only copying in how > much the user wants anyway, we could just go ahead and convert this to > > left -= snprintf(buffer, left, "0x%04x\n", *(unsigned int *) table->data); > > and be fine, right? Or am I misunderstanding what you're looking for? Thanks, snprintf() always produces a NUL-terminated string. And if you are passing 7 as len, you want 0xf0ad\n to be copied to user. For that you need 8 passed to snprintf, and 8-byte buffer given to it.