From e1ba7ab68436ad88901d3bf282646ea59ccedd82 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 11 Nov 2022 21:45:55 +0100 Subject: [PATCH] lock: Don't copy the lock when checking for process existence The lock test creates a lock and checks that it is not stale. This also tests whether the corresponding process still exists. However, it is possible that the lock is refreshed concurrently, which updates the lock timestamp. Calling `processExists()` with a value receiver, however, creates an unsynchronized copy of this field. Thus call the method using a pointer receiver. --- internal/restic/lock_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/restic/lock_unix.go b/internal/restic/lock_unix.go index c11bc4ca7..3f426ae32 100644 --- a/internal/restic/lock_unix.go +++ b/internal/restic/lock_unix.go @@ -29,7 +29,7 @@ func uidGidInt(u *user.User) (uid, gid uint32, err error) { // checkProcess will check if the process retaining the lock // exists and responds to SIGHUP signal. // Returns true if the process exists and responds. -func (l Lock) processExists() bool { +func (l *Lock) processExists() bool { proc, err := os.FindProcess(l.PID) if err != nil { debug.Log("error searching for process %d: %v\n", l.PID, err)