Adrian Chung
2002-Apr-07 19:12 UTC
[Samba] Possible memory leak password.c/pass_check_smb().
Hi! I'm running Samba 2.2.3a with a whole bunch of Windows XP clients, and have been noticing that Samba has been consuming all available memory resources if left unchecked for about a week. After some digging, and correlating the following messages in my logs: [2002/04/07 19:42:17, 1] smbd/password.c:pass_check_smb(555) Couldn't find user 'nobody' in passdb. I decided to put 'nobody' in my smbpasswd file. After doing that, the leak seems to have gone away. On further inspection, looking at source/smbd/password.c close to line 555: [...] BOOL pass_check_smb... [..] /* get the account information */ pdb_init_sam(&sampass); if (!pdb_getsampwnam(sampass, user)) { DEBUG(1,("Couldn't find user '%s' in passdb.\n", user)); return(False); } [...] It looks like pdb_init_sam() is called which actually malloc's memory, but never free's it, and returns. Not having looked at Samba code much, it is possible that this is free'd elsewhere, but it seems suspicious given my symptoms, and the fact that the rest of the code looks like: /* Quit if the account was disabled. */ if(pdb_get_acct_ctrl(sampass) & ACB_DISABLED) { DEBUG(1,("Account for user '%s' was disabled.\n", user)); pdb_free_sam(sampass); return(False); } if (pdb_get_acct_ctrl(sampass) & ACB_PWNOTREQ) { if (lp_null_passwords()) { DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n", user)); pdb_free_sam(sampass); return(True); } else { DEBUG(3,("Account for user '%s' has no password and null passwords are NOT allowed.\n", user)); pdb_free_sam(sampass); return(False); } } if (smb_password_ok(sampass, chal, lm_pwd, nt_pwd)) { pdb_free_sam(sampass); return(True); } DEBUG(2,("pass_check_smb failed - invalid password for user [%s]\n", user)); pdb_free_sam(sampass); return False; -- Adrian Chung (adrian at enfusion-group dot com) http://www.enfusion-group.com/~adrian GPG Fingerprint: C620 C8EA 86BA 79CC 384C E7BE A10C 353B 919D 1A17 [toad.enfusion-group.com] up 15 days, 7:45, 8 users