1170static int mount_is_safe(struct path *path)
1171{
1172 if (capable(CAP_SYS_ADMIN))
1173 return 0;
1174 return -EPERM;
1175#ifdef notyet
1176 if (S_ISLNK(path->dentry->d_inode->i_mode))
1177 return -EPERM;
1178 if (path->dentry->d_inode->i_mode & S_ISVTX) {
1179 if (current->uid != path->dentry->d_inode->i_uid)
1180 return -EPERM;
1181 }
1182 if (inode_permission(path->dentry->d_inode, MAY_WRITE))
1183 return -EPERM;
1184 return 0;
1185#endif
1186}
1187
1188struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
1189 int flag)
1190{
1191 struct vfsmount *res, *p, *q, *r, *s;
1192 struct path path;
1193
1194 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt))
1195 return NULL;
1196
1197 res = q = clone_mnt(mnt, dentry, flag);
1198 if (!q)
1199 goto Enomem;
1200 q->mnt_mountpoint = mnt->mnt_mountpoint;
1201
1202 p = mnt;
1203 list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) {
1204 if (!is_subdir(r->mnt_mountpoint, dentry))
1205 continue;
1206
1207 for (s = r; s; s = next_mnt(s, r)) {
1208 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(s)) {
1209 s = skip_mnt_tree(s);
1210 continue;