From nobody Wed Oct 06 20:09:53 2021 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 6D83112B9B86; Wed, 6 Oct 2021 20:09:54 +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 4HPltB0sCrz4qCg; Wed, 6 Oct 2021 20:09:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 ADE42264C4; Wed, 6 Oct 2021 20:09:53 +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 196K9rtP069528; Wed, 6 Oct 2021 20:09:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 196K9rJY069527; Wed, 6 Oct 2021 20:09:53 GMT (envelope-from git) Date: Wed, 6 Oct 2021 20:09:53 GMT Message-Id: <202110062009.196K9rJY069527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 880b670c6fdb - main - malloc: Unmark KASAN redzones if the full allocation size was requested 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 880b670c6fdbd1268887869375771e0a74d2c8ac Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=880b670c6fdbd1268887869375771e0a74d2c8ac commit 880b670c6fdbd1268887869375771e0a74d2c8ac Author: Mark Johnston AuthorDate: 2021-10-06 20:03:30 +0000 Commit: Mark Johnston CommitDate: 2021-10-06 20:09:41 +0000 malloc: Unmark KASAN redzones if the full allocation size was requested Consumers that want the full allocation size will typically access the full buffer, so mark the entire allocation as valid to avoid useless KASAN reports. Sponsored by: The FreeBSD Foundation --- sys/kern/kern_malloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index b1c5909db2a4..4ecdcdacce01 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1112,6 +1112,13 @@ malloc_usable_size(const void *addr) else size = malloc_large_size(slab); #endif + + /* + * Unmark the redzone to avoid reports from consumers who are + * (presumably) about to use the full allocation size. + */ + kasan_mark(addr, size, size, 0); + return (size); }