diff options
-rw-r--r-- | src/runtime/map.go | 5 | ||||
-rw-r--r-- | src/runtime/map_fast32.go | 5 | ||||
-rw-r--r-- | src/runtime/map_fast64.go | 5 | ||||
-rw-r--r-- | src/runtime/map_faststr.go | 5 |
4 files changed, 20 insertions, 0 deletions
diff --git a/src/runtime/map.go b/src/runtime/map.go index 22a0241f56..8be1d3991d 100644 --- a/src/runtime/map.go +++ b/src/runtime/map.go @@ -780,6 +780,11 @@ search: } notLast: h.count-- + // Reset the hash seed to make it more difficult for attackers to + // repeatedly trigger hash collisions. See issue 25237. + if h.count == 0 { + h.hash0 = fastrand() + } break search } } diff --git a/src/runtime/map_fast32.go b/src/runtime/map_fast32.go index d035ed0386..d80f5eac78 100644 --- a/src/runtime/map_fast32.go +++ b/src/runtime/map_fast32.go @@ -344,6 +344,11 @@ search: } notLast: h.count-- + // Reset the hash seed to make it more difficult for attackers to + // repeatedly trigger hash collisions. See issue 25237. + if h.count == 0 { + h.hash0 = fastrand() + } break search } } diff --git a/src/runtime/map_fast64.go b/src/runtime/map_fast64.go index f1f3927598..3bc84bbdd3 100644 --- a/src/runtime/map_fast64.go +++ b/src/runtime/map_fast64.go @@ -346,6 +346,11 @@ search: } notLast: h.count-- + // Reset the hash seed to make it more difficult for attackers to + // repeatedly trigger hash collisions. See issue 25237. + if h.count == 0 { + h.hash0 = fastrand() + } break search } } diff --git a/src/runtime/map_faststr.go b/src/runtime/map_faststr.go index 069cda6554..108c502394 100644 --- a/src/runtime/map_faststr.go +++ b/src/runtime/map_faststr.go @@ -369,6 +369,11 @@ search: } notLast: h.count-- + // Reset the hash seed to make it more difficult for attackers to + // repeatedly trigger hash collisions. See issue 25237. + if h.count == 0 { + h.hash0 = fastrand() + } break search } } |