mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Adjust error handling in kernfs rename.
Read-only directories (e.g. under /sys, /proc) should return EPERM for rename. PiperOrigin-RevId: 339979022
This commit is contained in:
@@ -578,13 +578,18 @@ func (o *OrderedChildren) RmDir(ctx context.Context, name string, child Inode) e
|
||||
//
|
||||
// Postcondition: reference on any replaced dentry transferred to caller.
|
||||
func (o *OrderedChildren) Rename(ctx context.Context, oldname, newname string, child, dstDir Inode) error {
|
||||
dst, ok := dstDir.(interface{}).(*OrderedChildren)
|
||||
if !ok {
|
||||
return syserror.ENODEV
|
||||
}
|
||||
if !o.writable || !dst.writable {
|
||||
if !o.writable {
|
||||
return syserror.EPERM
|
||||
}
|
||||
|
||||
dst, ok := dstDir.(interface{}).(*OrderedChildren)
|
||||
if !ok {
|
||||
return syserror.EXDEV
|
||||
}
|
||||
if !dst.writable {
|
||||
return syserror.EPERM
|
||||
}
|
||||
|
||||
// Note: There's a potential deadlock below if concurrent calls to Rename
|
||||
// refer to the same src and dst directories in reverse. We avoid any
|
||||
// ordering issues because the caller is required to serialize concurrent
|
||||
|
||||
Reference in New Issue
Block a user