From mboxrd@z Thu Jan 1 00:00:00 1970 From: OGAWA Hirofumi Subject: Re: [patch 12/12] vfs: allow file truncations when both suid and write permissions set Date: Fri, 07 Aug 2009 11:32:52 +0900 Message-ID: <87ocqs2w17.fsf@devron.myhome.or.jp> References: <200908062310.n76NAIEo013014@imap1.linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, amwang@redhat.com, eparis@redhat.com, esandeen@redhat.com, eteo@redhat.com To: akpm@linux-foundation.org Return-path: Received: from mail.parknet.ad.jp ([210.171.162.6]:34638 "EHLO mail.officemail.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752166AbZHGCcz (ORCPT ); Thu, 6 Aug 2009 22:32:55 -0400 In-Reply-To: <200908062310.n76NAIEo013014@imap1.linux-foundation.org> (akpm@linux-foundation.org's message of "Thu, 06 Aug 2009 16:10:18 -0700") Sender: linux-fsdevel-owner@vger.kernel.org List-ID: akpm@linux-foundation.org writes: > diff -puN fs/open.c~vfs-allow-file-truncations-when-both-suid-and-write-permissions-set fs/open.c > --- a/fs/open.c~vfs-allow-file-truncations-when-both-suid-and-write-permissions-set > +++ a/fs/open.c > @@ -213,11 +213,15 @@ int do_truncate(struct dentry *dentry, l > newattrs.ia_valid |= ATTR_FILE; > } > > + mutex_lock(&dentry->d_inode->i_mutex); > /* Remove suid/sgid on truncate too */ > - newattrs.ia_valid |= should_remove_suid(dentry); > + err = dentry_remove_suid(dentry); > + if (err) > + goto unlock; Can't we use ATTR_FORCE for this? Because this calls notify_change() twice, and I guess this removes s[ug]id even if vmtruncate() (or in future ->truncate() may return error) or something returned error. I think it would not be good behavior. Thanks. > - mutex_lock(&dentry->d_inode->i_mutex); > err = notify_change(dentry, &newattrs); > + > + unlock: > mutex_unlock(&dentry->d_inode->i_mutex); > return err; > } -- OGAWA Hirofumi