@@ -57,7 +57,8 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
57
57
newattrs .ia_valid |= ret | ATTR_FORCE ;
58
58
59
59
mutex_lock (& dentry -> d_inode -> i_mutex );
60
- ret = notify_change (dentry , & newattrs );
60
+ /* Note any delegations or leases have already been broken: */
61
+ ret = notify_change (dentry , & newattrs , NULL );
61
62
mutex_unlock (& dentry -> d_inode -> i_mutex );
62
63
return ret ;
63
64
}
@@ -464,21 +465,28 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
464
465
static int chmod_common (struct path * path , umode_t mode )
465
466
{
466
467
struct inode * inode = path -> dentry -> d_inode ;
468
+ struct inode * delegated_inode = NULL ;
467
469
struct iattr newattrs ;
468
470
int error ;
469
471
470
472
error = mnt_want_write (path -> mnt );
471
473
if (error )
472
474
return error ;
475
+ retry_deleg :
473
476
mutex_lock (& inode -> i_mutex );
474
477
error = security_path_chmod (path , mode );
475
478
if (error )
476
479
goto out_unlock ;
477
480
newattrs .ia_mode = (mode & S_IALLUGO ) | (inode -> i_mode & ~S_IALLUGO );
478
481
newattrs .ia_valid = ATTR_MODE | ATTR_CTIME ;
479
- error = notify_change (path -> dentry , & newattrs );
482
+ error = notify_change (path -> dentry , & newattrs , & delegated_inode );
480
483
out_unlock :
481
484
mutex_unlock (& inode -> i_mutex );
485
+ if (delegated_inode ) {
486
+ error = break_deleg_wait (& delegated_inode );
487
+ if (!error )
488
+ goto retry_deleg ;
489
+ }
482
490
mnt_drop_write (path -> mnt );
483
491
return error ;
484
492
}
@@ -522,6 +530,7 @@ SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode)
522
530
static int chown_common (struct path * path , uid_t user , gid_t group )
523
531
{
524
532
struct inode * inode = path -> dentry -> d_inode ;
533
+ struct inode * delegated_inode = NULL ;
525
534
int error ;
526
535
struct iattr newattrs ;
527
536
kuid_t uid ;
@@ -546,12 +555,17 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
546
555
if (!S_ISDIR (inode -> i_mode ))
547
556
newattrs .ia_valid |=
548
557
ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV ;
558
+ retry_deleg :
549
559
mutex_lock (& inode -> i_mutex );
550
560
error = security_path_chown (path , uid , gid );
551
561
if (!error )
552
- error = notify_change (path -> dentry , & newattrs );
562
+ error = notify_change (path -> dentry , & newattrs , & delegated_inode );
553
563
mutex_unlock (& inode -> i_mutex );
554
-
564
+ if (delegated_inode ) {
565
+ error = break_deleg_wait (& delegated_inode );
566
+ if (!error )
567
+ goto retry_deleg ;
568
+ }
555
569
return error ;
556
570
}
557
571
0 commit comments