[PATCH] talloc_free_for_exit() and targeted write protection for talloc destructor

Andrew Bartlett abartlet at samba.org
Mon Nov 28 18:13:53 UTC 2016


In a hope of getting more attention and being more transparent, here is
the talloc changes I included in my previous patch set.

As background, I want to make our LDAP server multi-process, and
running a connect()/bind()/close() loop against the LDAP server showed
a significant cost in talloc_free(ev) and talloc_autofree() just before
exit.

This made me think about a way to make Samba 'forget' to call free() or
inspect talloc children that did not have a destructor to fire. 

It also has very useful security implications, as if we don't
universally call the destructor, then a targeted overwrite of a
destructor is not nearly as useful.  This follows on from my magic
hardening work. 

The cost is that talloc_steal(), the implicit talloc_steal() when a
reference becomes a parent and talloc_add_destructor() become O(log(n))
or so, not O(1) as they were. 

Please carefully examine.  I'll also see if I can squeeze some more
performance out of it, eg dropping patch 33, as every single branch in
talloc has quite a cost.

Thanks,

Andrew Bartlett
-- 
Andrew Bartlett                       http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0027-talloc-Improve-test_magic_protection-testsuite.patch
Type: text/x-patch
Size: 2302 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0027-talloc-Improve-test_magic_protection-testsuite.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0028-talloc-Add-tests-for-talloc_parent-after-realloc-of-.patch
Type: text/x-patch
Size: 1797 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0028-talloc-Add-tests-for-talloc_parent-after-realloc-of-.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0029-talloc-Remove-talloc_abort_unknown_value-consolidate.patch
Type: text/x-patch
Size: 2026 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0029-talloc-Remove-talloc_abort_unknown_value-consolidate.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0030-talloc-clarify-that-talloc_magic-never-includes-the-.patch
Type: text/x-patch
Size: 975 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0030-talloc-clarify-that-talloc_magic-never-includes-the-.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0031-talloc-Set-TALLOC_FLAG_HAS_DESTRUCTOR-on-parents-whe.patch
Type: text/x-patch
Size: 2640 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0031-talloc-Set-TALLOC_FLAG_HAS_DESTRUCTOR-on-parents-whe.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0032-talloc-Only-call-talloc-destructors-when-TALLOC_FLAG.patch
Type: text/x-patch
Size: 5448 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0032-talloc-Only-call-talloc-destructors-when-TALLOC_FLAG.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0033-talloc-Add-debugging-abort-calls-for-invalid-situati.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0033-talloc-Add-debugging-abort-calls-for-invalid-situati.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0034-talloc-Pass-down-a-flag-to-determine-if-we-should-at.patch
Type: text/x-patch
Size: 3150 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0034-talloc-Pass-down-a-flag-to-determine-if-we-should-at.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0035-talloc-Avoid-calling-free-on-the-top-level-pointer-i.patch
Type: text/x-patch
Size: 1866 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0035-talloc-Avoid-calling-free-on-the-top-level-pointer-i.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0036-talloc-Add-talloc_free_for_exit.patch
Type: text/x-patch
Size: 14615 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0036-talloc-Add-talloc_free_for_exit.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0037-talloc-Use-talloc_free_for_exit-in-talloc_autofree.patch
Type: text/x-patch
Size: 1529 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0037-talloc-Use-talloc_free_for_exit-in-talloc_autofree.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0038-talloc-Add-tests-for-talloc-destructor-behaviour.patch
Type: text/x-patch
Size: 8058 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0038-talloc-Add-tests-for-talloc-destructor-behaviour.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0039-talloc-add-ASCII-art-to-describe-parent-child-arrang.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161129/5e8ff5ea/0039-talloc-add-ASCII-art-to-describe-parent-child-arrang.bin>


More information about the samba-technical mailing list