aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-10-10 03:03:55 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-14 13:07:19 -0400
commitd723a92dd465d549bf79dd481c09d59f0be02936 (patch)
tree70a30da992a8d620b4a2efec65cc94f07906b425
parent785a162d147a547bc7a577c1c28f6fb9dbeb4f16 (diff)
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 <benh@kernel.crashing.org> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/sysfs/file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index c324ee906df0..5d818df7250b 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,
156 struct sysfs_open_file *of = sysfs_of(file); 156 struct sysfs_open_file *of = sysfs_of(file);
157 struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr; 157 struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr;
158 struct kobject *kobj = of->sd->s_parent->s_dir.kobj; 158 struct kobject *kobj = of->sd->s_parent->s_dir.kobj;
159 int size = file_inode(file)->i_size; 159 loff_t size = file_inode(file)->i_size;
160 int count = min_t(size_t, bytes, PAGE_SIZE); 160 int count = min_t(size_t, bytes, PAGE_SIZE);
161 loff_t offs = *off; 161 loff_t offs = *off;
162 char *buf; 162 char *buf;