Page MenuHomeFreeBSD

linux: fix linux_recvmsg() flag handling
ClosedPublic

Authored by melifaro on Jan 8 2022, 1:44 PM.

Details

Summary

Currently, linux_recvmsg() code ignore all flags passed in flag function argument.
For example, it results in completely wrong behavior with MSG_PEEK.

Fix it by passing the flags in the unused msg->msg_flag parameter, following the approach used in sys_recvmsg.

Test Plan

Test code: P534

BEFORE

13:42 [1] m@devel0 ~/peek
socket(2,2,17) -> 3 | Success
bind(fd#3) -> 0 | Success
sendto(fd#4) -> 1024
recvmsg(fd#3) -> 128 | errno Success
load: 0.73  cmd: peek 1915 [sbwait] 2.22r 0.00u 0.00s 0% 1268k
mi_switch+0x157 sleepq_switch+0x107 sleepq_catch_signals+0x266 sleepq_wait_sig+0x9 _sleep+0x2dd sbwait+0x61 soreceive_dgram+0x162 soreceive+0x4b kern_recvit+0x1ba linux_recvmsg_common+0x125 linux_recvmsg+0x1c amd64_syscall+0x12e fast_syscall_common+0xf8
load: 0.73  cmd: peek 1915 [sbwait] 2.41r 0.00u 0.00s 0% 1268k
mi_switch+0x157 sleepq_switch+0x107 sleepq_catch_signals+0x266 sleepq_wait_sig+0x9 _sleep+0x2dd sbwait+0x61 soreceive_dgram+0x162 soreceive+0x4b kern_recvit+0x1ba linux_recvmsg_common+0x125 linux_recvmsg+0x1c amd64_syscall+0x12e fast_syscall_common+0xf8
load: 0.73  cmd: peek 1915 [sbwait] 2.59r 0.00u 0.00s 0% 1268k
mi_switch+0x157 sleepq_switch+0x107 sleepq_catch_signals+0x266 sleepq_wait_sig+0x9 _sleep+0x2dd sbwait+0x61 soreceive_dgram+0x162 soreceive+0x4b kern_recvit+0x1ba linux_recvmsg_common+0x125 linux_recvmsg+0x1c amd64_syscall+0x12e fast_syscall_common+0xf8
^C

AFTER

13:43 [1] m@devel0
13:43 [1] m@devel0 s kldunload linux64
13:43 [1] m@devel0 s kldload linux64
13:43 [1] m@devel0 ~/peek
socket(2,2,17) -> 3 | Success
bind(fd#3) -> 0 | Success
sendto(fd#4) -> 1024
recvmsg(fd#3) -> 128 | errno Success
recvmsg(fd#3) -> 1024 | errno Success
13:43 [1] m@devel0

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 43780
Build 40668: arc lint + arc unit

Event Timeline

melifaro retitled this revision from linux: fix linux_recvmsg() MSG_PEEK flag handling to linux: fix linux_recvmsg() flag handling.Jan 8 2022, 2:01 PM
melifaro edited the summary of this revision. (Show Details)
melifaro edited the test plan for this revision. (Show Details)
melifaro added reviewers: trasz, mjg, kib.
This revision is now accepted and ready to land.Jan 8 2022, 3:07 PM