Solaris and mlock()

James Peach jpeach at samba.org
Wed Feb 21 23:16:40 GMT 2007


On Feb 21, 2007, at 1:27 PM, Gerald (Jerry) Carter wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Gerald (Jerry) Carter wrote:
>> Jeremy & Guenther,
>>
>> Looks like this is still an issue.  Have either of you
>> tested the mlock() usage on non-Linux platforms? (e.g.
>> Solaris).  Doesn't the memory need to page aligned or
>> something?
>>
>>  failed to mlock memory: Invalid argument (22)
>>  Failed to store memory creds: NT_STATUS_INVALID_HANDLE
>>  Plain-text authentication for user AD\smitty returned
>>    NT_STATUS_INVALID_HANDLE (PAM: 4)
>>
>> Also, why is this showing up at all with the krb5 tkt
>> refresh and offline support disabled in the smb.conf
>> file?
>
> How about this patch?
>
>
> cheers, jerry
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.4 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF3LlcIR7qMdg1EfYRAlNCAJkBT0AZuuVoizTpdajESrMFybJQVgCgzpM2
> fg1rbEbBFNVO+msQytcfgkA=
> =+VGa
> -----END PGP SIGNATURE-----
> Index: nsswitch/winbindd_cred_cache.c
> ===================================================================
> --- nsswitch/winbindd_cred_cache.c	(revision 13384)
> +++ nsswitch/winbindd_cred_cache.c	(working copy)
> @@ -471,6 +471,8 @@
>  #if !defined(HAVE_MLOCK)
>  	return NT_STATUS_OK;
>  #else
> +	int psize = getpagesize();
> +
>  	/* new_entry->nt_hash is the base pointer for the block
>  	   of memory pointed into by new_entry->lm_hash and
>  	   new_entry->pass (if we're storing plaintext). */
> @@ -480,24 +482,31 @@
>  		memcredp->len += strlen(pass)+1;
>  	}
>
> -	memcredp->nt_hash = (unsigned char *)TALLOC_ZERO(memcredp,  
> memcredp->len);
> -	if (!memcredp->nt_hash) {
> +	/* On non-linux platforms, mlock()'d memory must be aligned on
> +	   a page boundary so allocate a bit more so we can offset
> +	   enough */
> +
> +	memcredp->len += psize;
> +
> +	memcredp->buffer = (unsigned char *)TALLOC_ZERO(memcredp, memcredp- 
> >len);
> +	if (!memcredp->buffer) {
>  		return NT_STATUS_NO_MEMORY;
>  	}
>
> +	/* point the nt_hash at the page boundary in the buffer */
> +	memcredp->nt_hash = memcredp->buffer +
> +		(psize - ((uint32)memcredp->buffer % psize));

Isn't this just memalign?

--
James Peach | jpeach at samba.org



More information about the samba-technical mailing list