Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

MIPS socket option (SO_*) values are wrong — setsockopt fails (e.g. busybox ping)

Aperta Adatta ai principianti
#1,640 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
Mezza giornata
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
python

Direzione di ricerca

Inizia in qiling/os/posix/const.py, in linux_mips_socket_options, e confronta le relative voci con i valori socket MIPS uapi descritti nell’issue. Esegui ql_syscall_setsockopt usando la riproduzione MIPS fornita, quindi aggiungi un test di regressione che copra le opzioni corrette e le mappature mancanti SO_TYPE/SO_ERROR. Il lavoro è completato quando MIPS SO_RCVBUF e SO_SNDBUF vengono mappati correttamente senza NotImplementedError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

MIPS socket option (SO_*) values are wrong — setsockopt fails (e.g. busybox ping)

Describe the bug

linux_mips_socket_options (qiling/os/posix/const.py) uses generic/incorrect SO_* values. MIPS has its own numbering (arch/mips/include/uapi/asm/socket.h) where the buffer/timeout/type options live in the 0x1000 range, unlike the asm-generic values used by most arches. The table is wrong in several places:

option table has MIPS uapi
SO_SNDBUF 0x01 0x1001
SO_RCVBUF 0x02 0x1002
SO_SNDLOWAT 0x03 0x1003
SO_RCVLOWAT 0x04 0x1004
SO_SNDTIMEO_OLD 0x05 0x1005
SO_RCVTIMEO_OLD 0x06 0x1006
SO_OOBINLINE 0x00 0x0100
SO_REUSEPORT 0x00 0x0200

SO_RCVLOWAT = 0x04 also silently collides with SO_REUSEADDR = 0x04 (it becomes an Enum alias), and SO_TYPE/SO_ERROR are missing entirely.

Consequently a guest setsockopt(SOL_SOCKET, SO_RCVBUF, ...) aborts emulation:

NotImplementedError: Could not convert emulated socket option 4098 to a socket option name

(4098 == 0x1002 == SO_RCVBUF on MIPS.) This is hit by ordinary programs — e.g. busybox ping sets SO_RCVBUF/SO_SNDBUF right after creating its socket.

Repro (Python)

from qiling import Qiling
from qiling.const import QL_ARCH, QL_OS, QL_ENDIAN, QL_VERBOSE
from qiling.os.posix.syscall.socket import ql_syscall_socket, ql_syscall_setsockopt

ql = Qiling(code=b"\x00\x00\x00\x00", archtype=QL_ARCH.MIPS, ostype=QL_OS.LINUX,
            endian=QL_ENDIAN.EB, rootfs="examples/rootfs/mips32_linux", verbose=QL_VERBOSE.OFF)

fd = ql_syscall_socket(ql, 2, 2, 0)            # AF_INET, SOCK_DGRAM
base = 0x100000
ql.mem.map(base, 0x1000)
ql.mem.write_ptr(base, 16384, 4)
# SOL_SOCKET=0xffff, SO_RCVBUF=0x1002 on MIPS
ql_syscall_setsockopt(ql, fd, 0xffff, 0x1002, base, 4)

Without the fix this raises NotImplementedError: Could not convert emulated socket option 4098.

Expected behavior

setsockopt with the MIPS SO_* values should map to the host option and succeed, matching the kernel's MIPS SO_* numbering.

Environment

  • Affects MIPS / MIPS64 (the values are shared); reproduces on any host.
  • Same code area as the already-closed #1286 (socket-level mapping for IPPROTO_TCP).

A fix (correct the SO_* values + add the missing ones, with a regression test) is proposed in the linked PR.

Lingua principale
Python
Stelle
6.1k
Fork
799
Merge medio
3h 15m
PR unite (30g)
8

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di qilingframework/qiling

Tutte le issue di qilingframework/qiling

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.