Bug 178084 - Last AIO read of a file opened with O_DIRECT returns wrong length
Last AIO read of a file opened with O_DIRECT returns wrong length
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeffrey Moyer
Brian Brock
http://linux.bkbits.net:8080/linux-2....
:
Depends On:
Blocks: 181409
  Show dependency treegraph
 
Reported: 2006-01-17 14:08 EST by Jeffrey Moyer
Modified: 2007-11-30 17:07 EST (History)
3 users (show)

See Also:
Fixed In Version: RHSA-2006-0575
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-08-10 17:52:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
reproducer (1.34 KB, text/x-csrc)
2006-01-17 14:08 EST, Jeffrey Moyer
no flags Details
Fix the return value for the last read of a file that is not a multple of block size (1.58 KB, patch)
2006-01-17 14:21 EST, Jeffrey Moyer
no flags Details | Diff

  None (edit)
Description Jeffrey Moyer 2006-01-17 14:08:39 EST
Description of problem:

When issuing AIO reads to a file opened with O_DIRECT, the "bytes read" returned
for the last block in the file is wrong.  If the user specified a 4k read, and
the file only has 300 bytes left, the kernel will return that it read 4k!

Version-Release number of selected component (if applicable):
kernel-2.6.9-27.EL

How reproducible:
100%

Steps to Reproduce:
Build the attached file like so:

gcc -o dioeof dioeof.c -laio

Then, create a file name a.txt with dd:

dd if=/dev/zero of=a.txt bs=300 count=1

Take note of the blocksize and count, here.  Now, run the program in the same
directory as a.txt.

Actual results:
./dioeof
ret = 300
ret = 4096

Expected results:
ret = 300
ret = 300

Additional info:
Comment 1 Jeffrey Moyer 2006-01-17 14:08:42 EST
Created attachment 123323 [details]
reproducer
Comment 2 Jeffrey Moyer 2006-01-17 14:21:04 EST
Created attachment 123326 [details]
Fix the return value for the last read of a file that is not a multple of block size

this patch is currently untested.
Comment 3 Jason Baron 2006-01-17 15:06:35 EST
hmmm...changing the dio structure is likely a kabi issue.
Comment 4 Jeffrey Moyer 2006-01-17 15:15:35 EST
How so?  The structure definition is private to fs/direct-io.c.
Comment 5 Jason Baron 2006-01-17 15:19:25 EST
ok. you're right. i retract my comment 
Comment 8 Jason Baron 2006-03-22 09:57:59 EST
committed in stream U4 build 34.6. A test kernel with this patch is available
from http://people.redhat.com/~jbaron/rhel4/
Comment 11 Rafal Wijata 2006-05-26 03:31:54 EDT
Is there any schedule on releasing kernel with this bugfix?
Comment 12 Jeffrey Moyer 2006-05-26 09:23:07 EDT
It will be available in update 4.
Comment 13 Rafal Wijata 2006-05-30 03:34:31 EDT
I'm really suprised, that this patch was not included in
https://rhn.redhat.com/errata/RHSA-2006-0493.html
I do consider this a security issue, as use is allowed to read data, which He
has not wrote itself. For eg. what would happen if that filesystem clusted was
previously used for /etc/shadow?

Anyway - where can I find some schedule for RH releases (so I can know when it
could be released)?
Comment 15 Red Hat Bugzilla 2006-08-10 17:52:57 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2006-0575.html

Note You need to log in before you can comment on or make changes to this bug.