backport upstream 25c5ffe