Bug 178084

Summary: Last AIO read of a file opened with O_DIRECT returns wrong length
Product: Red Hat Enterprise Linux 4 Reporter: Jeff Moyer <jmoyer>
Component: kernelAssignee: Jeff Moyer <jmoyer>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0CC: jbaron, rkenna, wijata
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://linux.bkbits.net:8080/linux-2.6/gnupatch@426191005mlv-LPd0wgDxjYB2GSh3g
Whiteboard:
Fixed In Version: RHSA-2006-0575 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-08-10 21:52:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 181409    
Attachments:
Description Flags
reproducer
none
Fix the return value for the last read of a file that is not a multple of block size none

Description Jeff Moyer 2006-01-17 19:08:39 UTC
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 Jeff Moyer 2006-01-17 19:08:42 UTC
Created attachment 123323 [details]
reproducer

Comment 2 Jeff Moyer 2006-01-17 19:21:04 UTC
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 20:06:35 UTC
hmmm...changing the dio structure is likely a kabi issue.

Comment 4 Jeff Moyer 2006-01-17 20:15:35 UTC
How so?  The structure definition is private to fs/direct-io.c.

Comment 5 Jason Baron 2006-01-17 20:19:25 UTC
ok. you're right. i retract my comment 

Comment 8 Jason Baron 2006-03-22 14:57:59 UTC
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 07:31:54 UTC
Is there any schedule on releasing kernel with this bugfix?


Comment 12 Jeff Moyer 2006-05-26 13:23:07 UTC
It will be available in update 4.

Comment 13 Rafal Wijata 2006-05-30 07:34:31 UTC
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 21:52:57 UTC
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