lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 13 Jul 2012 00:40:57 +0200
From:	ольга крыжановская <olga.kryzhanovska@...il.com>
To:	Greg KH <gregkh@...uxfoundation.org>
Cc:	linux-kernel@...r.kernel.org, stable@...r.kernel.org,
	torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
	alan@...rguk.ukuu.org.uk, Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [ 42/68] vfs: make O_PATH file descriptors usable for fchdir()

Just to be sure, has any one tested the patch (I can't, I am not doing
Linux kernel development and the closest here to me here only does
Solaris/Illumos and SUPERUX kernel development)?

My test case, which works on Solaris and AIX is below. You will have
to do a s/O_SEARCH/O_PATH/
-------- snip --------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#include <stdlib.h>
#include <stdio.h>

int main(int ac, char *av[])
{
	int dirfd, dupdirfd;

	dirfd=open("/etc", O_SEARCH);
	if(dirfd<0)
	{
		fprintf(stderr, "open() failed.\n");
		return EXIT_FAILURE;
	}
	
	dupdirfd = fcntl(dirfd, F_DUPFD, 50);
	if(dirfd<0)
	{
		fprintf(stderr, "fcntl() failed.\n");
		return EXIT_FAILURE;
	}
	
	if(fchdir(dupdirfd)<0)
	{
		fprintf(stderr, "fchdir(dupdirfd) failed.\n");
		return EXIT_FAILURE;
	}

	if(fchdir(dirfd)<0)
	{
		fprintf(stderr, "fchdir(dirfd) failed.\n");
		return EXIT_FAILURE;
	}

	if(openat(dupdirfd, "profile", O_RDONLY)<0)
	{
		fprintf(stderr, "openat(dupdirfd, profile, O_RDONLY) failed.\n");
		return EXIT_FAILURE;
	}

	dirfd=openat(dupdirfd, "krb5", O_SEARCH);
	if(dirfd<0)
	{
		fprintf(stderr, "openat(dupdirfd, krb5, O_SEARCH) failed.\n");
		return EXIT_FAILURE;
	}

	if(fchdir(dirfd)<0)
	{
		fprintf(stderr, "2nd fchdir(dirfd) failed.\n");
		return EXIT_FAILURE;
	}
	
	puts("SUCCESS.");

	return EXIT_SUCCESS;
}
-------- snip --------

Olga

On Thu, Jul 12, 2012 at 7:51 PM, Greg KH <gregkh@...uxfoundation.org> wrote:
> 3.0-stable review patch.  If anyone has any objections, please let me know.
>
> ------------------
>
> From: Linus Torvalds <torvalds@...ux-foundation.org>
>
> commit 332a2e1244bd08b9e3ecd378028513396a004a24 upstream.
>
> We already use them for openat() and friends, but fchdir() also wants to
> be able to use O_PATH file descriptors.  This should make it comparable
> to the O_SEARCH of Solaris.  In particular, O_PATH allows you to access
> (not-quite-open) a directory you don't have read persmission to, only
> execute permission.
>
> Noticed during development of multithread support for ksh93.
>
> Reported-by: ольга крыжановская <olga.kryzhanovska@...il.com>
> Cc: Al Viro <viro@...iv.linux.org.uk>
> Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
>
> ---
>  fs/open.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -396,10 +396,10 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd
>  {
>         struct file *file;
>         struct inode *inode;
> -       int error;
> +       int error, fput_needed;
>
>         error = -EBADF;
> -       file = fget(fd);
> +       file = fget_raw_light(fd, &fput_needed);
>         if (!file)
>                 goto out;
>
> @@ -413,7 +413,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd
>         if (!error)
>                 set_fs_pwd(current->fs, &file->f_path);
>  out_putf:
> -       fput(file);
> +       fput_light(file, fput_needed);
>  out:
>         return error;
>  }
>
>



-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     olga.kryzhanovska@...il.com   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ