Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jun 2014 17:47:01 +0200
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Dmitry Chagin <dchagin@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r266925 - in head/sys: amd64/linux32 i386/linux kern sys
Message-ID:  <20140606154701.GA26114@dft-labs.eu>
In-Reply-To: <201405311501.s4VF1pR8062552@svn.freebsd.org>
References:  <201405311501.s4VF1pR8062552@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, May 31, 2014 at 03:01:51PM +0000, Dmitry Chagin wrote:
> Author: dchagin
> Date: Sat May 31 15:01:51 2014
> New Revision: 266925
> URL: http://svnweb.freebsd.org/changeset/base/266925
> 
> Log:
>   To allow to run the interpreter itself add a new ELF branding type.
>   Allow Linux ABI to run ELF interpreter.
>   

[..]

> +	/* Some ABI allows to run the interpreter itself. */
> +	for (i = 0; i < MAX_BRANDS; i++) {
> +		bi = elf_brand_list[i];
> +		if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY)
> +			continue;
> +		if (hdr->e_machine != bi->machine ||
> +		    (bi->flags & BI_CAN_EXEC_INTERP) == 0)
> +			continue;
> +		/*
> +		 * Compare the interpreter name not the path to allow run it
> +		 * from everywhere.
> +		 */
> +		interp_brand_name = strrchr(bi->interp_path, '/');
> +		if (interp_brand_name == NULL)
> +			interp_brand_name = bi->interp_path;
> +		interp_len = strlen(interp_brand_name);
> +		fname_name = strrchr(imgp->args->fname, '/');

Don't know about the rest, but this part looks incorrect.

fname is NULL (which will crash in strrchr) when fexecve is executed.

> +		if (fname_name == NULL)
> +			fname_name = imgp->args->fname;
> +		fname_len = strlen(fname_name);
> +		if (fname_len < interp_len)
> +			continue;
> +		ret = strncmp(fname_name, interp_brand_name, interp_len);
> +		if (ret == 0)
> +			return (bi);
> +	}
> +


-- 
Mateusz Guzik <mjguzik gmail.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140606154701.GA26114>