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]
Message-ID: <1432006160.2870.138.camel@perches.com>
Date:	Mon, 18 May 2015 20:29:20 -0700
From:	Joe Perches <joe@...ches.com>
To:	Calvin Owens <calvinowens@...com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Alexey Dobriyan <adobriyan@...il.com>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Miklos Szeredi <miklos@...redi.hu>,
	Zefan Li <lizefan@...wei.com>, Oleg Nesterov <oleg@...hat.com>,
	David Howells <dhowells@...hat.com>,
	linux-kernel@...r.kernel.org, kernel-team@...com,
	Andy Lutomirski <luto@...capital.net>,
	Kees Cook <keescook@...omium.org>,
	"Kirill A. Shutemov" <kirill@...temov.name>
Subject: Re: [PATCH v5] procfs: Always expose /proc/<pid>/map_files/ and
 make it readable

On Mon, 2015-05-18 at 20:10 -0700, Calvin Owens wrote:
> Currently, /proc/<pid>/map_files/ is restricted to CAP_SYS_ADMIN, and
> is only exposed if CONFIG_CHECKPOINT_RESTORE is set. This interface is
> very useful for enumerating the files mapped into a process when the
> more verbose information in /proc/<pid>/maps is not needed. It also
> allows access to file descriptors for files that have been deleted and
> closed but are still mmapped into a process, which can be very useful
> for introspection and debugging.

style trivia:

> diff --git a/fs/proc/base.c b/fs/proc/base.c
[]
> +/*
> + * Enforce stronger PTRACE_MODE_ATTACH permissions on the symlinks under
> + * /proc/<pid>/map_files, since these links may refer to deleted or O_TMPFILE
> + * files that users might assume are inaccessible regardless of their
> + * ownership/permissions.
> + */
> +static void *proc_map_files_follow_link(struct dentry *dentry, struct nameidata *nd)
> +{
> +	struct inode *inode = d_inode(dentry);
> +	struct task_struct *task;
> +	int allowed = 0;
> +
> +	task = get_proc_task(inode);
> +	if (task) {
> +		allowed = ptrace_may_access(task, PTRACE_MODE_ATTACH);
> +		put_task_struct(task);
> +	} else {
> +		return ERR_PTR(-ESRCH);
> +	}
> +
> +	if (!allowed)
> +		return ERR_PTR(-EACCES);
> +
> +	return proc_pid_follow_link(dentry, nd);
> +}

It'd perhaps be clearer to read this with an
immediate return after a failure in get_proc_task.

Maybe something like (move initializations as desired):

static void *proc_map_files_follow_link(struct dentry *dentry, struct nameidata *nd)
{
	int allowed;
	struct iode *inode = d_inode(dentry);
	struct task_struct task = get_proc_task(inode);

	if (!task)
		return ERR_PTR(-ESRCH);

	allowed = ptrace_may_access(task, PTRACE_MODE_ATTACH);

	put_task_struct(task);

	if (!allowed)
		return ERR_PTR(-EACCES);

	return proc_pic_follow_link(dentry, nd);
}


--
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