- patches.apparmor/remove_suid_new_case_in_2.6.22.diff: Merge fix.
[linux-flexiantxendom0-3.2.10.git] / fs / open.c
index db692c1..1175e23 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -7,7 +7,6 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/file.h>
-#include <linux/smp_lock.h>
 #include <linux/quotaops.h>
 #include <linux/fsnotify.h>
 #include <linux/module.h>
@@ -199,6 +198,7 @@ int do_truncate(struct dentry *dentry, struct vfsmount *mnt, loff_t length,
 {
        int err;
        struct iattr newattrs;
+       struct path path = { .mnt = mnt, .dentry = dentry };
 
        /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
        if (length < 0)
@@ -211,6 +211,9 @@ int do_truncate(struct dentry *dentry, struct vfsmount *mnt, loff_t length,
                newattrs.ia_valid |= ATTR_FILE;
        }
 
+       /* Remove suid/sgid on truncate too */
+       newattrs.ia_valid |= should_remove_suid(&path);
+
        mutex_lock(&dentry->d_inode->i_mutex);
        err = notify_change(dentry, mnt, &newattrs);
        mutex_unlock(&dentry->d_inode->i_mutex);