Skip to content

x/crypto/curve25519: MOVQ global clobbers R15 when dynamically linking #18820

@crawshaw

Description

@crawshaw

The functions ladderstep, mul, and square load global values.

When dynamically linking on amd64, a the load uses R15 as a temporary. Unfortunately, these functions try to use R15 across these loads.

For example,

MOVQ ·REDMASK51(SB),DX

turns into MOVQ 0xABCD(IP), DX typically, but under the compiler's dynamic linking mode it becomes

MOVQ 0xABCD(IP), R15
MOVQ 0(R15), DX

The unit tests for this package (and crypto/tls which depends on this) hang under -buildmode=shared and fail under -buildmode=plugin:

curve25519_test.go:27: incorrect result: got 469423c8d7cc27bb36c7096de54d38d285740efa69594c1f98f49b113dcc7a19, want 89161fde887b2b53de549af483940106ecc114d6982daa98256de23bdf77661a

cc @mwhudson

@bradfitz Any idea who owns this code? I'd like their opinion before touching it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions