Refactor NetStateProvider to use new SyscallEvent and io rq objects
authorAntoine Busque <antoinebusque@gmail.com>
Tue, 31 Mar 2015 20:49:16 +0000 (16:49 -0400)
committerAntoine Busque <antoinebusque@gmail.com>
Tue, 31 Mar 2015 20:49:16 +0000 (16:49 -0400)
linuxautomaton/linuxautomaton/net.py

index 37ffe7e8123c6eec66332afab3c39a695e2044da..f670c1ba9bc2450dbb714cf3617355034fba2259 100644 (file)
@@ -52,13 +52,20 @@ class NetStateProvider(sp.StateProvider):
         if cpu.current_tid is None:
             return
 
-        current_syscall = self._state.tids[cpu.current_tid].current_syscall
-        if not current_syscall:
+        proc = self._state.tids[cpu.current_tid]
+        current_syscall = proc.current_syscall
+        if current_syscall is None:
             return
 
-        if current_syscall['name'] in sv.SyscallConsts.WRITE_SYSCALLS and \
-           current_syscall['fd'].fdtype == sv.FDType.unknown:
-            current_syscall['fd'].fdtype = sv.FDType.maybe_net
+        if proc.pid is not None and proc.pid != proc.tid:
+            proc = self._state.tids[proc.pid]
+
+        if current_syscall.name in sv.SyscallConsts.WRITE_SYSCALLS:
+            # TODO: find a way to set fd_type on the write rq to allow
+            # setting FD Type if FD hasn't yet been created
+            fd = current_syscall.io_rq.fd
+            if fd in proc.fds and proc.fds[fd].fd_type == sv.FDType.unknown:
+                proc.fds[fd].fd_type = sv.FDType.maybe_net
 
     def _process_netif_receive_skb(self, event):
         self._state.send_notification_cb('netif_receive_skb',
This page took 0.02403 seconds and 5 git commands to generate.