Web Analytics

Go 安全新提案:runtime/secret 能否终结密钥残留的噩梦?

本文永久链接 – https://tonybai.com/2025/12/05/proposal-runtime-secret 大家好,我是Tony Bai。 “如果你的服务器被攻破,攻击者能否拿到内存中残留的私钥,进而解密过去两年的所有通信记录?” 这是一个让所有安全工程师夜不能寐的问题。为了防止这种情况,现代加密协议(如 TLS 1.3, WireGuard)都强调前向保密 (Forward Secrecy):使用临时的、一次性的密钥,并在使用后立即销毁。 ...

December 5, 2025 · 6 min · Tony Bai

理解unsafe-assume-no-moving-gc包

本文永久链接 – https://tonybai.com/2023/04/16/understanding-unsafe-assume-no-moving-gc 1. 背景 在之前的《Go与神经网络:张量计算》一文中,不知道大家是否发现了,所有例子代码执行时,前面都加了一个环境变量ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH,就像下面这样: $ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH=go1.20 go run tensor.go 这是怎么回事儿呢?如果不加上这个环境变量会发生什么呢?我们来试试: // https://github.com/bigwhite/experiments/blob/master/go-and-nn/tensor-operations/tensor.go $go run tensor.go panic: Something in this program imports go4.org/unsafe/assume-no-moving-gc to declare that it assumes a non-moving garbage collector, but your version of go4.org/unsafe/assume-no-moving-gc hasn't been updated to assert that it's safe against the go1.20 runtime. If you want to risk it, run with environment variable ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH=go1.20 set. Notably, if go1.20 adds a moving garbage collector, this program is unsafe to use. goroutine 1 [running]: go4.org/unsafe/assume-no-moving-gc.init.0() /Users/tonybai/Go/pkg/mod/go4.org/unsafe/assume-no-moving-gc@v0.0.0-20220617031537-928513b29760/untested.go:25 +0x1ba exit status 2 我们看到,程序panic了!我们看到panic的错误信息提到了go4.org/unsafe/assume-no-moving-gc这个包,显然是这个包在“作祟”,那么assume-no-moving-gc这个包究竟是做什么的呢?究竟有何功用?为何gorgonia.org/tensor会依赖这个包?这超出了《Go与神经网络:张量计算》那篇文章的范畴,所以我并未提及。在这篇文章中,我就和大家一起来理解一下unsafe-assume-no-moving-gc这个包。 ...

April 16, 2023 · 8 min · Tony Bai

Hello,WireGuard

2020年1月28日,Linux之父Linus Torvalds正式将WireGuard merge到Linux 5.6版本内核主线: 图:WireGuard被加入linux kernel 5.6主线的commit log ...

March 29, 2020 · 13 min · Tony Bai