@@ -9,11 +9,13 @@ import (
99
1010 "github.com/aquasecurity/tracee/pkg/errfmt"
1111 "github.com/aquasecurity/tracee/pkg/logger"
12+ traceetime "github.com/aquasecurity/tracee/pkg/time"
1213 "github.com/aquasecurity/tracee/pkg/utils"
1314 "github.com/aquasecurity/tracee/pkg/utils/proc"
1415)
1516
16- const debugMsgs = false // debug messages can be too verbose, so they are disabled by default
17+ const debugMsgs = false // debug messages can be too verbose, so they are disabled by default
18+ const ProcfsClockId = traceetime .CLOCK_BOOTTIME // Procfs uses jiffies, which are based on boottime
1719
1820const (
1921 AllPIDs = 0
@@ -107,7 +109,7 @@ func getProcessByPID(pt *ProcessTree, givenPid int) (*Process, error) {
107109 return nil , errfmt .Errorf ("%v" , err )
108110 }
109111
110- startTimeNs := utils .ClockTicksToNsSinceBootTime (stat .StartTime )
112+ startTimeNs := traceetime .ClockTicksToNsSinceBootTime (stat .StartTime )
111113 hash := utils .HashTaskID (uint32 (status .GetPid ()), startTimeNs ) // status pid == tid
112114
113115 return pt .GetOrCreateProcessByHash (hash ), nil
@@ -149,7 +151,7 @@ func dealWithProc(pt *ProcessTree, givenPid int) error {
149151 }
150152
151153 // process hash
152- startTimeNs := utils .ClockTicksToNsSinceBootTime (start )
154+ startTimeNs := traceetime .ClockTicksToNsSinceBootTime (start )
153155 hash := utils .HashTaskID (uint32 (pid ), startTimeNs )
154156
155157 // update tree for the given process
@@ -165,6 +167,8 @@ func dealWithProc(pt *ProcessTree, givenPid int) error {
165167 }
166168 }
167169
170+ procfsTimeStamp := uint64 (pt .timeNormalizer .NormalizeTime (int (startTimeNs )))
171+
168172 procInfo .SetFeedAt (
169173 TaskInfoFeed {
170174 Name : name , // command name (add "procfs+" to debug if needed)
@@ -176,9 +180,9 @@ func dealWithProc(pt *ProcessTree, givenPid int) error {
176180 NsPPid : nsppid , // status: nsppid == nsppid
177181 Uid : - 1 , // do not change the parent uid
178182 Gid : - 1 , // do not change the parent gid
179- StartTimeNS : startTimeNs ,
183+ StartTimeNS : procfsTimeStamp ,
180184 },
181- utils . NsSinceBootTimeToTime ( uint64 ( start ) ), // try to be the first changelog entry
185+ traceetime . NsSinceEpochToTime ( procfsTimeStamp ), // try to be the first changelog entry
182186 )
183187
184188 // TODO: Update executable with information from /proc/<pid>/exe
@@ -222,7 +226,7 @@ func dealWithThread(pt *ProcessTree, givenPid int, givenTid int) error {
222226 }
223227
224228 // thread hash
225- startTimeNs := utils .ClockTicksToNsSinceBootTime (start )
229+ startTimeNs := traceetime .ClockTicksToNsSinceBootTime (start )
226230 hash := utils .HashTaskID (uint32 (pid ), startTimeNs )
227231
228232 // update tree for the given thread
@@ -234,6 +238,8 @@ func dealWithThread(pt *ProcessTree, givenPid int, givenTid int) error {
234238 return nil
235239 }
236240
241+ procfsTimeStamp := uint64 (pt .timeNormalizer .NormalizeTime (int (startTimeNs )))
242+
237243 threadInfo .SetFeedAt (
238244 TaskInfoFeed {
239245 Name : name , // command name (add "procfs+" to debug if needed)
@@ -245,9 +251,9 @@ func dealWithThread(pt *ProcessTree, givenPid int, givenTid int) error {
245251 NsPPid : nsppid , // status: nsppid == nsppid
246252 Uid : - 1 , // do not change the parent uid
247253 Gid : - 1 , // do not change the parent gid
248- StartTimeNS : startTimeNs ,
254+ StartTimeNS : procfsTimeStamp ,
249255 },
250- utils . NsSinceBootTimeToTime ( uint64 ( start ) ), // try to be the first changelog entry
256+ traceetime . NsSinceEpochToTime ( procfsTimeStamp ), // try to be the first changelog entry
251257 )
252258
253259 // thread group leader (leader tid is the same as the thread's pid, so we can find it)
0 commit comments