public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix compat_sys_utimensat
@ 2009-08-28  9:48 Suzuki Poulose
  2009-09-01  7:34 ` Suzuki Poulose
  0 siblings, 1 reply; 2+ messages in thread
From: Suzuki Poulose @ 2009-08-28  9:48 UTC (permalink / raw)
  To: akpm; +Cc: lkml

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]


Hi,

The compat_utimensat syscall does not ignore tv_sec field when tv_nsec 
is set to UTIME_OMIT/UTIME_NOW and returns -EINVAL.

This problem was revealed with the utimensat_tests from LTP.

The utimensat() syscall works fine.

Attaching a patch for the issue. The patch has been tested and verified 
to fix the issue.

Please apply.

Thanks,

Suzuki

[-- Attachment #2: fix-compat-utimensat-syscall.diff --]
[-- Type: text/plain, Size: 920 bytes --]

Compat utimensat() returns EINVAL when the tv_nsec is one of UTIME_OMIT or UTIME_NOW and
the tv_sec is set to non-zero. As per man pages, the tv_sec field should be ignored.

The sys_utimensat() works fine in this case.

Signed-off-by: Suzuki K P <suzuki@in.ibm.com>

Index: linux-2.6.31-rc7/fs/compat.c
===================================================================
--- linux-2.6.31-rc7.orig/fs/compat.c	2009-08-22 06:30:46.000000000 +0530
+++ linux-2.6.31-rc7/fs/compat.c	2009-08-28 14:14:32.781364904 +0530
@@ -100,13 +100,6 @@
 		    get_compat_timespec(&tv[1], &t[1]))
 			return -EFAULT;
 
-		if ((tv[0].tv_nsec == UTIME_OMIT || tv[0].tv_nsec == UTIME_NOW)
-		    && tv[0].tv_sec != 0)
-			return -EINVAL;
-		if ((tv[1].tv_nsec == UTIME_OMIT || tv[1].tv_nsec == UTIME_NOW)
-		    && tv[1].tv_sec != 0)
-			return -EINVAL;
-
 		if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT)
 			return 0;
 	}

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

* Re: [PATCH] Fix compat_sys_utimensat
  2009-08-28  9:48 [PATCH] Fix compat_sys_utimensat Suzuki Poulose
@ 2009-09-01  7:34 ` Suzuki Poulose
  0 siblings, 0 replies; 2+ messages in thread
From: Suzuki Poulose @ 2009-09-01  7:34 UTC (permalink / raw)
  To: akpm; +Cc: lkml

Suzuki Poulose wrote:
> 
> Hi,
> 
> The compat_utimensat syscall does not ignore tv_sec field when tv_nsec 
> is set to UTIME_OMIT/UTIME_NOW and returns -EINVAL.



mjs22lp5:~ # cat utimensat-test.c
#define _GNU_SOURCE
#define _ATFILE_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>

main(int argc, char *argv[])
{
	struct timespec ts[2];
	struct timespec *tsp;
	
	if (argc < 2) {
		fprintf(stderr, "Usage : %s filename\n", argv[0]);
		exit (-1);
	}
	
	ts[0].tv_nsec = ts[1].tv_nsec = UTIME_NOW;
	ts[0].tv_sec = ts[1].tv_sec = 1;

	tsp = ts;
	
	if (utimensat(AT_FDCWD, argv[1],tsp,0) == -1)
		perror("utimensat");
	else
		fprintf(stdout, "utimensat success\n");
	return 0;
}
mjs22lp5:~ # cc -m64 utimensat-test.c -o utimensat_test64
mjs22lp5:~ # cc -m32 utimensat-test.c -o utimensat_test32
mjs22lp5:~ # ./utimensat_test32 /tmp/utimensat_test
utimensat: Invalid argument
mjs22lp5:~ # ./utimensat_test64 /tmp/utimensat_test
utimensat success
mjs22lp5:~ # uname -r
2.6.31-rc8

> 
> This problem was revealed with the utimensat_tests from LTP.
> 
> The utimensat() syscall works fine.
> 
> Attaching a patch for the issue. The patch has been tested and verified 
> to fix the issue.

With the patch :

mjs22lp5:~ # ./utimensat_test64 /tmp/utimensat_test
utimensat success
mjs22lp5:~ # ./utimensat_test32 /tmp/utimensat_test
utimensat success
mjs22lp5:~ # uname -r
2.6.31-rc8utimensat


> 
> Please apply.
> 
> Thanks,
> 
> Suzuki
> 


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

end of thread, other threads:[~2009-09-01  7:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-28  9:48 [PATCH] Fix compat_sys_utimensat Suzuki Poulose
2009-09-01  7:34 ` Suzuki Poulose

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