From owner-svn-src-all@freebsd.org Fri May 24 19:43:40 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D3DA15B3ECA; Fri, 24 May 2019 19:43:40 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9DD86751A5; Fri, 24 May 2019 19:43:39 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 747F0216B0; Fri, 24 May 2019 19:43:39 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4OJhdgD082854; Fri, 24 May 2019 19:43:39 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4OJhcWP082851; Fri, 24 May 2019 19:43:38 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <201905241943.x4OJhcWP082851@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Fri, 24 May 2019 19:43:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348249 - in head/stand: . ficl libsa X-SVN-Group: head X-SVN-Commit-Author: sjg X-SVN-Commit-Paths: in head/stand: . ficl libsa X-SVN-Commit-Revision: 348249 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9DD86751A5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.94)[-0.944,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2019 19:43:40 -0000 Author: sjg Date: Fri May 24 19:43:38 2019 New Revision: 348249 URL: https://svnweb.freebsd.org/changeset/base/348249 Log: ficl pfopen: verify file If the file is verified - do not allow write otherwise do not allow read. Add O_ACCMODE to stand.h Reviewed by: stevek, mindal_semihalf.com MFC after: 3 days Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D20387 Modified: head/stand/ficl.mk head/stand/ficl/loader.c head/stand/libsa/stand.h Modified: head/stand/ficl.mk ============================================================================== --- head/stand/ficl.mk Fri May 24 18:41:31 2019 (r348248) +++ head/stand/ficl.mk Fri May 24 19:43:38 2019 (r348249) @@ -16,3 +16,7 @@ CFLAGS+= -fPIC CFLAGS+= -I${FICLSRC} -I${FICLSRC}/${FICL_CPUARCH} -I${LDRSRC} CFLAGS+= -DBF_DICTSIZE=15000 + +.if ${MK_LOADER_VERIEXEC} != "no" +CFLAGS+= -DLOADER_VERIEXEC -I${SRCTOP}/lib/libsecureboot/h +.endif Modified: head/stand/ficl/loader.c ============================================================================== --- head/stand/ficl/loader.c Fri May 24 18:41:31 2019 (r348248) +++ head/stand/ficl/loader.c Fri May 24 19:43:38 2019 (r348249) @@ -502,6 +502,23 @@ static void pfopen(FICL_VM *pVM) /* open the file */ fd = open(name, mode); +#ifdef LOADER_VERIEXEC + if (fd >= 0) { + if (verify_file(fd, name, 0, VE_GUESS) < 0) { + /* not verified writing ok but reading is not */ + if ((mode & O_ACCMODE) != O_WRONLY) { + close(fd); + fd = -1; + } + } else { + /* verified reading ok but writing is not */ + if ((mode & O_ACCMODE) != O_RDONLY) { + close(fd); + fd = -1; + } + } + } +#endif free(name); stackPushINT(pVM->pStack, fd); return; Modified: head/stand/libsa/stand.h ============================================================================== --- head/stand/libsa/stand.h Fri May 24 18:41:31 2019 (r348248) +++ head/stand/libsa/stand.h Fri May 24 19:43:38 2019 (r348249) @@ -286,6 +286,7 @@ extern int open(const char *, int); #define O_RDONLY 0x0 #define O_WRONLY 0x1 #define O_RDWR 0x2 +#define O_ACCMODE 0x3 /* NOT IMPLEMENTED */ #define O_CREAT 0x0200 /* create if nonexistent */ #define O_TRUNC 0x0400 /* truncate to zero length */