From: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
To: ltp-list-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: tolzmann-KUpvgZVWgV9o1qOY/usvUg@public.gmane.org,
bugzilla-daemon-590EEB7GvNiWaY/ihj7yzEB+6BGkLq7r@public.gmane.org,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
bugme-daemon-590EEB7GvNiWaY/ihj7yzEB+6BGkLq7r@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Subject: Re: [Bugme-new] [Bug 15909] New: open("a/", O_NOFOLLOW) fails with ELOOP if "a" is a symbolic link to a directory.
Date: Tue, 11 May 2010 18:24:52 +0200 [thread overview]
Message-ID: <20100511162452.GD2832@quack.suse.cz> (raw)
In-Reply-To: <20100511154850.GC2832-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2651 bytes --]
On Tue 11-05-10 17:48:51, Jan Kara wrote:
> On Thu 06-05-10 14:30:02, Andrew Morton wrote:
> >
> > (switched to email. Please respond via emailed reply-to-all, not via the
> > bugzilla web interface).
> >
> > On Wed, 5 May 2010 13:01:22 GMT
> > bugzilla-daemon-590EEB7GvNiWaY/ihj7yzEB+6BGkLq7r@public.gmane.org wrote:
> >
> > > https://bugzilla.kernel.org/show_bug.cgi?id=15909
> > >
> > > Summary: open("a/",O_NOFOLLOW) fails with ELOOP if "a" is a
> > > symbolic link to a directory.
> > > Product: File System
> > > Version: 2.5
> > > Kernel Version: 2.6.34-rc6
> > > Platform: All
> > > OS/Version: Linux
> > > Tree: Mainline
> > > Status: NEW
> > > Severity: high
> > > Priority: P1
> > > Component: Other
> > > AssignedTo: fs_other-ztI5WcYan/vQLgFONoPN62D2FQJk+8+b@public.gmane.org
> > > ReportedBy: tolzmann-KUpvgZVWgV9o1qOY/usvUg@public.gmane.org
> > > Regression: No
> > >
> > >
> > > mkdir c
> > > ln -s c a
> > >
> > > f=open("a/",O_RDONLY+O_NOFOLLOW)
> > >
> > > fails with ELOOP. However, this open should behave like open("a/.") not like
> > > open("a") according to path_resolution(7). In kernel version 2.6.32 the open
> > > worked as documented.
> > >
> > > On a higher level this bug makes
> > >
> > > find a/
> > >
> > > to fail.
> > >
> >
> > It sounds like this 2.6.32->2.6.34-rc6 regression could have pretty
> > serious ramifications for some users. Does anyone know whcih commit
> > might have caused it?
> The patch below fixes the issue for me but someone should have a look
> at it because I'm not really an expert in that code and the code paths are so
> twisted that my mind is currently tied into a knot ;).
>
> Honza
> ---
>
> From d53d3cc6488d9135bb69c3ff7e034b3b624866ed Mon Sep 17 00:00:00 2001
> From: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
> Date: Tue, 11 May 2010 16:34:25 +0200
> Subject: [PATCH] vfs: Fix O_NOFOLLOW behavior for paths with trailing slashes
>
> According to specification
> mkdir d; ln -s d a; open("a/", O_NOFOLLOW | O_RDONLY)
> should return success but currently it did return ELOOP. Fix the code to ignore
> O_NOFOLLOW in case the provided path has trailing slashes. This is a regression
> caused by path lookup cleanup patch series.
>
> CC: stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
> Signed-off-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
...
BTW: It might be worthwhile to add the attached testcase to LTP?
Honza
--
Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
SUSE Labs, CR
[-- Attachment #2: open-follow-test.c --]
[-- Type: text/x-c++src, Size: 991 bytes --]
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
int do_test(char *p)
{
int err;
char path[16];
strcpy(path, p);
err = open(path, O_NOFOLLOW | O_RDONLY);
if (err >= 0) {
fprintf(stderr, "open(\"%s\", O_NOFOLLOW | O_RDONLY) did not fail!\n", path);
return 1;
}
strcat(path, "/");
err = open(path, O_NOFOLLOW | O_RDONLY);
if (err < 0) {
fprintf(stderr, "open(\"%s\", O_NOFOLLOW | O_RDONLY) failed with %d\n", path, errno);
return 1;
}
strcat(path, ".");
err = open(path, O_NOFOLLOW | O_RDONLY);
if (err < 0) {
fprintf(stderr, "open(\"%s\", O_NOFOLLOW | O_RDONLY) failed with %d\n", path, errno);
return 1;
}
return 0;
}
int main(void)
{
if (mkdir("d", 0700) < 0) {
perror("mkdir");
return 1;
}
if (symlink("d", "a") < 0) {
perror("link");
return 1;
}
if (do_test("a"))
return 1;
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 80 bytes --]
------------------------------------------------------------------------------
[-- Attachment #4: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2010-05-11 16:24 UTC|newest]
Thread overview: 11+ 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
[not found] ` <20100511154850.GC2832-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
2010-05-11 16:24 ` Jan Kara [this message]
2010-05-11 16:35 ` [LTP] " Subrata Modak
2010-05-12 15:59 ` Jan Kara
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=20100511162452.GD2832@quack.suse.cz \
--to=jack-alswssmvlrq@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=bugme-daemon-590EEB7GvNiWaY/ihj7yzEB+6BGkLq7r@public.gmane.org \
--cc=bugzilla-daemon-590EEB7GvNiWaY/ihj7yzEB+6BGkLq7r@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ltp-list-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=tolzmann-KUpvgZVWgV9o1qOY/usvUg@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).