mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
kernel: unshare a network namespace without taking Task.mu
t.netns is an atomic pointer so it should not be a problem for readers. As for writers, only task can change its network namespace. Reported-by: syzbot+8e29d377b851dcdfbca2@syzkaller.appspotmail.com Reported-by: syzbot+9ffa998047fce0c57473@syzkaller.appspotmail.com Reported-by: syzbot+c1c75367b97f5e31a12f@syzkaller.appspotmail.com PiperOrigin-RevId: 542384765
This commit is contained in:
@@ -466,17 +466,16 @@ func (t *Task) Unshare(flags int32) error {
|
||||
}
|
||||
t.childPIDNamespace = t.tg.pidns.NewChild(t.UserNamespace())
|
||||
}
|
||||
t.mu.Lock()
|
||||
// Can't defer unlock: DecRefs must occur without holding t.mu.
|
||||
var oldNETNS *inet.Namespace
|
||||
if flags&linux.CLONE_NEWNET != 0 {
|
||||
if !haveCapSysAdmin {
|
||||
t.mu.Unlock()
|
||||
return linuxerr.EPERM
|
||||
}
|
||||
oldNETNS = t.netns.Load()
|
||||
t.netns.Store(inet.NewNamespace(t.netns.Load()))
|
||||
}
|
||||
t.mu.Lock()
|
||||
// Can't defer unlock: DecRefs must occur without holding t.mu.
|
||||
if flags&linux.CLONE_NEWUTS != 0 {
|
||||
if !haveCapSysAdmin {
|
||||
t.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user