Bug 248065 - Linuxulator: 32-bit compat + send with MSG_NOSIGNAL
Summary: Linuxulator: 32-bit compat + send with MSG_NOSIGNAL
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks: 247219
  Show dependency treegraph
 
Reported: 2020-07-18 13:16 UTC by Alex S
Modified: 2021-03-06 12:38 UTC (History)
2 users (show)

See Also:


Attachments
minimal repro (2.33 KB, text/plain)
2020-07-18 13:16 UTC, Alex S
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex S 2020-07-18 13:16:06 UTC
Created attachment 216539 [details]
minimal repro

Apparently, with a sufficiently large payload and the MSG_NOSIGNAL flag, blocking send turns out not quite as blocking as expected. So far this is only observable with 32-bit Linux applications:

% /compat/linux/usr/bin/cc -DSERVER -DCLIENT -std=c99 -Wall -m32 eagain-bug.c -pthread -o eagain-bug
% ./eagain-bug
server started
client started
connection accepted
[server] Sending 100000 bytes...
[server] sent: 49032
[server] Sending 100000 bytes...
[server] sent: -1
[server] send: Resource temporarily unavailable

See attachment for the code. (Or grab it from https://github.com/shkhln/unexpected-eagain.)
Comment 1 Alex S 2020-07-18 13:25:25 UTC
By the way, with this program truss outputs something like

  linux_socketcall(9,{ LINUX_LISTEN, 0x186a0 })	 = 49032 (0xbf88)

This should rather be

  linux_socketcall(LINUX_SEND,{ 4, 0x186a0 })	 = 49032 (0xbf88)
Comment 2 Edward Tomasz Napierala freebsd_committer freebsd_triage 2021-02-05 17:26:59 UTC
https://reviews.freebsd.org/D28504
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-02-06 23:47:21 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f6e8256a965d5b7a7d43034ea31b2430a3b51066

commit f6e8256a965d5b7a7d43034ea31b2430a3b51066
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-02-05 17:24:23 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-02-06 23:21:27 +0000

    linux: fix handling of flags for 32 bit send(2) syscall

    Previously the flags were passed as-is, which could resulted
    in spurious EAGAIN returned for non-blocking sockets, which
    broke some Steam games.

    PR:             248065
    Reported By:    Alex S <iwtcex@gmail.com>
    Tested By:      Alex S <iwtcex@gmail.com>
    Reviewed By:    emaste
    MFC After:      3 days
    Sponsored By:   The FreeBSD Foundation

 sys/compat/linux/linux_socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-03-02 18:44:09 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9d930fb09072d21464288df8c834cb8d0b760073

commit 9d930fb09072d21464288df8c834cb8d0b760073
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-02-05 17:24:23 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-03-02 18:43:27 +0000

    linux: fix handling of flags for 32 bit send(2) syscall

    Previously the flags were passed as-is, which could resulted
    in spurious EAGAIN returned for non-blocking sockets, which
    broke some Steam games.

    PR:             248065
    Reported By:    Alex S <iwtcex@gmail.com>
    Tested By:      Alex S <iwtcex@gmail.com>
    Reviewed By:    emaste
    MFC After:      3 days
    Sponsored By:   The FreeBSD Foundation

    (cherry picked from commit f6e8256a965d5b7a7d43034ea31b2430a3b51066)

 sys/compat/linux/linux_socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-03-05 00:37:35 UTC
A commit in branch releng/13.0 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=fdd7609f10236df34c8d8ae2d6f2dae46e0e96cf

commit fdd7609f10236df34c8d8ae2d6f2dae46e0e96cf
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-02-05 17:24:23 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-03-04 23:29:22 +0000

    linux: fix handling of flags for 32 bit send(2) syscall

    Previously the flags were passed as-is, which could resulted
    in spurious EAGAIN returned for non-blocking sockets, which
    broke some Steam games.

    Approved by:    re (gjb)
    PR:             248065
    Reported By:    Alex S <iwtcex@gmail.com>
    Tested By:      Alex S <iwtcex@gmail.com>
    Reviewed By:    emaste
    MFC After:      3 days
    Sponsored By:   The FreeBSD Foundation

    (cherry picked from commit f6e8256a965d5b7a7d43034ea31b2430a3b51066)
    (cherry picked from commit 9d930fb09072d21464288df8c834cb8d0b760073)

 sys/compat/linux/linux_socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)