mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tiantao (H)" <tiantao6@huawei.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Tian Tao <tiantao6@hisilicon.com>
Cc: <gregkh@linuxfoundation.org>, <rafael@kernel.org>,
	<akpm@linux-foundation.org>, <linux-kernel@vger.kernel.org>,
	<jonathan.cameron@huawei.com>, <song.bao.hua@hisilicon.com>
Subject: Re: [PATCH v3 3/3] drivers/base/node.c: use bin_attribute to avoid buff overflow
Date: Thu, 3 Jun 2021 18:31:57 +0800	[thread overview]
Message-ID: <be871547-5fbc-e273-a8ae-97defe75b85c@huawei.com> (raw)
In-Reply-To: <YLimj+KPaQ2P/cnl@smile.fi.intel.com>


在 2021/6/3 17:53, Andy Shevchenko 写道:
> On Thu, Jun 03, 2021 at 05:22:42PM +0800, Tian Tao wrote:
>> Reading sys/devices/system/cpu/cpuX/nodeX/ returns cpumap and cpulist.
>> However, the size of this file is limited to PAGE_SIZE because of the
>> limitation for sysfs attribute. so we use bin_attribute instead of
>> attribute to avoid NR_CPUS too big to cause buff overflow.
> ...
>
>>   }
>>   
>> -static DEVICE_ATTR_RO(cpumap);
>>   
>> -static inline ssize_t cpulist_show(struct device *dev,
>> -				   struct device_attribute *attr,
>> -				   char *buf)
>> +static BIN_ATTR_RO(cpumap, 0);
> So, you will have 2 blank lines in a row after this. Why one is not enough?
> Same question for other similar cases, if any.

  I can delete the line 55. this is the only problem, are there any 
other problems?

47 static inline ssize_t cpumap_read(struct file *file, struct kobject 
*kobj,

   48                                   struct bin_attribute *attr, char 
*buf,
   49                                   loff_t off, size_t count)
   50 {
   51         struct device *dev = kobj_to_dev(kobj);
   52
   53         return node_read_cpumap(dev, false, buf, off, count);
   54 }
   55
   56
   57 static BIN_ATTR_RO(cpumap, 0);
   58
   59 static inline ssize_t cpulist_read(struct file *file, struct 
kobject *kobj,
   60                                    struct bin_attribute *attr, 
char *buf,
   61                                    loff_t off, size_t count)
   62 {
   63         struct device *dev = kobj_to_dev(kobj);
   64
   65         return node_read_cpumap(dev, true, buf, off, count);
   66 }
   67
   68 static BIN_ATTR_RO(cpulist, 0);

>


  reply	other threads:[~2021-06-03 10:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  9:22 [PATCH v3 0/3] " 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
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) [this message]
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=be871547-5fbc-e273-a8ae-97defe75b85c@huawei.com \
    --to=tiantao6@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=song.bao.hua@hisilicon.com \
    --cc=tiantao6@hisilicon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®