From: "Aneesh Kumar K.V" Subject: Re: [PATCH -V6 09/26] vfs: Add delete child and delete self permission flags Date: Fri, 09 Sep 2011 10:49:19 +0530 Message-ID: <87r53q47jc.fsf@skywalker.in.ibm.com> References: <1315243548-18664-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <1315243548-18664-10-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <20110907203916.GE8074@fieldses.org> <87ipp35qjx.fsf@skywalker.in.ibm.com> <20110908200754.GB17215@fieldses.org> <20110908220246.GD17215@fieldses.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: agruen-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: "J. Bruce Fields" Return-path: In-Reply-To: <20110908220246.GD17215-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org> Sender: linux-nfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On Thu, 8 Sep 2011 18:02:46 -0400, "J. Bruce Fields" wrote: > On Thu, Sep 08, 2011 at 04:07:54PM -0400, J. Bruce Fields wrote: > > On Thu, Sep 08, 2011 at 03:00:58PM +0530, Aneesh Kumar K.V wrote: > > > On Wed, 7 Sep 2011 16:39:16 -0400, "J. Bruce Fields" wrote: > > > > On Mon, Sep 05, 2011 at 10:55:31PM +0530, Aneesh Kumar K.V wrote: > > > > > +static int may_delete(struct inode *dir, struct dentry *victim, > > > > > + int isdir, int replace) > > > > > { > > > > > - int error; > > > > > + int mask, error, is_sticky; > > > > > + struct inode *inode = victim->d_inode; > > > > > > > > > > - if (!victim->d_inode) > > > > > + if (!inode) > > > > > return -ENOENT; > > > > > > > > > > BUG_ON(victim->d_parent->d_inode != dir); > > > > > audit_inode_child(victim, dir); > > > > > > > > > > - error = inode_permission(dir, MAY_WRITE | MAY_EXEC); > > > > > + mask = MAY_WRITE | MAY_EXEC | MAY_DELETE_CHILD; > > > > > + if (replace) > > > > > + mask |= S_ISDIR(inode->i_mode) ? > > > > > + MAY_CREATE_DIR : MAY_CREATE_FILE; > > > > > > > > I'm having trouble understanding this next bit: > > > > > > > > > + is_sticky = check_sticky(dir, inode); > > > > > + error = inode_permission(dir, mask); > > > > > + if ((error || is_sticky) && IS_RICHACL(inode) && > > > > > + !inode_permission(dir, mask & ~(MAY_WRITE | MAY_DELETE_CHILD)) && > > > > > + !inode_permission(inode, MAY_DELETE_SELF)) > > > > > + error = 0; > > > > > > > > OK, so we can ignore the lack of write or delete permissions on the > > > > parent if we have delete_self permissions on the child. I guess that's > > > > right. > > > > > > > > Why the "|| is_sticky" above? > > > > > > > > Is there some less complicated why to write this? > > > > > > we removed the ns_capable check out of check_sticky, because we don't > > > want to do capability check when richacl allows access. We also want to > > > make sure that even if mode bits allow access (inode_permission(dir, mask)) > > > if sticky bit is set we do additional check. > > > > Why are the two inode_permissions ANDed? The windows semantics are that > > you can delete if you have MAY_DELETE_CHILD *or* MAY_DELETE_SELF. > > Either way, those conditions are just really hard to follow. Could you > simplify the logic, add comments, maybe move the richacl stuff into a > little helper function? > > Also, a nit: > > > > > > + !inode_permission(dir, mask & ~(MAY_WRITE | MAY_DELETE_CHILD)) && > > The way you calculated mask above it always includes MAY_WRITE and > MAY_DELETE_CHILD, so the above is equivalent to just > > !inode_permission(dir, MAY_WRITE | MAY_DELETE_CHILD) && > > isn't it? > I guess i can simplify it as !inode_permission(dir, MAY_EXEC | replace_mask) -aneesh -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html