NetBSD Problem Report #34773

From www@NetBSD.org  Tue Oct 10 19:22:53 2006
Return-Path: <www@NetBSD.org>
Received: by narn.NetBSD.org (Postfix, from userid 31301)
	id B35A863B9FB; Tue, 10 Oct 2006 19:22:53 +0000 (UTC)
Message-Id: <20061010192253.B35A863B9FB@narn.NetBSD.org>
Date: Tue, 10 Oct 2006 19:22:53 +0000 (UTC)
From: scs5mjf@comp.leeds.ac.uk
Reply-To: scs5mjf@comp.leeds.ac.uk
To: gnats-bugs@NetBSD.org
Subject: Patch that adds functionality to veriexecgen
X-Send-Pr-Version: www-1.0

>Number:         34773
>Category:       bin
>Synopsis:       Patch that adds functionality to veriexecgen
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 10 19:25:00 +0000 2006
>Last-Modified:  Mon Jul 13 20:10:29 +0000 2020
>Originator:     Matt Fleming
>Release:        
>Organization:
>Environment:
>Description:
This patch allows users to tell veriexecgen to 'guess' the flags that should be applied to fingerprintdb.

See, 
http://mail-index.netbsd.org/tech-userlevel/2006/10/09/0002.html

begin 600 veriexecgen.patch.tgz
M'XL(`%/Q*T4``^T9:W/:2#)?X5?,>BN)9`F0`&,;+MD0&VZIPDX.["NG'!<E
M2R/01DB<1I!XO?[OUSTS>B#`]M7=[7[Q5.P9S73W]+M[G!6-//J#VE,:5!=6
M;,]>_>^'`:-E&##7F\UF"[^;AT:3[QN&>=!HF:],X\"L-^OP8;XRS`;,KXCQ
M?^!E8RQ9;$6$O&(V.YC_YNZ&F_X9W/SIXQ>R9%&5W7I!;96Y0JTZ=6#+B\L[
MSG/K9X!4;2L^*@\"A_YH/P.X_.Z_'^71R9BXGD_;I&:O6!2&<8U%=NWIV_55
M.:(Q;*R\8$HBF)@7!L2LMLJ.Y[JDLB25"+[(.L^52N49HI7J#3*F"U*'B"#F
M<=LX:C>/2`7CH(0W:)KV'"J'Y),=2R+-]D&KW:@+(N4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ats-bugs@netbsd.org
Cc: 
Subject: Re: security/34773: Patch that adds functionality to veriexecgen
Date: Sat, 20 Apr 2019 12:58:00 +0100

 Adding patch inline.

 Index: usr.sbin/veriexecgen/veriexecgen.c
 ===================================================================
 RCS file: /cvsroot/src/usr.sbin/veriexecgen/veriexecgen.c,v
 retrieving revision 1.6
 diff -u -r1.6 veriexecgen.c
 --- usr.sbin/veriexecgen/veriexecgen.c	23 Sep 2006 19:08:48 -0000	1.6
 +++ usr.sbin/veriexecgen/veriexecgen.c	7 Oct 2006 14:56:32 -0000
 @@ -40,11 +40,13 @@
  #include <sys/types.h>
  #include <sys/queue.h>
  #include <sys/stat.h>
 +#include <sys/statvfs.h>
  #include <sys/dirent.h>
  #include <sys/verified_exec.h>

  #include <err.h>
  #include <errno.h>
 +#include <fnmatch.h>
  #include <fts.h>
  #include <stdio.h>
  #include <stdlib.h>
 @@ -65,11 +67,21 @@
  #define DEFAULT_SYSPATHS { "/bin", "/sbin", "/usr/bin", "/usr/sbin", \
  			   "/lib", "/usr/lib", "/libexec", "/usr/libexec", \
  			   NULL }
 +#define DEFAULT_INTERPRETERS { "/bin/sh", "/bin/csh", "/bin/ksh",	\
 +			      "/usr/pkg/bin/perl", "/usr/pkg/bin/python2.4", \
 +			      NULL }
 +#define DEFAULT_LIBS { "/lib/*", "/usr/lib/*", "/usr/pkg/lib/*", NULL }
 +#define DEFAULT_SCRIPT_SUFFIX { ".sh", ".py", ".pl", NULL }
 +
 +#define PROGRAM			VERIEXEC_DIRECT
 +#define INTERPRETER		VERIEXEC_INDIRECT
 +#define SCRIPT			(VERIEXEC_DIRECT | VERIEXEC_FILE)
 +#define LIBRARY			0x20

  struct fentry {
  	char filename[MAXPATHLEN];
  	char *hash_val;
 -	int flags;
 +	char *flags;
  	TAILQ_ENTRY(fentry) f;
  };
  TAILQ_HEAD(, fentry) fehead;
 @@ -87,13 +99,26 @@
  	{ NULL, NULL },
  };

 -int Aflag, aflag, Dflag, Fflag, rflag, Sflag, vflag;
 +struct flags {
 +	int script;
 +	int lib;
 +	int intrprtr;
 +	int exec;
 +	int local;
 +};
 +
 +int Aflag, aflag, Dflag, Fflag, Iflag, iflag, Lflag, lflag, rflag;
 +int Sflag, sflag, vflag, Xflag;
 +
 +char **interpreter_patterns = NULL;
 +char **lib_patterns = NULL;
 +char **scripts = NULL;

  static void
  usage(void)
  {
  	(void)fprintf(stderr,
 -	    "usage: %s [-AaDrSv] [-d dir] [-o fingerprintdb]"
 +	    "usage: %s [-AaDFIiLlrSsvX] [-d dir] [-o fingerprintdb]"
  	    " [-t algorithm]\n", getprogname());
  }

 @@ -130,20 +155,89 @@
  	return h->filefunc(filename, NULL);
  }

 +static char *
 +weigh_flags(struct flags f)
 +{
 +	char *buf = "";
 +
 +	if (!(f.local))
 +		easprintf(&buf, "%sUNTRUSTED", *buf ? ", " : "");
 +
 +	if (f.script)
 +		easprintf(&buf, "%s%sSCRIPT", buf, *buf ? ", " : "");
 +	else if (f.lib)
 +		easprintf(&buf, "%s%sLIBRARY", buf, *buf ? ", " : "");
 +	else if (f.intrprtr)
 +		easprintf(&buf, "%s%sINTERPRETER", buf, *buf ? ", " : "");
 +	else if (f.exec)
 +		easprintf(&buf, "%s%sPROGRAM", buf, *buf ? ", " : "");
 +	else
 +		easprintf(&buf, "%s%sFILE", buf, *buf ? ", " : "");
 +
 +	return buf;
 +}
 +
  static int
 +wildcard(char **list, char *path)
 +{
 +	int i;
 +	char **a = list;
 +
 +	for (i = 0; a[i] != NULL; i++) {
 +		if (!fnmatch(a[i], path, 0))
 +			return 1;
 +	}
 +	return 0;
 +}
 +
 +static char *
  figure_flags(char *path, mode_t mode)
  {
 -#ifdef notyet
 +	char *p;
 +	struct statvfs st;
 +	struct flags f;
 +
 +	memset(&f, 0, sizeof(struct flags));
 +
  	if (Fflag) {
  		/* Try to figure out right flag(s). */
 -		return VERIEXEC_DIRECT;
 -}
 -#endif /* notyet */
 +		if (statvfs(path, &st) == -1)
 +			err(1, "could not stat %s", path);
 +
 +		if ((st.f_flag & MNT_LOCAL))
 +			f.local = 1;

 -	if (!IS_EXEC(mode))
 -		return VERIEXEC_FILE;
 -	else
 -		return 0;
 +		if (IS_EXEC(mode))
 +			f.exec = 1;
 +
 +		if (Lflag) {
 +			char *a[] = DEFAULT_LIBS;
 +			f.lib = wildcard(a, path);
 +		}
 +
 +		if (lflag && *lib_patterns != NULL)
 +			f.lib = wildcard(lib_patterns, path);
 +
 +		if (Iflag) {
 +			char *a[] = DEFAULT_INTERPRETERS;
 +			f.intrprtr = wildcard(a, path);
 +		}
 +
 +		if (iflag && *interpreter_patterns != NULL)
 +			f.intrprtr = wildcard(interpreter_patterns, path);
 +
 +		if (Sflag && ((p = strchr(path, '.')) != NULL)) {
 +			char *a[] = DEFAULT_SCRIPT_SUFFIX;
 +			f.script = wildcard(a, p);
 +		}
 +
 +		if (sflag && *scripts != NULL)
 +			f.script = wildcard(scripts, path);
 +
 +	} else if (IS_EXEC(mode))
 +		f.exec = 1;
 +
 +	return weigh_flags(f);
  }

  static int
 @@ -168,7 +262,7 @@

  	if (file->fts_info == FTS_SL) {
  		if (stat(file->fts_path, &sb) == -1)
 -			err(1, "Cannot stat symlink");
 +			err(1, "Cannot stat symlink %s", file->fts_path);
  	} else
  		sb = *file->fts_statp;

 @@ -225,15 +319,6 @@
  	fts_close(fh);
  }

 -static char *
 -flags2str(int flags)
 -{
 -	if (flags != 0)
 -		return "FILE";
 -	else
 -		return "";
 -}
 -
  static void
  store_entries(char *dbfile, struct hash *hash)
  {
 @@ -274,7 +359,7 @@
  			(void)printf("Adding %s.\n", e->filename);

  		(void)fprintf(fp, "%s %s %s %s\n", e->filename,
 -			hash->hashname, e->hash_val, flags2str(e->flags));
 +			hash->hashname, e->hash_val, e->flags);
  	}

  	(void)fclose(fp);
 @@ -293,14 +378,15 @@
  int
  main(int argc, char **argv)
  {
 -	int ch, total = 0;
 +	int ch, stotal = 0, itotal = 0, sutotal = 0, ltotal = 0;
  	char *dbfile = NULL;
  	char **search_path = NULL;
  	struct hash *hash = NULL;

 -	Aflag = aflag = Dflag = Fflag = rflag = Sflag = vflag = 0;
 +	Aflag = aflag = Dflag = Fflag = Iflag = iflag = Lflag = lflag;
 +	rflag = Sflag = sflag = vflag = Xflag = 0;

 -	while ((ch = getopt(argc, argv, "AaDd:ho:rSt:v")) != -1) {
 +	while ((ch = getopt(argc, argv, "AaDd:FhIiLl::o:rSs:t:vX")) != -1) {
  		switch (ch) {
  		case 'A':
  			Aflag = 1;
 @@ -313,18 +399,34 @@
  			break;
  		case 'd':
  			search_path = erealloc(search_path, sizeof(char *) *
 -			    (total + 1));
 -			search_path[total] = optarg;
 -			search_path[++total] = NULL;
 +			    (stotal + 1));
 +			search_path[stotal] = optarg;
 +			search_path[++stotal] = NULL;
  			break;
 -#ifdef notyet
  		case 'F':
  			Fflag = 1;
  			break;
 -#endif /* notyet */
  		case 'h':
  			usage();
  			return 0;
 +		case 'I':
 +			Iflag = 1;
 +			break;
 +		case 'i':
 +			iflag = 1;
 +			interpreter_patterns = erealloc(interpreter_patterns,
 +						sizeof(char *) * (itotal + 1));
 +			interpreter_patterns[itotal++] = optarg;
 +			break;
 +		case 'L':
 +			Lflag = 1;
 +			break;
 +		case 'l':
 +			lflag = 1;
 +			lib_patterns = erealloc(lib_patterns, sizeof(char *) *
 +						(ltotal + 1));
 +			lib_patterns[ltotal++] = optarg;
 +			break;
  		case 'o':
  			dbfile = optarg;
  			break;
 @@ -334,18 +436,31 @@
  		case 'S':
  			Sflag = 1;
  			break;
 +		case 's':
 +			sflag = 1;
 +			scripts = erealloc(scripts,
 +						sizeof(char *) * (sutotal + 1));
 +			scripts[sutotal++] = optarg;
 +			break;
  		case 't':
  			hash = find_hash(optarg);
  			break;
  		case 'v':
  			vflag = 1;
  			break;
 +		case 'X':
 +			Xflag = 1;
 +			break;
  		default:
  			usage();
  			return 1;
  		}
  	}

 +	/* -F implies -I and -S */
 +	if (Fflag)
 +		Iflag = Lflag = Sflag = 1;
 +
  	if (dbfile == NULL)
  		dbfile = DEFAULT_DBFILE;

 @@ -375,7 +490,7 @@

  	store_entries(dbfile, hash);

 -	if (Sflag && chflags(dbfile, SF_IMMUTABLE) != 0)
 +	if (Xflag && chflags(dbfile, SF_IMMUTABLE) != 0)
  		err(1, "Can't set immutable flag");

  	return 0;

Responsible-Changed-From-To: security-officer->bin-bug-people
Responsible-Changed-By: sevan@NetBSD.org
Responsible-Changed-When: Sat, 20 Apr 2019 13:50:08 +0000
Responsible-Changed-Why:
Not a security issue


Responsible-Changed-From-To: bin-bug-people->sevan
Responsible-Changed-By: sevan@NetBSD.org
Responsible-Changed-When: Mon, 22 Apr 2019 12:12:53 +0000
Responsible-Changed-Why:
take


Responsible-Changed-From-To: sevan->bin-bug-people
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Mon, 13 Jul 2020 20:10:29 +0000
Responsible-Changed-Why:
Reset to role account


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.