All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Jan Kara <jack@suse.cz>,
	ltp-list@lists.sourceforge.net, tolzmann@molgen.mpg.de,
	bugzilla-daemon@bugzilla.kernel.org,
	Al Viro <viro@zeniv.linux.org.uk>,
	bugme-daemon@bugzilla.kernel.org, linux-fsdevel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>,
	chrubis@suse.cz
Subject: Re: [LTP] [Bugme-new] [Bug 15909] New: open("a/", O_NOFOLLOW) fails with ELOOP if "a" is a symbolic link to a directory.
Date: Wed, 12 May 2010 17:59:48 +0200	[thread overview]
Message-ID: <20100512155948.GD3326@quack.suse.cz> (raw)
In-Reply-To: <1273595753.4875.1.camel@subratamodak.linux.ibm.com>

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

  Hi,

On Tue 11-05-10 22:05:52, Subrata Modak wrote:
> It would be great if you can shoot it in the form of a patch, mentioning
> 
>      1. The GPL Lincense,
>      2. The purpose of the test case,
>      3. Exact location it goes,
>      4. Which LTPROOT/runtest/<file> executes it
  With a help of Cyril I've created the attached patch and verified that
the test fails on 2.6.33 but succeeds on 2.6.32...

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

[-- Attachment #2: ltp-open-test.diff --]
[-- Type: text/x-patch, Size: 5333 bytes --]

Add O_NOFOLLOW open test with trailing slash

In a situation where symlink (say 's') points to a directory,
open("s/", O_NOFOLLOW) should succeed. Check for this.

Signed-off-by: Jan Kara <jack@suse.cz>

--- ltp/testcases/kernel/syscalls/open/open07.c.orig	2010-05-12 15:26:03.000000000 +0200
+++ ltp/testcases/kernel/syscalls/open/open07.c	2010-05-12 17:50:54.000000000 +0200
@@ -40,6 +40,9 @@
  * 	4. Create a symbolic link to a symbolically linked directory, and call
  *	   open(O_NOFOLLOW). Check that it returns ELOOP.
  *
+ * 	5. Create a symbolic link to a directory, and call
+ *         open("link/", O_NOFOLLOW). Check that it succeeds.
+ *
  * USAGE:  <for command-line>
  *  open07 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
  *     where,  -c n : Run n copies concurrently.
@@ -70,34 +73,35 @@ void setupfunc_test1();
 void setupfunc_test2();
 void setupfunc_test3();
 void setupfunc_test4();
+void setupfunc_test5();
 
 char *TCID = "open07";
-int TST_TOTAL = 4;
+int TST_TOTAL = 5;
 extern int Tst_count;
 int fd1, fd2;
 
-char file1[100], file2[100], file3[100];
-
 int exp_enos[] = {ELOOP, 0};
 
 struct test_case_t {
 	char *desc;
-	char *filename;
+	char filename[100];
 	int flags;
 	int mode;
 	void (*setupfunc)();
 	int exp_errno;
-    int fileHandle;
+	int fileHandle;
 } TC[] = {
-	{ "Test for ELOOP on f2: f1 -> f2", file2, O_NOFOLLOW, 00700,
+	{ "Test for ELOOP on f2: f1 -> f2", {}, O_NOFOLLOW, 00700,
 		setupfunc_test1, ELOOP, 0},
-	{ "Test for ELOOP on d2: d1 -> d2", file2, O_NOFOLLOW, 00700,
+	{ "Test for ELOOP on d2: d1 -> d2", {}, O_NOFOLLOW, 00700,
 		setupfunc_test2, ELOOP, 0},
-	{ "Test for ELOOP on f3: f1 -> f2 -> f3", file3, O_NOFOLLOW, 00700,
+	{ "Test for ELOOP on f3: f1 -> f2 -> f3", {}, O_NOFOLLOW, 00700,
 		setupfunc_test3, ELOOP, 0},
-	{ "Test for ELOOP on d3: d1 -> d2 -> d3", file3, O_NOFOLLOW, 00700,
+	{ "Test for ELOOP on d3: d1 -> d2 -> d3", {}, O_NOFOLLOW, 00700,
 		setupfunc_test4, ELOOP, 0},
-	{ NULL, NULL, 0, 0, NULL, 0, 0}
+	{ "Test for success on d2: d1 -> d2", {}, O_NOFOLLOW, 00700,
+		setupfunc_test5, 0, 0},
+	{ NULL, {}, 0, 0, NULL, 0, 0}
 };
 
 int main(int ac, char **av)
@@ -132,21 +136,34 @@ int main(int ac, char **av)
 
 			TEST(open(TC[i].filename, TC[i].flags, TC[i].mode));
 
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "call succeeded unexpectedly");
-			}
-
-			TEST_ERROR_LOG(TEST_ERRNO);
-
-			if (TEST_ERRNO != TC[i].exp_errno) {
-				tst_resm(TFAIL, "open returned unexpected "
-					 "errno, expected: %d, got: %d",
-					 TC[i].exp_errno, TEST_ERRNO);
+			if (TC[i].exp_errno != 0) {
+				if (TEST_RETURN != -1) {
+					tst_resm(TFAIL, "open succeeded "
+						 "unexpectedly");
+				}
+				TEST_ERROR_LOG(TEST_ERRNO);
+
+				if (TEST_ERRNO != TC[i].exp_errno) {
+					tst_resm(TFAIL, "open returned "
+						 "unexpected errno, expected: "
+						 "%d, got: %d",
+						 TC[i].exp_errno, TEST_ERRNO);
+				} else {
+					tst_resm(TPASS, "open returned "
+						 "expected ELOOP error");
+				}
 			} else {
-				tst_resm(TPASS, "open returned expected "
-					 "ELOOP error");
+				if (TEST_RETURN == -1) {
+					tst_resm(TFAIL, "open failed "
+						 "unexpectedly with errno %d",
+						 TEST_ERRNO);
+				} else {
+					tst_resm(TPASS, "open succeeded as "
+						 "expected");
+				}
 			}
-            close(TC[i].fileHandle);
+
+			close(TC[i].fileHandle);
 		}
 	}
 	cleanup();
@@ -157,6 +174,8 @@ int main(int ac, char **av)
 void
 setupfunc_test1()
 {
+	char file1[100], file2[100];
+
 	sprintf(file1, "open03.1.%d", getpid());
 	sprintf(file2, "open03.2.%d", getpid());
 	if ((fd1 = creat(file1, 00700)) < 0) {
@@ -167,11 +186,14 @@ setupfunc_test1()
 		tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno);
 		/*NOTREACHED*/
 	}
+	strcpy(TC[0].filename, file2);
 }
 
 void
 setupfunc_test2()
 {
+	char file1[100], file2[100];
+
 	sprintf(file1, "open03.3.%d", getpid());
 	sprintf(file2, "open03.4.%d", getpid());
 	if (mkdir(file1, 00700) < 0) {
@@ -182,11 +204,14 @@ setupfunc_test2()
 		tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno);
 		/*NOTREACHED*/
 	}
+	strcpy(TC[1].filename, file2);
 }
 
 void
 setupfunc_test3()
 {
+	char file1[100], file2[100], file3[100];
+
 	sprintf(file1, "open03.5.%d", getpid());
 	sprintf(file2, "open03.6.%d", getpid());
 	sprintf(file3, "open03.7.%d", getpid());
@@ -202,11 +227,14 @@ setupfunc_test3()
 		tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno);
 		/*NOTREACHED*/
 	}
+	strcpy(TC[2].filename, file3);
 }
 
 void
 setupfunc_test4()
 {
+	char file1[100], file2[100], file3[100];
+
 	sprintf(file1, "open03.8.%d", getpid());
 	sprintf(file2, "open03.9.%d", getpid());
 	sprintf(file3, "open03.10.%d", getpid());
@@ -222,6 +250,26 @@ setupfunc_test4()
 		tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno);
 		/*NOTREACHED*/
 	}
+	strcpy(TC[3].filename, file3);
+}
+
+void
+setupfunc_test5()
+{
+	char file1[100], file2[100];
+
+	sprintf(file1, "open11.3.%d", getpid());
+	sprintf(file2, "open12.4.%d", getpid());
+	if (mkdir(file1, 00700) < 0) {
+		tst_brkm(TBROK, cleanup, "mkdir(2) failed: errno: %d", errno);
+		/*NOTREACHED*/
+	}
+	if (symlink(file1, file2) < 0) {
+		tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno);
+		/*NOTREACHED*/
+	}
+	strcpy(TC[4].filename, file2);
+	strcat(TC[4].filename, "/");
 }
 
 /*

  reply	other threads:[~2010-05-12 15:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-15909-10286@https.bugzilla.kernel.org/>
2010-05-06 21:30 ` [Bugme-new] [Bug 15909] New: open("a/", O_NOFOLLOW) fails with ELOOP if "a" is a symbolic link to a directory Andrew Morton
2010-05-09 15:29   ` OGAWA Hirofumi
2010-05-11 15:48   ` Jan Kara
2010-05-11 16:24     ` [LTP] " Jan Kara
2010-05-11 16:24       ` Jan Kara
2010-05-11 16:35       ` [LTP] " Subrata Modak
2010-05-11 16:35         ` Subrata Modak
2010-05-12 15:59         ` Jan Kara [this message]
2010-05-12 16:46           ` Subrata Modak
2010-05-13 11:29             ` Jan Kara
2010-05-17 20:06               ` Subrata Modak
2010-05-11 16:28     ` Jan Kara
2010-05-12 10:02       ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100512155948.GD3326@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=bugme-daemon@bugzilla.kernel.org \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=chrubis@suse.cz \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=subrata@linux.vnet.ibm.com \
    --cc=tolzmann@molgen.mpg.de \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.