Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'work.gfs2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull gfs2 setattr updates from Al Viro:
"Make it possible for filesystems to use a generic 'may_setattr()' and
switch gfs2 to using it"

* 'work.gfs2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
gfs2: Switch to may_setattr in gfs2_setattr
fs: Move notify_change permission checks into may_setattr

+35 -21
+31 -19
fs/attr.c
··· 249 249 } 250 250 EXPORT_SYMBOL(setattr_copy); 251 251 252 + int may_setattr(struct user_namespace *mnt_userns, struct inode *inode, 253 + unsigned int ia_valid) 254 + { 255 + int error; 256 + 257 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) { 258 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 259 + return -EPERM; 260 + } 261 + 262 + /* 263 + * If utimes(2) and friends are called with times == NULL (or both 264 + * times are UTIME_NOW), then we need to check for write permission 265 + */ 266 + if (ia_valid & ATTR_TOUCH) { 267 + if (IS_IMMUTABLE(inode)) 268 + return -EPERM; 269 + 270 + if (!inode_owner_or_capable(mnt_userns, inode)) { 271 + error = inode_permission(mnt_userns, inode, MAY_WRITE); 272 + if (error) 273 + return error; 274 + } 275 + } 276 + return 0; 277 + } 278 + EXPORT_SYMBOL(may_setattr); 279 + 252 280 /** 253 281 * notify_change - modify attributes of a filesytem object 254 282 * @mnt_userns: user namespace of the mount the inode was found from ··· 318 290 319 291 WARN_ON_ONCE(!inode_is_locked(inode)); 320 292 321 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) { 322 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 323 - return -EPERM; 324 - } 325 - 326 - /* 327 - * If utimes(2) and friends are called with times == NULL (or both 328 - * times are UTIME_NOW), then we need to check for write permission 329 - */ 330 - if (ia_valid & ATTR_TOUCH) { 331 - if (IS_IMMUTABLE(inode)) 332 - return -EPERM; 333 - 334 - if (!inode_owner_or_capable(mnt_userns, inode)) { 335 - error = inode_permission(mnt_userns, inode, MAY_WRITE); 336 - if (error) 337 - return error; 338 - } 339 - } 293 + error = may_setattr(mnt_userns, inode, ia_valid); 294 + if (error) 295 + return error; 340 296 341 297 if ((ia_valid & ATTR_MODE)) { 342 298 umode_t amode = attr->ia_mode;
+2 -2
fs/gfs2/inode.c
··· 1985 1985 if (error) 1986 1986 goto out; 1987 1987 1988 - error = -EPERM; 1989 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 1988 + error = may_setattr(&init_user_ns, inode, attr->ia_valid); 1989 + if (error) 1990 1990 goto error; 1991 1991 1992 1992 error = setattr_prepare(&init_user_ns, dentry, attr);
+2
include/linux/fs.h
··· 3439 3439 #define buffer_migrate_page_norefs NULL 3440 3440 #endif 3441 3441 3442 + int may_setattr(struct user_namespace *mnt_userns, struct inode *inode, 3443 + unsigned int ia_valid); 3442 3444 int setattr_prepare(struct user_namespace *, struct dentry *, struct iattr *); 3443 3445 extern int inode_newsize_ok(const struct inode *, loff_t offset); 3444 3446 void setattr_copy(struct user_namespace *, struct inode *inode,