Skip to contentSkip to conversation

vfs: fix overflow in direct-io subsystem

PATCH In review Edward Shishkin 4 participants 4 messages Oct 13, 2010 – Oct 14, 2010 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 vfs: fix overflow in direct-io subsystem

Fix up overflow (ssize_t->int) in the direct-io subsystem.

---
 fs/direct-io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/direct-io.c +1 -1
@@ -218,7 +218,7 @@ static struct page *dio_get_page(struct 
  * filesystems can use it to hold additional state between get_block calls and
  * dio_complete.
  */
-static int dio_complete(struct dio *dio, loff_t offset, int ret, bool is_async)
+static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret, bool is_async)
 {
 	ssize_t transferred = 0;
 
Acked-by on v1 1/2
#2 lore raw
In reply to Edward Shishkin
Quoted 10 lines · Edward Shishkin

Fix up overflow (ssize_t->int) in the direct-io subsystem.

---
 fs/direct-io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

fs/direct-io.c static struct page *dio_get_page(struct · line 223

Quoted 7 lines
fs/direct-io.c +1 -1
@@ -218,7 +218,7 @@ static struct page *dio_get_page(struct 
  * filesystems can use it to hold additional state between get_block calls and
  * dio_complete.
  */
-static int dio_complete(struct dio *dio, loff_t offset, int ret, bool is_async)
+static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret, bool is_async)
 {
 	ssize_t transferred = 0;
#3 lore raw
In reply to Edward Shishkin
Quoted 10 lines · On Wed, 13 Oct 2010 22:45:57 +0200 Edward Shishkin <[email protected]>…

Fix up overflow (ssize_t->int) in the direct-io subsystem.

---
 fs/direct-io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

fs/direct-io.c static struct page *dio_get_page(struct · line 224

Quoted 8 lines
fs/direct-io.c +1 -1
@@ -218,7 +218,7 @@ static struct page *dio_get_page(struct 
  * filesystems can use it to hold additional state between get_block calls and
  * dio_complete.
  */
-static int dio_complete(struct dio *dio, loff_t offset, int ret, bool is_async)
+static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret, bool is_async)
 {
 	ssize_t transferred = 0;
 

I'd call this a truncation error, not an overflow. Semantics.

So what's the runtime effect? The subsystem will go stupid when doing a single transfer of over 2G on a 64-bit machine?

Can this actually happen in practice? Has nobody ever done this before now?

<goes to test it>

<discovers that ubuntu 8.04's dd doesn't support conv=direct>

<stupid thing>