Bug 732305

Summary: ioctl on invalid I_ATMARK is not POSIX compliant anymore
Product: [Fedora] Fedora Reporter: Vittorio <vitti570>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 15CC: aquini, gansalmon, itamar, jonathan, kernel-maint, madhu.chinakonda
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-30 12:55:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Vittorio 2011-08-21 19:55:39 UTC
Description of problem:
I just installed kernel-2.6.40.3-0.fc15.x86_64.rpm
and I found that ioctl on an invalid I_ATMARK now sets errno to ENOTTY.
This is not POSIX compliant, man 3 ioctl says that EINVAL (Invalid argument) 
should be put in errno if the I_ATMARK command fails.
Instead now ENOTTY (Inappropriate ioctl for device) is given as errno.

Version-Release number of selected component (if applicable):


How reproducible:
#include <stdio.h>
#include <linux/sockios.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <errno.h>
int main()
{
int n, s, optval;
s=socket(PF_INET,SOCK_DGRAM,0);
if( s == -1 ) perror("errno from socket:");
n=ioctl(s,SIOCATMARK,&optval);
perror("errno from ioctl");
if( errno != EINVAL) printf("n=%d errno=%d\n",n,errno);
return 0;
}


Steps to Reproduce:
1. Compile
2. Run
3.
  
Actual results:
Inappropriate ioctl for device

Expected results:
Invalid argument (EINVAL)

Additional info:

Comment 1 Vittorio 2011-08-21 19:58:21 UTC
Until 2.6.38.8-35 ioctl gave the correct errno. 
This is running sockioctl01 from ltp-full-20110606.

Comment 2 Josh Boyer 2011-08-21 21:02:06 UTC
You should file this upstream.

Comment 3 Chuck Ebbert 2011-08-22 15:46:57 UTC
(In reply to comment #3)

> This is not POSIX compliant, man 3 ioctl says that EINVAL (Invalid argument) 
> should be put in errno if the I_ATMARK command fails.

I_ATMARK is for POSIX STREAMS devices and is not the same as SIOCATMARK, which takes no arguments. In any case I'm pretty sure ENOTTY is correct if you're trying to use it on a datagram socket.