Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>,
	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
Date: Thu, 13 Aug 2020 13:36:09 -0400	[thread overview]
Message-ID: <34b2d8f2-d10a-a9fd-3b5e-470cb8c4251d@toxicpanda.com> (raw)
In-Reply-To: <20200813173155.GZ1236603@ZenIV.linux.org.uk>

On 8/13/20 1:31 PM, Al Viro wrote:
> 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.
> 

Right, gotcha.  I'll rig that up and see how it looks.  I'd recommend looking 
through what I do with a fine tooth comb, I'm obviously not batting 1000 today. 
Thanks,

Josef

  reply	other threads:[~2020-08-13 17:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 14:53 [PATCH] " Josef Bacik
2020-08-13 14:59 ` Matthew Wilcox
2020-08-13 15:08   ` Josef Bacik
2020-08-13 15:33 ` [PATCH][v2] " Josef Bacik
2020-08-13 15:37   ` Christoph Hellwig
2020-08-13 15:40     ` Josef Bacik
2020-08-13 15:41       ` Christoph Hellwig
2020-08-13 16:20         ` Al Viro
2020-08-13 17:19           ` Josef Bacik
2020-08-13 17:31             ` Al Viro
2020-08-13 17:36               ` Josef Bacik [this message]
2020-08-13 21:10             ` David Laight
2020-08-13 21:31               ` Josef Bacik
2020-08-13 16:19 ` [PATCH] " David Laight
2020-08-13 16:21   ` Al Viro
2020-08-13 17:08   ` Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34b2d8f2-d10a-a9fd-3b5e-470cb8c4251d@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=hch@lst.de \
    --cc=kernel-team@fb.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH][v2] proc: use vmalloc for our kernel buffer' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).