All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: "tiantao (H)" <tiantao6@huawei.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Tian Tao <tiantao6@hisilicon.com>,
	rafael@kernel.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, jonathan.cameron@huawei.com,
	song.bao.hua@hisilicon.com, Randy Dunlap <rdunlap@infradead.org>,
	Stefano Brivio <sbrivio@redhat.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	"Ma, Jianpeng" <jianpeng.ma@intel.com>,
	Yury Norov <yury.norov@gmail.com>,
	Valentin Schneider <valentin.schneider@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Daniel Bristot de Oliveira <bristot@redhat.com>
Subject: Re: [PATCH v3 1/3] lib: bitmap: introduce bitmap_print_to_buf
Date: Thu, 3 Jun 2021 13:37:09 +0200	[thread overview]
Message-ID: <YLi+5dOGIa6bkJoF@kroah.com> (raw)
In-Reply-To: <0a43ca2a-7563-0bd6-fd1f-3fef208d71ef@huawei.com>

On Thu, Jun 03, 2021 at 07:21:30PM +0800, tiantao (H) wrote:
> 
> 在 2021/6/3 18:49, Greg KH 写道:
> > On Thu, Jun 03, 2021 at 06:33:25PM +0800, tiantao (H) wrote:
> > > 在 2021/6/3 17:50, Andy Shevchenko 写道:
> > > > On Thu, Jun 03, 2021 at 05:22:40PM +0800, Tian Tao wrote:
> > > > > New API bitmap_print_to_buf() with bin_attribute to avoid maskp
> > > > > exceeding PAGE_SIZE. bitmap_print_to_pagebuf() is a special case
> > > > > of bitmap_print_to_buf(), so in bitmap_print_to_pagebuf() call
> > > > > bitmap_print_to_buf().
> > > > ...
> > > > 
> > > > >    /**
> > > > > + * bitmap_print_to_buf - convert bitmap to list or hex format ASCII string
> > > > > + * @list: indicates whether the bitmap must be list
> > > > > + * @buf: the kernel space buffer to read to
> > > > > + * @maskp: pointer to bitmap to convert
> > > > > + * @nmaskbits: size of bitmap, in bits
> > > > > + * @off: offset in data buffer below
> > > > > + * @count: the maximum number of bytes to print
> > > > > + *
> > > > > + * The role of bitmap_print_to_buf() and bitmap_print_to_pagebuf() is
> > > > > + * the same, the difference is that buf of bitmap_print_to_buf()
> > > > > + * can be more than one pagesize.
> > > > > + */
> > > > > +int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
> > > > > +			int nmaskbits, loff_t off, size_t count)
> > > > > +{
> > > > > +	const char *fmt = list ? "%*pbl\n" : "%*pb\n";
> > > > > +	ssize_t size;
> > > > > +	void *data;
> > > > > +
> > > > > +	if (off == LLONG_MAX && count == PAGE_SIZE - offset_in_page(buf))
> > > > > +		return scnprintf(buf, count, fmt, nmaskbits, maskp);
> > > > > +
> > > > > +	data = kasprintf(GFP_KERNEL, fmt, nmaskbits, maskp);
> > > > > +	if (!data)
> > > > > +		return -ENOMEM;
> > > > > +
> > > > > +	size = memory_read_from_buffer(buf, count, &off, data, strlen(data) + 1);
> > > > Are you sure you have put parameters in the correct order?
> > > yes, I already test it.
> > Great, can you add the test to the patch series as well so that we can
> > make sure it does not break in the future?
> How do I do this?  Do I need to provide a kselftest ?

That would be wonderful, great idea!

thanks,

greg k-h

  parent reply	other threads:[~2021-06-03 11:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  9:22 [PATCH v3 0/3] use bin_attribute to avoid buff overflow Tian Tao
2021-06-03  9:22 ` [PATCH v3 1/3] lib: bitmap: introduce bitmap_print_to_buf Tian Tao
2021-06-03  9:50   ` Andy Shevchenko
2021-06-03 10:33     ` tiantao (H)
2021-06-03 10:49       ` Greg KH
     [not found]         ` <0a43ca2a-7563-0bd6-fd1f-3fef208d71ef@huawei.com>
2021-06-03 11:37           ` Greg KH [this message]
2021-06-03 11:38             ` Greg KH
2021-06-03 11:11       ` Andy Shevchenko
2021-06-03 12:39         ` Jonathan Cameron
2021-06-03 13:00           ` Andy Shevchenko
2021-06-03  9:22 ` [PATCH v3 2/3] topology: use bin_attribute to avoid buff overflow Tian Tao
2021-06-03  9:22 ` [PATCH v3 3/3] drivers/base/node.c: " Tian Tao
2021-06-03  9:53   ` Andy Shevchenko
2021-06-03 10:31     ` tiantao (H)
2021-06-03 11:09       ` Andy Shevchenko
2021-06-03  9:49 ` [PATCH v3 0/3] " Jonathan Cameron

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=YLi+5dOGIa6bkJoF@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bristot@redhat.com \
    --cc=jianpeng.ma@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=sbrivio@redhat.com \
    --cc=song.bao.hua@hisilicon.com \
    --cc=tiantao6@hisilicon.com \
    --cc=tiantao6@huawei.com \
    --cc=valentin.schneider@arm.com \
    --cc=yury.norov@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.