From nobody Tue Mar 29 20:14:45 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5C77E1A321EF; Tue, 29 Mar 2022 20:14:46 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KSglV1z25z3GZb; Tue, 29 Mar 2022 20:14:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648584886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=drfXE8T0I3Dob7oB2Nu3dqNlXTC2buwcxpsyDPaDUeE=; b=u12cZpyR7Ah9Oq8wVtVWwQ7FKsSEAPhtLII7TasLgxohzG6KIaJF5ugCTIfXxQijlz6J93 Uko4FQYqu/oul9Vr2GwF10AwDTnvk951Mj6rEFhjcnrf7w+FyEaSceC6pbvWNvxWNizuir PFkXln/EgVfDfazd4D9ye8UiauLJWBb6x/6Oc3RXwDhpwTwKrhrf4dQWN93smx5c3Kb2ih rtFsI15sbbAwuXLIW0eFrO80zsih4gwb14JAjGKCH8dDlNs3a3Jf0QWgQnM4G4yxtnVMNd 5cZtN1GEeO4jSrcvdmeM7LTSN74z09RgRe3PY9HFVH6Ovdy2Qqz88TuljrGjdQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1F65425347; Tue, 29 Mar 2022 20:14:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22TKEjfA024242; Tue, 29 Mar 2022 20:14:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22TKEjd9024241; Tue, 29 Mar 2022 20:14:45 GMT (envelope-from git) Date: Tue, 29 Mar 2022 20:14:45 GMT Message-Id: <202203292014.22TKEjd9024241@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: f90cd1ae30b5 - main - Clear non-x86 compat stat syscall kernel stack memory disclosure List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f90cd1ae30b5f49e9f6ea58a0628ce1c8d8822bc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648584886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=drfXE8T0I3Dob7oB2Nu3dqNlXTC2buwcxpsyDPaDUeE=; b=qlkv2NyWtZA9vqrj6eOxWr2tmfxTbyF9s9cosmFHqxW5CdTJ0V3ZTqZmzUJJ9jF/YfY8Tw rqAPczthw6nJsk+17IYLqqejyZeF19LSINikiroRkFlxQkrh4sPkoZPWCcE8BkzccSuqk1 31Qi6WhCQT8MbjXu2jCoCioN5CtNi3705hxUWx6beBeG6MuHYC4e0F7+OGac8ciFypfEAQ bibgw2dDpCTJ8aehnP9S5oTsUylvE6T5OHFosiPWPRAmKT5p4WBggV7JoP4RPjpGJHAQWB 8kFzxNWlfTKyi1TWHpsgW1URAQ4RvFO3tyrdyTMS45Ab+PaWtgFjVayoRamVPw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648584886; a=rsa-sha256; cv=none; b=SSChGCF4dAYk8Xgpl2TcuY64Ibl6tWA1y8Y7G9w6iUT9iVttPteNd1QApX6WK0rEZ5gwfv UKpcFZuGKCmfg6YoLl3ahCFSMz4CJ7ZeklGkL3+gkyha0gXcoLuzQQEUEbzcxnMlBrtolW y1SnsXxFm8D+DGqkt7R7ycadxFZawxFyhYI6oKp/wS6DQLKN7ZgLzJbH6pR9aOwkEJ6sK6 Jx6P+lrF0UGp6Y+Bsiqajjc5+H0eosXlY8uqtXk8WTf+VZwWbNCaV22jRqp40clCCtYeO/ D/skD/ch6ytJWP0DU1umCtBMQH/esfE92saAulOGm8/OT1y23YCPVZ3aptwCcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=f90cd1ae30b5f49e9f6ea58a0628ce1c8d8822bc commit f90cd1ae30b5f49e9f6ea58a0628ce1c8d8822bc Author: Ed Maste AuthorDate: 2022-03-29 17:55:21 +0000 Commit: Ed Maste CommitDate: 2022-03-29 20:10:04 +0000 Clear non-x86 compat stat syscall kernel stack memory disclosure 32-bit architectures other than i386 have 64-bit time_t which results in a struct timespec with 12 bytes for tv_sec and tv_nsec, and 4 bytes of padding. Zero the padding holes in struct stat32 and struct freebsd11_stat32. i386 has 32-bit time_t; struct timespec is 8 bytes and has no padding. Found by inspection, prompted by a report by Reno Robert of Trend Micro Zero Day Initiative. The originally reported issue (ZDI-CAN-14538) is already fixed in all supported FreeBSD versions (it was addressed incidentally as part of the 64-bit inode project). Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34709 --- sys/compat/freebsd32/freebsd32_misc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 01337ea51c50..2b20170bfd2f 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2176,6 +2176,17 @@ static void copy_stat(struct stat *in, struct stat32 *out) { +#ifndef __amd64__ + /* + * 32-bit architectures other than i386 have 64-bit time_t. This + * results in struct timespec32 with 12 bytes for tv_sec and tv_nsec, + * and 4 bytes of padding. Zero the padding holes in struct stat32. + */ + bzero(&out->st_atim, sizeof(out->st_atim)); + bzero(&out->st_mtim, sizeof(out->st_mtim)); + bzero(&out->st_ctim, sizeof(out->st_ctim)); + bzero(&out->st_birthtim, sizeof(out->st_birthtim)); +#endif CP(*in, *out, st_dev); CP(*in, *out, st_ino); CP(*in, *out, st_mode); @@ -2337,6 +2348,18 @@ static int freebsd11_cvtstat32(struct stat *in, struct freebsd11_stat32 *out) { +#ifndef __amd64__ + /* + * 32-bit architectures other than i386 have 64-bit time_t. This + * results in struct timespec32 with 12 bytes for tv_sec and tv_nsec, + * and 4 bytes of padding. Zero the padding holes in freebsd11_stat32. + */ + bzero(&out->st_atim, sizeof(out->st_atim)); + bzero(&out->st_mtim, sizeof(out->st_mtim)); + bzero(&out->st_ctim, sizeof(out->st_ctim)); + bzero(&out->st_birthtim, sizeof(out->st_birthtim)); +#endif + CP(*in, *out, st_ino); if (in->st_ino != out->st_ino) { switch (ino64_trunc_error) {