[klibc] RESEND [PATCH][BUGFIX] Fix termination of the spoofing portmapper

maximilian attems max at stro.at
Thu Jun 5 03:53:15 PDT 2008


On Thu, Jun 05, 2008 at 11:15:31AM +0200, Louis Rilling wrote:
> Hi,
> 
> I'm resending since I got no feedback: I assume that the message was lost...
> 
> The attached patch fixes a few bugs related to the spoofing portmapper used
> by nfsmount.
> 
> Regards,
> 
> Louis
> 
> -- 
> Dr Louis Rilling			Kerlabs
> Skype: louis.rilling			Batiment Germanium
> Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
> http://www.kerlabs.com/			35700 Rennes

> Fix termination of dummy portmapper
> 
> This patch actually fixes two bugs happening when the dummy portammaper is
> started:
> 1/ if nfs_mount() fails, nfsmount_main returns without trying to kill the dummy
>    portmapper;
> 2/ kill() is called with arguments inverted, which leads to send an arbitrary,
>    probably invalid, signal to task 15(!). The most probable side effect is that
>    the loop over waitpid() never ends, which blocks the boot process without
>    warning.

i've seen that condition happening, thanks for catching the error!
 
> Signed-off-by: Louis Rilling <Louis.Rilling at kerlabs.com>
Acked-by: maximilian attems <max at stro.at>
> ---
>  usr/kinit/nfsmount/main.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> Index: b/usr/kinit/nfsmount/main.c
> ===================================================================
> --- a/usr/kinit/nfsmount/main.c	2008-05-28 18:43:39.000000000 +0200
> +++ b/usr/kinit/nfsmount/main.c	2008-05-28 19:08:03.000000000 +0200
> @@ -168,6 +168,7 @@ int nfsmount_main(int argc, char *argv[]
>  	const char *portmap_file;
>  	pid_t spoof_portmap;
>  	int err;
> +	int ret;

just a nitpick, that variable declation could be on the same line.
>  
>  	if ((err = setjmp(abort_buf)))
>  		return err;
> @@ -243,13 +244,14 @@ int nfsmount_main(int argc, char *argv[]
>  		return 1;
>  #endif
>  
> +	ret = 0;
>  	if (nfs_mount(rem_name, hostname, server, rem_path, path,
>  		      &mount_data) != 0)
> -		return 1;
> +		ret = 1;
>  
>  	/* If we set up the spoofer, tear it down now */
>  	if (spoof_portmap) {
> -		kill(SIGTERM, spoof_portmap);
> +		kill(spoof_portmap, SIGTERM);
>  		while (waitpid(spoof_portmap, NULL, 0) == -1 &&
>  		       errno == EINTR)
>  		  ;
> @@ -257,5 +259,5 @@ int nfsmount_main(int argc, char *argv[]
>  
>  	free(rem_name);
>  
> -	return 0;
> +	return ret;
>  }

guess hpa will pick it up soonest, otherwise i'll prepare it for
my git tree for this weekend, have a small bunch of fixes pending

-- 
maks



More information about the klibc mailing list