public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] ioctl01 failed when checking the ioctl bad command return value.
@ 2012-11-01  2:10 Linliangjie
  2012-11-01  3:34 ` Wanlong Gao
  0 siblings, 1 reply; 2+ messages in thread
From: Linliangjie @ 2012-11-01  2:10 UTC (permalink / raw)
  To: ltp-list@lists.sourceforge.net; +Cc: shyju pv, Sanil kumar, Maxiansheng (Max)


[-- Attachment #1.1: Type: text/plain, Size: 2573 bytes --]

Issue description:
-------------------
Kernel Version : 3.7-rc2
System call : ioctl
LTP Testcase : ioctl01
LTP Version : 20120903
Platform : x86_64 ( HP 8200 PC )
Testcase Description : Testcase to check the errnos set by the ioctl(2) system
call.
Previous kernel version in which testcase passed : 3.2.9

Executing log:
-------------------------
[root@linux-qf4g]-[/tmp/ltp/ltp/testcases/bin]
(0)# ./ioctl01 -D /dev/tty
ioctl01     1  TPASS  :  failed as expected: TEST_ERRNO=EBADF(9): Bad file
descriptor
ioctl01     2  TPASS  :  failed as expected: TEST_ERRNO=EFAULT(14): Bad address
ioctl01     3  TFAIL  :  failed unexpectedly; expected 22 - Invalid argument:
TEST_ERRNO=ENOTTY(25): Inappropriate ioctl for device
ioctl01     4  TPASS  :  failed as expected: TEST_ERRNO=ENOTTY(25):
Inappropriate ioctl for device
ioctl01     5  TPASS  :  failed as expected: TEST_ERRNO=EFAULT(14): Bad address
-------------------------
The return value of the code is expected to be 22 but 24 is returned and
hence the LTP test failed.

From v3.2.9, kernel has changed the return value for bad command.
The patch commit no:07d106d0a33d6063d2061305903deb02489eba20

Below is part of the patch:
----------------------------------

diff --git a/fs/ioctl.c b/fs/ioctl.c

index 1d9b9fc..066836e 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c

@@ -42,7 +42,7 @@ static long vfs_ioctl(struct file *filp, unsigned

 int cmd,

        error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
        if (error == -ENOIOCTLCMD)
-               error = -EINVAL;
+               error = -ENOTTY;


diff --git a/block/ioctl.c b/block/ioctl.c
index ca939fc..d510c2a 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -180,6 +180,26 @@ int __blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
 EXPORT_SYMBOL_GPL(__blkdev_driver_ioctl);

 /*
+ * Is it an unrecognized ioctl? The correct returns are either
+ * ENOTTY (final) or ENOIOCTLCMD ("I don't know this one, try a
+ * fallback"). ENOIOCTLCMD gets turned into ENOTTY by the ioctl
+ * code before returning.
+ *
+ * Confused drivers sometimes return EINVAL, which is wrong. It
+ * means "I understood the ioctl command, but the parameters to
+ * it were wrong".
+ *
+ * We should aim to just fix the broken drivers, the EINVAL case
+ * should go away.
+ */

---------------------------------


We can see that kernel has modified the return value of bad command from EINVAL
to ENOTTY. So I think we should update the ltp code to cope with the latest
kernel.




Jack

[-- Attachment #1.2: Type: text/html, Size: 4295 bytes --]

[-- Attachment #2: Type: text/plain, Size: 240 bytes --]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] ioctl01 failed when checking the ioctl bad command return value.
  2012-11-01  2:10 [LTP] ioctl01 failed when checking the ioctl bad command return value Linliangjie
@ 2012-11-01  3:34 ` Wanlong Gao
  0 siblings, 0 replies; 2+ messages in thread
From: Wanlong Gao @ 2012-11-01  3:34 UTC (permalink / raw)
  To: Linliangjie
  Cc: shyju pv, ltp-list@lists.sourceforge.net, Maxiansheng (Max),
	Sanil kumar

On 11/01/2012 10:10 AM, Linliangjie wrote:
> Issue description: 
> ------------------- 
> Kernel Version : 3.7-rc2
> System call : ioctl
> LTP Testcase : ioctl01
> LTP Version : 20120903 
> Platform : x86_64 ( HP 8200 PC ) 
> Testcase Description : Testcase to check the errnos set by the ioctl(2) system
> call.
> Previous kernel version in which testcase passed : 3.2.9
> 
> Executing log:
> -------------------------
> [root@linux-qf4g]-[/tmp/ltp/ltp/testcases/bin]
> (0)# ./ioctl01 -D /dev/tty
> ioctl01     1  TPASS  :  failed as expected: TEST_ERRNO=EBADF(9): Bad file
> descriptor
> ioctl01     2  TPASS  :  failed as expected: TEST_ERRNO=EFAULT(14): Bad address
> ioctl01     3  TFAIL  :  failed unexpectedly; expected 22 - Invalid argument:
> TEST_ERRNO=ENOTTY(25): Inappropriate ioctl for device
> ioctl01     4  TPASS  :  failed as expected: TEST_ERRNO=ENOTTY(25):
> Inappropriate ioctl for device
> ioctl01     5  TPASS  :  failed as expected: TEST_ERRNO=EFAULT(14): Bad address
> -------------------------
> The return value of the code is expected to be 22 but 24 is returned and 
> hence the LTP test failed. 
> 
>>From v3.2.9, kernel has changed the return value for bad command. 
> The patch commit no:07d106d0a33d6063d2061305903deb02489eba20

Yes, you are right, but you didn't find the real effective patch,
the real effective patch is 

commit bbb63c514a3464342967237a51a21ea8f61ab951
Author: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Date:   Mon Aug 27 15:23:12 2012 +0800

    drivers:tty:fix up ENOIOCTLCMD error handling
    
    At commit 07d106d0, Linus pointed out that ENOIOCTLCMD should be
    translated as ENOTTY to user mode.
    For example:
        fd = open("/dev/tty", O_RDWR);
        ioctl(fd, -1, &argp);
    
    then the errno should be ENOTTY but not EINVAL.
    
    Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
    Acked-by: Alan Cox <alan@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


It's a kernel change, so I will make a patch to fix this LTP test case.
Thank you very much for reporting this. ;)
And you *Huawei* guys are very welcome to the Open Source community. :-)


Regards,
Wanlong Gao


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-01  3:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-01  2:10 [LTP] ioctl01 failed when checking the ioctl bad command return value Linliangjie
2012-11-01  3:34 ` Wanlong Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox