1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00
samba-mirror/source3
Jones Syue 044cb8f9d5 mdssvc: Do an early talloc_free() in _mdssvc_open()
Environment setup:
When macOS Finder connect to a samba server with 'spotlight = yes',
macOS would issue mdssvc open (mdssvc.opnum == 0) to samba and it goes
through api _mdssvc_open().

After applied 578e434a94,
(this is reported by jaywei@qnap.com)
this line 'talloc_free(path);' is deleted if _mdssvc_open() normal exit,
so memory is lazy de-allocate: delayed to
smbd_tevent_trace_callback() @ smb2_process.c. [1]

Supposed to explicitly free 'path' in _mdssvc_open() @ srv_mdssvc_nt.c[2]
just like abnormal exit, do not wait for main loop to free 'path' which is
no longer used, this is more consistent while reading source code.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15449

[1] gdb tracing 'path' address 0x56204ccc67e0 to know how it is freed.
Breakpoint 2, _tc_free_children_internal (tc=0x56204ccc6780, ptr=0x56204ccc67e0, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1656
1656            while (tc->child) {
(gdb) bt
0  _tc_free_children_internal (tc=0x56204ccc6780, ptr=0x56204ccc67e0, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1656
1  0x00007ff430d92b14 in _tc_free_internal (tc=0x56204ccc6780, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1183
2  0x00007ff430d93b71 in _tc_free_children_internal (tc=0x56204ccc6720, ptr=0x56204ccc6780, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1668
3  0x00007ff430d93d66 in talloc_free_children (ptr=0x56204ccc6780) at ../../lib/talloc/talloc.c:1714
4  0x00007ff432235aca in talloc_pop (frame=0x56204ccc6780) at ../../lib/util/talloc_stack.c:125
5  0x00007ff430d92959 in _tc_free_internal (tc=0x56204ccc6720, location=0x7ff431f358d0 "../../source3/smbd/process.c:3726") at ../../lib/talloc/talloc.c:1157
6  0x00007ff430d92cd5 in _talloc_free_internal (ptr=0x56204ccc6780, location=0x7ff431f358d0 "../../source3/smbd/process.c:3726") at ../../lib/talloc/talloc.c:1247
7  0x00007ff430d93f96 in _talloc_free (ptr=0x56204ccc6780, location=0x7ff431f358d0 "../../source3/smbd/process.c:3726") at ../../lib/talloc/talloc.c:1791
8  0x00007ff431d81292 in smbd_tevent_trace_callback (point=TEVENT_TRACE_AFTER_LOOP_ONCE, private_data=0x7ffe46591e30) at ../../source3/smbd/process.c:3726
<...cut...>

[2] gdb tracing 'path' address 0x55a6d66deed0 to know how it is freed.
Breakpoint 2, _tc_free_children_internal (tc=0x55a6d66deed0, ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1656
1656            while (tc->child) {
(gdb) bt
0  _tc_free_children_internal (tc=0x55a6d66deed0, ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1656
1  0x00007fc4cb892b14 in _tc_free_internal (tc=0x55a6d66deed0, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1183
2  0x00007fc4cb892cd5 in _talloc_free_internal (ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1247
3  0x00007fc4cb893f96 in _talloc_free (ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1791
4  0x00007fc4cc9396e4 in _mdssvc_open (p=0x55a6d66d5600, r=0x55a6d66edc60) at ../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189
<...cut...>

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: Noel Power <npower@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Aug 14 18:11:37 UTC 2023 on atb-devel-224
2023-08-14 18:11:37 +00:00
..
auth s3:auth: Add missing newlines to logging messages 2023-08-08 04:39:37 +00:00
build
client smbclient3: Get all reparse data for allinfo 2023-08-10 14:36:40 +00:00
exports
groupdb s3:groupdb: Add missing newline to logging message 2023-08-08 04:39:38 +00:00
include s3:include: Fix code spelling 2023-07-13 05:41:36 +00:00
intl
lib s3:lib: Use portable format specifiers 2023-08-14 04:57:34 +00:00
libads s3:libads: Add missing newlines to logging messages 2023-08-08 04:39:38 +00:00
libgpo/gpext
libnet s3:libnet: Add missing newline to logging message 2023-08-08 04:39:38 +00:00
librpc s3:librpc: Add missing newline to logging message 2023-08-08 04:39:38 +00:00
libsmb libsmb: Retry with OPEN_REPARSE_POINT on IO_REPARSE_TAG_NOT_HANDLED 2023-08-10 13:40:31 +00:00
locale s3:utils: Fix code spelling 2023-08-08 04:39:38 +00:00
locking s3:locking: Fix code spelling 2023-07-17 11:46:29 +00:00
modules s3:vfs: Add missing space in debug message 2023-08-08 04:39:38 +00:00
nmbd s3:nmbd: Add missing newlines to logging messages 2023-08-08 04:39:38 +00:00
param s3:param: Fix code spelling 2023-07-19 09:58:37 +00:00
passdb s3:passdb: Fix typo 2023-08-08 04:39:38 +00:00
printing s3:printing: Fix code spelling 2023-08-08 04:39:38 +00:00
profile profiling: Factor out functions to read smbprofile.tdb 2023-06-16 16:14:30 +00:00
registry s3:registry: Fix code spelling 2023-08-14 04:57:34 +00:00
rpc_client s3:rpc_client: Add missing newlines to logging messages 2023-08-08 04:39:38 +00:00
rpc_server mdssvc: Do an early talloc_free() in _mdssvc_open() 2023-08-14 18:11:37 +00:00
rpcclient CVE-2023-34968: mdssvc: introduce an allocating wrapper to sl_pack() 2023-07-21 12:05:35 +00:00
script sefltest: Add new regression test dfs with widelinks = yes 2023-07-28 23:50:32 +00:00
selftest s3: torture: Add SMB1-TRUNCATED-SESSSETUP test. 2023-08-14 14:57:32 +00:00
services s3:services: Disable rcinit-based service control code 2021-12-10 14:02:30 +00:00
smbd s3: smbd: Ensure all callers to srvstr_pull_req_talloc() pass a zeroed-out dest pointer. 2023-08-14 15:55:43 +00:00
torture s3: torture: Add SMB1-TRUNCATED-SESSSETUP test. 2023-08-14 14:57:32 +00:00
utils s3:utils: Fix code spelling 2023-08-08 04:39:38 +00:00
web
winbindd s3:winbindd: Fix debug messages 2023-08-08 04:39:38 +00:00
.clang_complete
.dmallocrc
.indent.pro
Doxyfile
mainpage.dox
smbadduser.in
wscript s3:waf: Fix code spelling 2023-07-19 09:58:37 +00:00
wscript_build profiling: Factor out functions to read smbprofile.tdb 2023-06-16 16:14:30 +00:00
wscript_configure_system_ncurses