golang/src/net/textproto
Cherry Mui c4772d30bf cmd/link: disallow pull-only linknames
As mentioned in CL 584598, linkname is a mechanism that, when
abused, can break API integrity and even safety of Go programs.
CL 584598 is a first step to restrict the use of linknames, by
implementing a blocklist. This CL takes a step further, tightening
up the restriction by allowing linkname references ("pull") only
when the definition side explicitly opts into it, by having a
linkname on the definition (possibly to itself). This way, it is at
least clear on the definition side that the symbol, despite being
unexported, is accessed outside of the package. Unexported symbols
without linkname can now be actually private. This is similar to
the symbol visibility rule used by gccgo for years (which defines
unexported non-linknamed symbols as C static symbols).

As there can be pull-only linknames in the wild that may be broken
by this change, we currently only enforce this rule for symbols
defined in the standard library. Push linknames are added in the
standard library to allow things build.

Linkname references to external (non-Go) symbols are still allowed,
as their visibility is controlled by the C symbol visibility rules
and enforced by the C (static or dynamic) linker.

Assembly symbols are treated similar to linknamed symbols.

This is controlled by -checklinkname linker flag, currently not
enabled by default. A follow-up CL will enable it by default.

Change-Id: I07344f5c7a02124dbbef0fbc8fec3b666a4b2b0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/585358
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2024-05-15 19:57:43 +00:00
..
header.go net: add available godoc link 2024-01-10 03:29:50 +00:00
header_test.go net/http, net/textproto: add Header.Values, MIMEHeader.Values methods 2019-10-17 18:21:01 +00:00
pipeline.go net/textproto, sync: unlock mutexes appropriately before panics 2020-04-08 16:19:51 +00:00
reader.go cmd/link: disallow pull-only linknames 2024-05-15 19:57:43 +00:00
reader_test.go net/textproto, mime/multipart: avoid unbounded read in MIME header 2024-03-05 18:31:56 +00:00
textproto.go net: add available godoc link 2024-01-10 03:29:50 +00:00
writer.go net: add available godoc link 2024-01-10 03:29:50 +00:00
writer_test.go net/textproto: use strings.Builder 2022-09-07 13:55:46 +00:00