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)
Oct 16 2024, 6:03 AM
Unknown Object (File)
Oct 11 2024, 7:41 PM
Unknown Object (File)
Oct 11 2024, 7:41 PM
Unknown Object (File)
Oct 11 2024, 7:41 PM
Unknown Object (File)
Oct 11 2024, 7:12 PM
Unknown Object (File)
Oct 9 2024, 2:09 PM
Unknown Object (File)
Oct 1 2024, 10:43 AM
Unknown Object (File)
Sep 14 2024, 9:56 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).