Re: [PATCH] sysfs: fix off-by-one error in fill_read_buffer

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Tejun Heo <teheo@...>
Cc: <gregkh@...>, <linux-kernel@...>
Date: Monday, November 12, 2007 - 11:50 pm

on 2007-11-12 22:08 Tejun Heo wrote:

OK, I did it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>

---
  fs/sysfs/file.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 27d1785..7f6a8d2 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -119,7 +119,9 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer

  	sysfs_put_active_two(attr_sd);

-	BUG_ON(count > (ssize_t)PAGE_SIZE);
+	/* the code works fine with PAGE_SIZE return but it's likely to
+	   indicate truncated result or overflow in normal use cases. */
+	BUG_ON(count >= (ssize_t)PAGE_SIZE);
  	if (count >= 0) {
  		buffer->needs_read_fill = 0;
  		buffer->count = count;
-- 
1.5.3


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] sysfs: fix off-by-one error in fill_read_buffer, Miao Xie, (Mon Nov 12, 11:50 pm)