Page MenuHomeFreeBSD

Change ipsec_address() and ipsec_logsastr() functions to take two additional arguments - buffer and size of this buffer.
ClosedPublic

Authored by ae on Apr 18 2015, 12:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 2, 11:51 AM
Unknown Object (File)
Thu, May 2, 12:16 AM
Unknown Object (File)
Fri, Apr 26, 11:36 AM
Unknown Object (File)
Fri, Apr 26, 4:53 AM
Unknown Object (File)
Oct 28 2023, 10:02 AM
Unknown Object (File)
Sep 19 2023, 11:39 AM
Unknown Object (File)
Aug 27 2023, 1:48 PM
Unknown Object (File)
Aug 2 2023, 6:22 PM
Subscribers
None

Details

Summary
ipsec_address() is used to convert sockaddr structure to presentation
format. The IPv6 part of this function returns pointer to the on-stack
buffer and at the moment when it will be used by caller, it becames
invalid. IPv4 version uses 4 static buffers and returns pointer to
new buffer each time when it called. But anyway it is still possible
to get corrupted data when several threads will use this function.
  https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=185996

ipsec_logsastr() is used to format string describing SA entry. It also
uses static buffer and has the same problem with concurrent threads.

To fix these problems I added the buffer pointer and size of this
buffer to arguments. Now each caller will pass buffer and its size
to these functions. Also, I converted all places where these functions
are used (except disabled code).

And now ipsec_address() uses inet_ntop() function from libkern.
Test Plan

Without patch and sysctl net.inet.ipsec.debug=1 we have such messages for IPv6 packets:

ipsec_common_input: no key association found for SA 0T\^S\^Z\^A����_/00005fb7/50
ipsec_common_input: no key association found for SA 0T\^S\^Z\^A����_/00005fb7/50
ipsec_common_input: no key association found for SA 0T\^S\^Z\^A����_/00005fb7/50

and with patch:

ipsec_common_input: no key association found for SA fe80::11/00005fb7/50
ipsec_common_input: no key association found for SA fe80::1:11/00003d59/50
ipsec_common_input: no key association found for SA fc00::11/00003d57/50
ipsec_common_input: no key association found for SA 10.9.8.11/00003d55/50
ipsec_common_input: no key association found for SA 10.9.8.11/00003d55/50

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

ae retitled this revision from to Change ipsec_address() and ipsec_logsastr() functions to take two additional arguments - buffer and size of this buffer..
ae updated this object.
ae edited the test plan for this revision. (Show Details)
ae added a reviewer: network.
gnn added a reviewer: gnn.
This revision is now accepted and ready to land.Apr 18 2015, 4:10 PM
ae updated this revision to Diff 4900.

Closed by commit rS281695 (authored by @ae).