From 8cd607447ebc7ed2627e825fca673bb5b45f6ad4 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Tue, 7 Dec 2021 15:05:19 +0100 Subject: [PATCH 1/2] routing: fix memory corruption in MC store Since bbolt returns references to internally stored data when storing locally it's best to copy the byte slices returned or alternatively convert them to string (which also makes a copy) to avoid crashes casued by memory corruption. --- routing/missioncontrol_store.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/routing/missioncontrol_store.go b/routing/missioncontrol_store.go index 193f7d13a..27be86821 100644 --- a/routing/missioncontrol_store.go +++ b/routing/missioncontrol_store.go @@ -82,7 +82,7 @@ func newMissionControlStore(db kvdb.Backend, maxRecords int, // difference when updating the DB state. c := resultsBucket.ReadCursor() for k, _ := c.First(); k != nil; k, _ = c.Next() { - keys.PushBack(k) + keys.PushBack(string(k)) keysMap[string(k)] = struct{}{} } @@ -334,7 +334,7 @@ func (b *missionControlStore) storeResults() error { return err } - keys.PushBack(k) + keys.PushBack(string(k)) keysMap[string(k)] = struct{}{} } @@ -345,14 +345,14 @@ func (b *missionControlStore) storeResults() error { } front := keys.Front() - key := front.Value.([]byte) + key := front.Value.(string) - if err := bucket.Delete(key); err != nil { + if err := bucket.Delete([]byte(key)); err != nil { return err } keys.Remove(front) - delete(keysMap, string(key)) + delete(keysMap, key) } return nil From 5efbb2b0ff31af7ed25a4e50251e02fccd3656fb Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Tue, 7 Dec 2021 15:06:56 +0100 Subject: [PATCH 2/2] docs: update release notes --- docs/release-notes/release-notes-0.14.2.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/release-notes-0.14.2.md b/docs/release-notes/release-notes-0.14.2.md index f5d18c82e..939b6e4a7 100644 --- a/docs/release-notes/release-notes-0.14.2.md +++ b/docs/release-notes/release-notes-0.14.2.md @@ -17,6 +17,9 @@ * [Add json flag to trackpayment](https://github.com/lightningnetwork/lnd/pull/6060) +* [Fix memory corruption in Mission Control + Store](https://github.com/lightningnetwork/lnd/pull/6068) + ## RPC Server * [ChanStatusFlags is now