From owner-svn-src-releng@freebsd.org Thu Mar 19 16:51:35 2020 Return-Path: Delivered-To: svn-src-releng@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D5CB12643C6; Thu, 19 Mar 2020 16:51:35 +0000 (UTC) (envelope-from gordon@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 48jtGZ2ky0z44d2; Thu, 19 Mar 2020 16:51:34 +0000 (UTC) (envelope-from gordon@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 153A0DFB4; Thu, 19 Mar 2020 16:51:34 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02JGpXpw025770; Thu, 19 Mar 2020 16:51:33 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02JGpX9E025769; Thu, 19 Mar 2020 16:51:33 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <202003191651.02JGpX9E025769@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Thu, 19 Mar 2020 16:51:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r359142 - in releng: 11.3/sys/kern 12.1/sys/kern X-SVN-Group: releng X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: in releng: 11.3/sys/kern 12.1/sys/kern X-SVN-Commit-Revision: 359142 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 16:51:35 -0000 Author: gordon Date: Thu Mar 19 16:51:33 2020 New Revision: 359142 URL: https://svnweb.freebsd.org/changeset/base/359142 Log: Fix kernel memory disclosure with nested jails. Approved by: so Security: FreeBSD-SA-20:08.jail Security: CVE-2020-7453 Modified: releng/11.3/sys/kern/kern_jail.c releng/12.1/sys/kern/kern_jail.c Modified: releng/11.3/sys/kern/kern_jail.c ============================================================================== --- releng/11.3/sys/kern/kern_jail.c Thu Mar 19 16:50:36 2020 (r359141) +++ releng/11.3/sys/kern/kern_jail.c Thu Mar 19 16:51:33 2020 (r359142) @@ -881,8 +881,12 @@ kern_jail_set(struct thread *td, struct uio *optuio, i "osrelease cannot be changed after creation"); goto done_errmsg; } - if (len == 0 || len >= OSRELEASELEN) { + if (len == 0 || osrelstr[len - 1] != '\0') { error = EINVAL; + goto done_free; + } + if (len >= OSRELEASELEN) { + error = ENAMETOOLONG; vfs_opterror(opts, "osrelease string must be 1-%d bytes long", OSRELEASELEN - 1); @@ -1272,9 +1276,11 @@ kern_jail_set(struct thread *td, struct uio *optuio, i pr->pr_osreldate = osreldt ? osreldt : ppr->pr_osreldate; if (osrelstr == NULL) - strcpy(pr->pr_osrelease, ppr->pr_osrelease); + strlcpy(pr->pr_osrelease, ppr->pr_osrelease, + sizeof(pr->pr_osrelease)); else - strcpy(pr->pr_osrelease, osrelstr); + strlcpy(pr->pr_osrelease, osrelstr, + sizeof(pr->pr_osrelease)); LIST_INIT(&pr->pr_children); mtx_init(&pr->pr_mtx, "jail mutex", NULL, MTX_DEF | MTX_DUPOK); Modified: releng/12.1/sys/kern/kern_jail.c ============================================================================== --- releng/12.1/sys/kern/kern_jail.c Thu Mar 19 16:50:36 2020 (r359141) +++ releng/12.1/sys/kern/kern_jail.c Thu Mar 19 16:51:33 2020 (r359142) @@ -862,8 +862,12 @@ kern_jail_set(struct thread *td, struct uio *optuio, i "osrelease cannot be changed after creation"); goto done_errmsg; } - if (len == 0 || len >= OSRELEASELEN) { + if (len == 0 || osrelstr[len - 1] != '\0') { error = EINVAL; + goto done_free; + } + if (len >= OSRELEASELEN) { + error = ENAMETOOLONG; vfs_opterror(opts, "osrelease string must be 1-%d bytes long", OSRELEASELEN - 1); @@ -1253,9 +1257,11 @@ kern_jail_set(struct thread *td, struct uio *optuio, i pr->pr_osreldate = osreldt ? osreldt : ppr->pr_osreldate; if (osrelstr == NULL) - strcpy(pr->pr_osrelease, ppr->pr_osrelease); + strlcpy(pr->pr_osrelease, ppr->pr_osrelease, + sizeof(pr->pr_osrelease)); else - strcpy(pr->pr_osrelease, osrelstr); + strlcpy(pr->pr_osrelease, osrelstr, + sizeof(pr->pr_osrelease)); LIST_INIT(&pr->pr_children); mtx_init(&pr->pr_mtx, "jail mutex", NULL, MTX_DEF | MTX_DUPOK);