From 8b0a9fe360eb3d6631aab5d1b36d536b7381a1e6 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 6 Jan 2006 00:19:59 -0800 Subject: [PATCH] --- yaml --- r: 16512 b: refs/heads/master c: 9f708e40fe040e79f6c393a282f0701c9f8dc174 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/nfsd/vfs.c | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index dbae5ff88b5b..b217a9787cb6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a334de28665b14f0a33df82699fa9a78cfeedf31 +refs/heads/master: 9f708e40fe040e79f6c393a282f0701c9f8dc174 diff --git a/trunk/fs/nfsd/vfs.c b/trunk/fs/nfsd/vfs.c index f83ab4cf4265..df4019f04560 100644 --- a/trunk/fs/nfsd/vfs.c +++ b/trunk/fs/nfsd/vfs.c @@ -880,6 +880,16 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, return err; } +static void kill_suid(struct dentry *dentry) +{ + struct iattr ia; + ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID; + + down(&dentry->d_inode->i_sem); + notify_change(dentry, &ia); + up(&dentry->d_inode->i_sem); +} + static inline int nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, loff_t offset, struct kvec *vec, int vlen, @@ -933,14 +943,8 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, } /* clear setuid/setgid flag after write */ - if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) { - struct iattr ia; - ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID; - - down(&inode->i_sem); - notify_change(dentry, &ia); - up(&inode->i_sem); - } + if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) + kill_suid(dentry); if (err >= 0 && stable) { static ino_t last_ino;