From d723a92dd465d549bf79dd481c09d59f0be02936 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Thu, 10 Oct 2013 18:03:55 +1100 Subject: 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: Benjamin Herrenschmidt Cc: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index c324ee9..5d818df 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -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; -- cgit v1.1