mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Don't leak dentries returned by sockfs.NewDentry().
PiperOrigin-RevId: 334263322
This commit is contained in:
@@ -52,6 +52,7 @@ var _ = socket.SocketVFS2(&socketVFS2{})
|
||||
func newVFS2Socket(t *kernel.Task, family int, stype linux.SockType, protocol int, fd int, flags uint32) (*vfs.FileDescription, *syserr.Error) {
|
||||
mnt := t.Kernel().SocketMount()
|
||||
d := sockfs.NewDentry(t.Credentials(), mnt)
|
||||
defer d.DecRef(t)
|
||||
|
||||
s := &socketVFS2{
|
||||
socketOpsCommon: socketOpsCommon{
|
||||
|
||||
@@ -52,6 +52,7 @@ func (*socketProviderVFS2) Socket(t *kernel.Task, stype linux.SockType, protocol
|
||||
vfsfd := &s.vfsfd
|
||||
mnt := t.Kernel().SocketMount()
|
||||
d := sockfs.NewDentry(t.Credentials(), mnt)
|
||||
defer d.DecRef(t)
|
||||
if err := vfsfd.Init(s, linux.O_RDWR, mnt, d, &vfs.FileDescriptionOptions{
|
||||
DenyPRead: true,
|
||||
DenyPWrite: true,
|
||||
|
||||
@@ -55,6 +55,7 @@ var _ = socket.SocketVFS2(&SocketVFS2{})
|
||||
func NewSockfsFile(t *kernel.Task, ep transport.Endpoint, stype linux.SockType) (*vfs.FileDescription, *syserr.Error) {
|
||||
mnt := t.Kernel().SocketMount()
|
||||
d := sockfs.NewDentry(t.Credentials(), mnt)
|
||||
defer d.DecRef(t)
|
||||
|
||||
fd, err := NewFileDescription(ep, stype, linux.O_RDWR, mnt, d, &vfs.FileLocks{})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user