From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:42183 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932130AbcFOOVG (ORCPT ); Wed, 15 Jun 2016 10:21:06 -0400 Date: Wed, 15 Jun 2016 10:20:59 -0400 From: Vivek Goyal To: Miklos Szeredi Cc: Stephen Smalley , "linux-unionfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ovl: fix uid/gid when creating over whiteout Message-ID: <20160615142059.GC19388@redhat.com> References: <20160615133002.GA11993@veci.piliscsaba.szeredi.hu> <20160615140151.GB19388@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Jun 15, 2016 at 04:09:47PM +0200, Miklos Szeredi wrote: > On Wed, Jun 15, 2016 at 4:01 PM, Vivek Goyal wrote: > > On Wed, Jun 15, 2016 at 03:30:02PM +0200, Miklos Szeredi wrote: > > >> --- a/fs/overlayfs/dir.c > >> +++ b/fs/overlayfs/dir.c > >> @@ -405,12 +405,21 @@ static int ovl_create_or_link(struct den > >> err = ovl_create_upper(dentry, inode, &stat, link, hardlink); > >> } else { > >> const struct cred *old_cred; > >> + struct cred *override_cred; > >> > >> old_cred = ovl_override_creds(dentry->d_sb); > >> > >> - err = ovl_create_over_whiteout(dentry, inode, &stat, link, > >> - hardlink); > >> + err = -ENOMEM; > >> + override_cred = prepare_creds(); > >> + if (override_cred) { > >> + override_cred->fsuid = old_cred->fsuid; > >> + override_cred->fsgid = old_cred->fsgid; > > > > Hi Miklos, > > > > I am wondering if we are switching to tasks's ->fsuid and ->fsgid too > > early. ovl_create_over_whiteout() calls ovl_lookup_temp(workdir) and > > IIUC, task might not have permission to do lookup in workdir. > > > > Should we switch to this override_cred, just before ovl_create_real() > > so that task ->fsuid and ->fsgid are used only for creation purposes > > only. > > For lookup in workdir only CAP_DAC_OVERRIDE should matter, the actual > value of the fsuid and fsgid should be irrelevant (user, group and > others all have zero permission on workdir). Ok. Agreed that CAP_DAC_OVERRIDE should do. Thanks Vivek