Bug 1078894 - readahead does not return error on pipes and sockets
Summary: readahead does not return error on pipes and sockets
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 20
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1081759
TreeView+ depends on / blocked
 
Reported: 2014-03-20 13:55 UTC by Jeff Bastian
Modified: 2014-03-28 03:17 UTC (History)
6 users (show)

Fixed In Version: kernel-3.13.7-100.fc19
Clone Of:
: 1081759 (view as bug list)
Environment:
Last Closed: 2014-03-28 03:15:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
readahead test program (1.03 KB, text/plain)
2014-03-20 13:55 UTC, Jeff Bastian
no flags Details

Description Jeff Bastian 2014-03-20 13:55:46 UTC
Created attachment 876851 [details]
readahead test program

Description of problem:
The LTP (Linux Test Project) readahead01.c test tries the readahead syscall on a pipe and a socket and it succeeds.  It should fail and return EINVAL because it does not make sense to read ahead on a stream like a pipe or socket.

I've extracted the readahead test from LTP into a standalone program and here's how it fails on Fedora 20:

~]# uname -r
3.13.6-200.fc20.x86_64

~]# strace -e trace=readahead ./a.out
test_invalid_fd pipe:
readahead(3, 0, 4096)                   = 0
  failure: readahead returned 0
  failure: errno is 0
test_invalid_fd socket:
readahead(3, 0, 4096)                   = 0
  failure: readahead returned 0
  failure: errno is 0


It works correctly on a 3.10.0 kernel:

~]# strace -e trace=readahead ./a.out
test_invalid_fd pipe:
readahead(3, 0, 4096)                   = -1 EINVAL (Invalid argument)
  success: readahead returned -1
  success: errno is 22
test_invalid_fd socket:
readahead(3, 0, 4096)                   = -1 EINVAL (Invalid argument)
  success: readahead returned -1
  success: errno is 22


Version-Release number of selected component (if applicable):
kernel-3.13.6-200.fc20.x86_64

How reproducible:
every time

Steps to Reproduce:
1. gcc readahead-pipe-socket.c     (see attached)
2. ./a.out

Actual results:
readahead returns success on pipes and sockets

Expected results:
readahead returns EINVAL on pipes and sockets

Additional info:

Comment 1 Jeff Bastian 2014-03-20 13:59:21 UTC
It looks like a recent commit broke this and it was reported on LKML, but not fixed yet:

https://lkml.org/lkml/2013/12/19/906
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=63d0f0a3c7e1

Comment 2 Josh Boyer 2014-03-20 16:31:47 UTC
OK, I believe this is fixed by:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=58d5640ebdb273cc

Probably should have been CC'd to stable.  I'll get that going.

Comment 3 Josh Boyer 2014-03-20 17:40:14 UTC
Fixed in git.  Picked up for 3.13.7 stable too.

Comment 4 Fedora Update System 2014-03-25 02:45:50 UTC
kernel-3.13.7-200.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/kernel-3.13.7-200.fc20

Comment 5 Fedora Update System 2014-03-25 02:46:43 UTC
kernel-3.13.7-100.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/kernel-3.13.7-100.fc19

Comment 6 Fedora Update System 2014-03-26 05:29:45 UTC
Package kernel-3.13.7-200.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing kernel-3.13.7-200.fc20'
as soon as you are able to, then reboot.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-4317/kernel-3.13.7-200.fc20
then log in and leave karma (feedback).

Comment 7 Jeff Bastian 2014-03-27 12:23:34 UTC
It works! Thanks!

~]$ uname -r
3.13.7-200.fc20.x86_64

~]$ ./readahead
test_invalid_fd pipe:
  success: readahead returned -1
  success: errno is 22
test_invalid_fd socket:
  success: readahead returned -1
  success: errno is 22

Comment 8 Fedora Update System 2014-03-28 03:15:26 UTC
kernel-3.13.7-200.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2014-03-28 03:17:30 UTC
kernel-3.13.7-100.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


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