Page MenuHomeFreeBSD

Unlock inp when handling TCP_MD5SIG socket options
ClosedPublic

Authored by thj on Jun 20 2022, 1:15 PM.
Tags
None
Referenced Files
F105582091: D35532.diff
Tue, Dec 17, 10:35 PM
Unknown Object (File)
Wed, Dec 4, 10:18 AM
Unknown Object (File)
Oct 19 2024, 2:26 PM
Unknown Object (File)
Oct 19 2024, 2:26 PM
Unknown Object (File)
Oct 19 2024, 2:26 PM
Unknown Object (File)
Oct 19 2024, 2:25 PM
Unknown Object (File)
Oct 19 2024, 2:25 PM
Unknown Object (File)
Oct 19 2024, 2:08 PM

Details

Summary

Unlock the inp when hanlding TCP_MD5SIG socket options. tcp_ipsec_pcbctl
handles locking the inp when the option is being modified.

This was found by Claudio Jeker while OpenBGPd and the fix is from him.

On 14 we get a panic when trying to call getsockopt, on 13.1 the process locks
up using 100% CPU.

Test Plan

The following test case exercises the behaviour with the tcpmd5 kernel module
loaded.

#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>

#include <err.h>

int
main(int argc, char **argv)
{
        struct sockaddr_in s = { 0 };
        socklen_t len;
        int fd, opt;

        if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
                err(1, "socket");

        s.sin_family = AF_INET;
        s.sin_len = sizeof(s);
        s.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
        s.sin_port = htons(22);
        if (connect(fd, (struct sockaddr *)&s, sizeof(s)) == -1)
                err(1, "connect");

        if (getsockopt(fd, IPPROTO_TCP, TCP_MD5SIG, &opt, &len) == -1)
                err(1, "getsockopt");

        return opt;
}

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46061
Build 42950: arc lint + arc unit

Event Timeline

thj requested review of this revision.Jun 20 2022, 1:15 PM
This revision is now accepted and ready to land.Jun 20 2022, 1:35 PM

Would it be possible to add the testcase for both IPv4 and IPv6?

  • Add test cases for getsockopt
This revision now requires review to proceed.Jun 22 2022, 3:06 PM
This revision is now accepted and ready to land.Jun 22 2022, 4:29 PM
This revision now requires review to proceed.Jun 23 2022, 2:48 PM
This revision was not accepted when it landed; it landed in state Needs Review.Jun 23 2022, 2:59 PM
This revision was automatically updated to reflect the committed changes.