All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oren Laadan <orenl@cs.columbia.edu>
To: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Serge Hallyn <serge@hallyn.com>,
	Matt Helsley <matthltc@us.ibm.com>, Dan Smith <danms@us.ibm.com>,
	John Stultz <johnstul@us.ibm.com>,
	Matthew Wilcox <matthew@wil.cx>,
	Jamie Lokier <jamie@shareable.org>,
	linux-fsdevel@vger.kernel.org,
	Containers <containers@lists.linux-foundation.org>
Subject: Re: [PATCH 04/16][cr][v3]: Restore file_owner info
Date: Wed, 04 Aug 2010 19:01:29 -0400	[thread overview]
Message-ID: <4C59F149.90606@cs.columbia.edu> (raw)
In-Reply-To: <1280877097-12377-5-git-send-email-sukadev@linux.vnet.ibm.com>



On 08/03/2010 07:11 PM, Sukadev Bhattiprolu wrote:
> Restore the file-owner information for each 'struct file'.  This is
> essentially is like a new fcntl(F_SETOWN) and fcntl(F_SETSIG) calls,
> except that the pid, uid, euid and signum values are read from the
> checkpoint image.
>
> Changelog[v3]:
> 	- [Oren Laadan]: Ensure find_vpid() found a valid pid before
> 	  making it the file owner.
> Changelog[v2]:
> 	- [Matt Helsley, Serge Hallyn]: Don't trust uids in checkpoint image.
> 	  (added CAP_KILL check)
> 	- Check that signal number read from the checkpoint image is valid.
> 	  (not sure it is required, since its an incomplete check for tampering)
>
> Signed-off-by: Sukadev Bhattiprolu<sukadev@linux.vnet.ibm.com>

I may have missed a previous discussion on this - but: do you
plan to relate the uid/euid to the userns ?

[...]

> diff --git a/fs/checkpoint.c b/fs/checkpoint.c
> index ce1b4af..b5486c1 100644
> --- a/fs/checkpoint.c
> +++ b/fs/checkpoint.c
> @@ -618,6 +618,68 @@ static int attach_file(struct file *file)
>   	return fd;
>   }
>
> +static int restore_file_owner(struct ckpt_ctx *ctx, struct ckpt_hdr_file *h,
> +		struct file *file)
> +{
> +	int ret;
> +	struct pid *pid;
> +	uid_t uid, euid;
> +
> +	uid = h->f_owner_uid;
> +	euid = h->f_owner_euid;
> +
> +	ckpt_debug("restore_file_owner(): uid %u, euid %u, pid %d, type %d\n",
> +			uid, euid, h->f_owner_pid, h->f_owner_pid_type);
> +	/*
> +	 * We can't trust the uids in the checkpoint image and normally need
> +	 * CAP_KILL. But if the uids match our ids, should be fine since we
> +	 * have access to the file.
> +	 *
> +	 * TODO: Move this check to __f_setown() ?
> +	 */
> +	ret = -EACCES;
> +	if (!capable(CAP_KILL)&&
> +			(uid != current_uid() || euid != current_euid())) {
> +		ckpt_err(ctx, ret, "image uids [%d, %d] don't match current "
> +				"process uids [%d, %d] and no CAP_KILL\n",
> +				uid, euid, current_uid(), current_euid());
> +		return ret;
> +	}
> +
> +	ret = -EINVAL;
> +	if (!valid_signal(h->f_owner_signum)) {
> +		ckpt_err(ctx, ret, "Invalid signum %d\n", h->f_owner_signum);
> +		return ret;
> +	}
> +	file->f_owner.signum = h->f_owner_signum;
> +
> +	rcu_read_lock();
> +
> +	/*
> +	 * If file had a non-NULL owner and we can't find the owner after
> +	 * restart, return error.
> +	 */
> +	pid = find_vpid(h->f_owner_pid);
> +	if (h->f_owner_pid&&  !pid)
> +		ret = -ESRCH;
> +	else {
> +		/*
> +		 * TODO: Do we need 'force' to be 1 here or can it be 0 ?
> +		 * 	 'force' is used to modify the owner, if one is
> +		 * 	 already set. Can it be set when we restart an
> +		 * 	 application ?
> +		 */
> +		ret = __f_setown(file, pid, h->f_owner_pid_type, uid, euid, 1);

__f_setown() does not check its pid_type argument - you need
to sanitize here, no ?

(and not that I expect the PIDTYPE_... will ever change, but -
possibly encode the PIDTYPE_... types into CKPT_PIDTYPE_... )

[...]

Oren.


  reply	other threads:[~2010-08-04 23:01 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-03 23:11 [PATCH 00/16][cr][v3]: C/R file owner, locks, leases Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 01/16][cr][v3]: Add uid, euid params to f_modown() Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 02/16][cr][v3]: Add uid, euid params to __f_setown() Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 03/16][cr][v3]: Checkpoint file-owner information Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 04/16][cr][v3]: Restore file_owner info Sukadev Bhattiprolu
2010-08-04 23:01   ` Oren Laadan [this message]
     [not found]   ` <1280877097-12377-5-git-send-email-sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2010-08-04 23:01     ` Oren Laadan
2010-08-03 23:11 ` [PATCH 05/16][cr][v3]: Move file_lock macros into linux/fs.h Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 06/16][cr][v3]: Checkpoint file-locks Sukadev Bhattiprolu
2010-08-04 23:26   ` Oren Laadan
     [not found]   ` <1280877097-12377-7-git-send-email-sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2010-08-04 23:26     ` Oren Laadan
2010-08-03 23:11 ` [PATCH 07/16][cr][v3]: Define flock_set() Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 08/16][cr][v3]: Define flock64_set() Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 09/16][cr][v3]: Restore file-locks Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 10/16][cr][v3]: Initialize ->fl_break_time to 0 Sukadev Bhattiprolu
     [not found] ` <1280877097-12377-1-git-send-email-sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2010-08-03 23:11   ` [PATCH 01/16][cr][v3]: Add uid, euid params to f_modown() Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 02/16][cr][v3]: Add uid, euid params to __f_setown() Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 03/16][cr][v3]: Checkpoint file-owner information Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 04/16][cr][v3]: Restore file_owner info Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 05/16][cr][v3]: Move file_lock macros into linux/fs.h Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 06/16][cr][v3]: Checkpoint file-locks Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 07/16][cr][v3]: Define flock_set() Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 08/16][cr][v3]: Define flock64_set() Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 09/16][cr][v3]: Restore file-locks Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 10/16][cr][v3]: Initialize ->fl_break_time to 0 Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 11/16][cr][v3]: Add ->fl_type_prev field Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 12/16][cr][v3]: Add ->fl_break_notified field Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 13/16][cr][v3]: Add jiffies_begin field to ckpt_ctx Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 14/16][cr][v3]: Checkpoint file-leases Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 15/16][cr][v3]: Define do_setlease() Sukadev Bhattiprolu
2010-08-03 23:11   ` [PATCH 16/16][cr][v3]: Restore file-leases Sukadev Bhattiprolu
2010-08-04 10:45   ` [PATCH 00/16][cr][v3]: C/R file owner, locks, leases Steven Whitehouse
2010-08-03 23:11 ` [PATCH 11/16][cr][v3]: Add ->fl_type_prev field Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 12/16][cr][v3]: Add ->fl_break_notified field Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 13/16][cr][v3]: Add jiffies_begin field to ckpt_ctx Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 14/16][cr][v3]: Checkpoint file-leases Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 15/16][cr][v3]: Define do_setlease() Sukadev Bhattiprolu
2010-08-03 23:11 ` [PATCH 16/16][cr][v3]: Restore file-leases Sukadev Bhattiprolu
2010-08-04 23:35   ` Oren Laadan
     [not found]   ` <1280877097-12377-17-git-send-email-sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2010-08-04 23:35     ` Oren Laadan
2010-08-04 10:45 ` [PATCH 00/16][cr][v3]: C/R file owner, locks, leases Steven Whitehouse
2010-08-04 17:26   ` Matt Helsley
2010-08-04 17:26   ` Matt Helsley
2010-08-04 18:03     ` Oren Laadan
     [not found]     ` <20100804172649.GM2927-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2010-08-04 18:03       ` Oren Laadan
2010-08-04 19:01   ` Sukadev Bhattiprolu
2010-08-04 19:16     ` Oren Laadan
     [not found]     ` <20100804190112.GA11571-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-08-04 19:16       ` Oren Laadan
2010-08-04 19:01   ` Sukadev Bhattiprolu

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=4C59F149.90606@cs.columbia.edu \
    --to=orenl@cs.columbia.edu \
    --cc=containers@lists.linux-foundation.org \
    --cc=danms@us.ibm.com \
    --cc=jamie@shareable.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=matthltc@us.ibm.com \
    --cc=serge@hallyn.com \
    --cc=sukadev@linux.vnet.ibm.com \
    /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.