提交 d723a92d 编写于 作者: B Benjamin Herrenschmidt 提交者: Greg Kroah-Hartman

sysfs/bin: Fix size handling overflow for bin_attribute

While looking at the code, I noticed that bin_attribute read() and write()
ops copy the inode size into an int for futher comparisons.

Some bin_attributes can be fairly large. For example, pci creates some for
BARs set to the BAR size and giant BARs are around the corner, so this is
going to break something somewhere eventually.

Let's use the right type.

[adjust for seqfile conversions, only needed for bin_read() - gkh]
Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 785a162d
......@@ -156,7 +156,7 @@ static ssize_t sysfs_bin_read(struct file *file, char __user *userbuf,
struct sysfs_open_file *of = sysfs_of(file);
struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr;
struct kobject *kobj = of->sd->s_parent->s_dir.kobj;
int size = file_inode(file)->i_size;
loff_t size = file_inode(file)->i_size;
int count = min_t(size_t, bytes, PAGE_SIZE);
loff_t offs = *off;
char *buf;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册