Bug 11180 - Samba standard process model closes random files when forking more than once
Summary: Samba standard process model closes random files when forking more than once
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.2.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-26 09:57 UTC by Andreas Schneider
Modified: 2015-04-09 19:23 UTC (History)
2 users (show)

See Also:


Attachments
Patch for 4.2, cherry-picked from master. (2.46 KB, patch)
2015-03-31 13:49 UTC, Michael Adam
obnox: review+
asn: review+
Details
Patch for 4.1, cherry-picked from master (2.46 KB, patch)
2015-03-31 13:50 UTC, Michael Adam
obnox: review+
asn: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schneider 2015-03-26 09:57:58 UTC
The Samba standard process model closes random files when forking more than once.
Comment 1 Andreas Schneider 2015-03-26 10:12:52 UTC
    The issue has been found with nss_wrapper debug output running:
        samba4.ntvfs.cifs.krb5.base.lock
    
    In the case here, we fork a child and close the fd without resetting
    the pipe fd variable. Then the fd was used to open the nss_wrapper
    hosts file which got the same fd. We forked again in the process model
    called close() on the re-used fd (of the pipe variable) again without
    nss_wrapper noticing.  Now Samba opened the secrets tdb and got
    the same fd as nss_wrapper was using for the hosts file and next
    nss_wrapper tried to parse a TDB ...
Comment 2 Jeremy Allison 2015-03-26 18:37:42 UTC
Andreas, can you point at any specific source code lines inside source4/ so I can start to investigate and fix this ? Would save me some time.

Thanks !

Jeremy.
Comment 3 Michael Adam 2015-03-26 20:09:31 UTC
(In reply to Jeremy Allison from comment #2)

Jeremy we already fixed it:
comment #1 is the commit message from master.

Will attach backported patch...
Comment 4 Jeremy Allison 2015-03-26 20:18:39 UTC
Ah, I didn't see any attachment or git refspec :-).

Maybe you could add it here ?

:-).
Comment 5 Michael Adam 2015-03-26 20:25:44 UTC
Oh, I was about to but it is still in autobuild (by andreas):

https://git.samba.org/?p=asn/samba-autobuild/.git;a=shortlog;h=refs/heads/master

https://git.samba.org/?p=asn/samba-autobuild/.git;a=commitdiff;h=2bad6e6cf36a2b93944ef2a6e418d1a3aa70cacc


After all, it was only fixed today. :)

Will attach stuff once it's through.
Comment 6 Michael Adam 2015-03-31 13:49:43 UTC
Created attachment 10921 [details]
Patch for 4.2, cherry-picked from master.
Comment 7 Michael Adam 2015-03-31 13:50:53 UTC
Created attachment 10922 [details]
Patch for 4.1, cherry-picked from master
Comment 8 Andreas Schneider 2015-03-31 15:09:49 UTC
Karo, please add the patches to the relevant branches. Thanks!
Comment 9 Karolin Seeger 2015-04-08 19:17:39 UTC
Pushed to autobuild-v4-[1|2]-test.
Comment 10 Karolin Seeger 2015-04-09 19:23:24 UTC
(In reply to Karolin Seeger from comment #9)
Pushed to both branches.
Closing out bug report.

Thanks!