From: Dave Chinner <david@fromorbit.com>
To: David Drysdale <drysdale@google.com>
Cc: linux-kernel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Kees Cook <keescook@chromium.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Meredydd Luff <meredydd@senatehouse.org>,
Will Drewry <wad@chromium.org>,
Jorge Lucangeli Obes <jorgelo@google.com>,
Ricky Zhou <rickyz@google.com>, Lee Campbell <leecam@google.com>,
Julien Tinnes <jln@google.com>,
Mike Depinet <mdepinet@google.com>,
James Morris <james.l.morris@oracle.com>,
Andy Lutomirski <luto@amacapital.net>,
Paolo Bonzini <pbonzini@redhat.com>,
Paul Moore <paul@paul-moore.com>,
Christoph Hellwig <hch@infradead.org>,
Michael Kerrisk <mtk.manpages@gmail.com>,
linux-api@vger.kernel.org, linux-security-module@vger.kernel.org,
fstests@vger.kernel.org
Subject: Re: [PATCHv3 xfstests 2/3] generic: test openat and new O_BENEATH flag
Date: Tue, 17 Mar 2015 10:24:34 +1100 [thread overview]
Message-ID: <20150316232434.GJ28557@dastard> (raw)
In-Reply-To: <1425909612-28034-3-git-send-email-drysdale@google.com>
On Mon, Mar 09, 2015 at 02:00:11PM +0000, David Drysdale wrote:
> Test basic openat(2) behaviour.
>
> Test that if O_BENEATH flag is set, openat() will only
> open paths that have no .. component and do not start
> with /. Symlinks are also checked for the same restrictions.
>
> Signed-off-by: David Drysdale <drysdale@google.com>
> ---
> .gitignore | 1 +
> common/openat | 61 ++++++++++++++++++++++++++++++
> src/Makefile | 3 +-
> src/openat.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
This strikes me as something that shoul dbe added to xfs_io for
testing, as it already supports a heap of other open flags and
xfstests is already dependent on it.
> tests/generic/151 | 89 ++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/151.out | 9 +++++
> tests/generic/152 | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/152.out | 23 ++++++++++++
> tests/generic/group | 2 +
I'd also prefer one patch per new test - it's easier to review...
> +_openat_setup()
> +{
> + local dir=$1
> +
> + mkdir -p $dir/subdir
> + echo 0123456789 > $dir/topfile
> + echo 0123456789 > $dir/subdir/bottomfile
> +
> + ln -s subdir/bottomfile $dir/symlinkdown
> + ln -s ../topfile $dir/subdir/symlinkup
> + ln -s $dir/topfile $dir/subdir/symlinkout
> + ln -s bottomfile $dir/subdir/symlinkin
> +}
> +
> +#
> +# Check whether the openat wrapper program is available
> +#
> +_requires_openat()
> +{
> + OPENAT_PROG=$here/src/openat
> + _require_command $OPENAT_PROG
> +}
if this is part of xfs_io, then _requires_xfs_io_command "open -b"
could be used to test if the command is supported, and no need for
this function at all.
> +#
> +# This checks whether the O_BENEATH flag is supported by the openat syscall
> +#
> +_requires_o_beneath()
> +{
> + # Kernels that don't support O_BENEATH will silently accept it, so
> + # check for O_BENEATH behavior: attempting to open an absolute
> + # path should fail with EPERM.
> + $OPENAT_PROG -t -b $TEST_DIR
> + if [ $? -ne 0 ]; then
> + _notrun "kernel doesn't support O_BENEATH flag in openat syscall"
> + fi
> +}
as running the command would tell us if the kernel supports it, too.
> +#endif
> +#endif
> +
> +void usage(const char *progname)
> +{
> + fprintf(stderr, "Usage: %s [-f dirname] [-b] [-n] [-t] <file>\n",
> + progname);
> + fprintf(stderr," -f dirname : use this dir for dfd\n");
> + fprintf(stderr," -b : open with O_BENEATH\n");
> + fprintf(stderr," -n : open with O_NOFOLLOW\n");
> + fprintf(stderr," -t : test for expected EPERM failure\n");
> + fprintf(stderr," -h : show this usage message\n");
> + exit(1);
Hmm - you're also testing O_NOFOLLOW behaviour too? Perhaps that
should be mentioned/added to xfs_io, too?
The reason I suggest this, even though it's a little more work, is
tht we can then re-use the new flags in other tests easily without
needing to write new helper functions...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
WARNING: multiple messages have this Message-ID (diff)
From: Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org>
To: David Drysdale <drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Alexander Viro
<viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
"Eric W. Biederman"
<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Meredydd Luff <meredydd-zPN50pYk8eUaUu29zAJCuw@public.gmane.org>,
Will Drewry <wad-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
Jorge Lucangeli Obes
<jorgelo-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Ricky Zhou <rickyz-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Lee Campbell <leecam-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Julien Tinnes <jln-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Mike Depinet <mdepinet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
James Morris
<james.l.morris-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>,
Paolo Bonzini <pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Paul Moore <paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org>,
Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Michael Kerrisk
<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
fstests-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCHv3 xfstests 2/3] generic: test openat and new O_BENEATH flag
Date: Tue, 17 Mar 2015 10:24:34 +1100 [thread overview]
Message-ID: <20150316232434.GJ28557@dastard> (raw)
In-Reply-To: <1425909612-28034-3-git-send-email-drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
On Mon, Mar 09, 2015 at 02:00:11PM +0000, David Drysdale wrote:
> Test basic openat(2) behaviour.
>
> Test that if O_BENEATH flag is set, openat() will only
> open paths that have no .. component and do not start
> with /. Symlinks are also checked for the same restrictions.
>
> Signed-off-by: David Drysdale <drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> ---
> .gitignore | 1 +
> common/openat | 61 ++++++++++++++++++++++++++++++
> src/Makefile | 3 +-
> src/openat.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
This strikes me as something that shoul dbe added to xfs_io for
testing, as it already supports a heap of other open flags and
xfstests is already dependent on it.
> tests/generic/151 | 89 ++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/151.out | 9 +++++
> tests/generic/152 | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/152.out | 23 ++++++++++++
> tests/generic/group | 2 +
I'd also prefer one patch per new test - it's easier to review...
> +_openat_setup()
> +{
> + local dir=$1
> +
> + mkdir -p $dir/subdir
> + echo 0123456789 > $dir/topfile
> + echo 0123456789 > $dir/subdir/bottomfile
> +
> + ln -s subdir/bottomfile $dir/symlinkdown
> + ln -s ../topfile $dir/subdir/symlinkup
> + ln -s $dir/topfile $dir/subdir/symlinkout
> + ln -s bottomfile $dir/subdir/symlinkin
> +}
> +
> +#
> +# Check whether the openat wrapper program is available
> +#
> +_requires_openat()
> +{
> + OPENAT_PROG=$here/src/openat
> + _require_command $OPENAT_PROG
> +}
if this is part of xfs_io, then _requires_xfs_io_command "open -b"
could be used to test if the command is supported, and no need for
this function at all.
> +#
> +# This checks whether the O_BENEATH flag is supported by the openat syscall
> +#
> +_requires_o_beneath()
> +{
> + # Kernels that don't support O_BENEATH will silently accept it, so
> + # check for O_BENEATH behavior: attempting to open an absolute
> + # path should fail with EPERM.
> + $OPENAT_PROG -t -b $TEST_DIR
> + if [ $? -ne 0 ]; then
> + _notrun "kernel doesn't support O_BENEATH flag in openat syscall"
> + fi
> +}
as running the command would tell us if the kernel supports it, too.
> +#endif
> +#endif
> +
> +void usage(const char *progname)
> +{
> + fprintf(stderr, "Usage: %s [-f dirname] [-b] [-n] [-t] <file>\n",
> + progname);
> + fprintf(stderr," -f dirname : use this dir for dfd\n");
> + fprintf(stderr," -b : open with O_BENEATH\n");
> + fprintf(stderr," -n : open with O_NOFOLLOW\n");
> + fprintf(stderr," -t : test for expected EPERM failure\n");
> + fprintf(stderr," -h : show this usage message\n");
> + exit(1);
Hmm - you're also testing O_NOFOLLOW behaviour too? Perhaps that
should be mentioned/added to xfs_io, too?
The reason I suggest this, even though it's a little more work, is
tht we can then re-use the new flags in other tests easily without
needing to write new helper functions...
Cheers,
Dave.
--
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org
next prev parent reply other threads:[~2015-03-16 23:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 14:00 [PATCHv3 0/3] fs: add O_BENEATH flag to openat(2) David Drysdale
2015-03-09 14:00 ` [PATCHv3 1/3] " David Drysdale
2015-03-09 14:00 ` [PATCHv3 xfstests 2/3] generic: test openat and new O_BENEATH flag David Drysdale
2015-03-09 14:00 ` David Drysdale
2015-03-16 23:24 ` Dave Chinner [this message]
2015-03-16 23:24 ` Dave Chinner
2015-03-17 15:33 ` Kees Cook
2015-03-18 2:52 ` Dave Chinner
2015-03-18 2:52 ` Dave Chinner
2015-03-18 10:17 ` David Drysdale
2015-03-09 14:00 ` [PATCHv3 man-pages 3/3] open.2: describe " David Drysdale
2015-03-09 14:32 ` Michael Kerrisk (man-pages)
2015-03-09 15:16 ` David Drysdale
2015-03-09 15:16 ` David Drysdale
2015-03-09 15:54 ` Michael Kerrisk (man-pages)
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=20150316232434.GJ28557@dastard \
--to=david@fromorbit.com \
--cc=drysdale@google.com \
--cc=ebiederm@xmission.com \
--cc=fstests@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=james.l.morris@oracle.com \
--cc=jln@google.com \
--cc=jorgelo@google.com \
--cc=keescook@chromium.org \
--cc=leecam@google.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mdepinet@google.com \
--cc=meredydd@senatehouse.org \
--cc=mtk.manpages@gmail.com \
--cc=paul@paul-moore.com \
--cc=pbonzini@redhat.com \
--cc=rickyz@google.com \
--cc=viro@zeniv.linux.org.uk \
--cc=wad@chromium.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 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.