mirror of
https://github.com/pgsty/minio.git
synced 2026-10-17 23:16:09 +03:00
fix: reset pooled NSScanner RPC responses to avoid stale usage data
NSScanner responses stream either a dataUsageEntry update or the final dataUsageCache. The grid framework recycles stream responses into a pool without resetting them, and the handler set only one field per response - so a recycled response still carried the Final (or Update) payload of an earlier scan. A remote node reading such a response accepted the stale final cache, corrupting bucket usage data across scanner cycles. Honor Recycler types when pooling stream responses, implement it for nsScannerResp, and clear the unset field at the response construction sites for defense in depth. Signed-off-by: Julien Laurenceau <julien.laurenceau@pepitedata.com>
This commit is contained in:
@@ -698,6 +698,11 @@ func (h *StreamTypeHandler[Payload, Req, Resp]) PutRequest(r Req) {
|
||||
// These should be returned by the caller.
|
||||
func (h *StreamTypeHandler[Payload, Req, Resp]) PutResponse(r Resp) {
|
||||
if r != h.nilResp {
|
||||
if rc, ok := any(r).(Recycler); ok {
|
||||
// Recycled stream responses must not leak fields
|
||||
// from a previous use into the next response.
|
||||
rc.Recycle()
|
||||
}
|
||||
//nolint:staticcheck // SA6002 IT IS A GENERIC VALUE! (and always a pointer)
|
||||
h.respPool.Put(r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user