NetBSD Problem Report #59086
From www@netbsd.org Wed Feb 19 00:20:28 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 96D451A923D
for <gnats-bugs@gnats.NetBSD.org>; Wed, 19 Feb 2025 00:20:28 +0000 (UTC)
Message-Id: <20250219002027.557E51A923E@mollari.NetBSD.org>
Date: Wed, 19 Feb 2025 00:20:27 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: vioif(4): kmem_free pointer/content size confusion
X-Send-Pr-Version: www-1.0
>Number: 59086
>Category: kern
>Synopsis: vioif(4): kmem_free pointer/content size confusion
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Feb 19 00:25:01 +0000 2025
>Last-Modified: Sat Feb 22 12:20:01 +0000 2025
>Originator: Taylor R Campbell
>Release: current, 10
>Organization:
The Virtual FreeKMEM Foundation
>Environment:
>Description:
1534 kmem_free(txc, sizeof(txc));
https://nxr.netbsd.org/xref/src/sys/dev/pci/if_vioif.c?r=1.113#1534
1577 kmem_free(txc, sizeof(*txc));
https://nxr.netbsd.org/xref/src/sys/dev/pci/if_vioif.c?r=1.113#1577
The first one (in an error branch of vioif_netqueue_init) is wrong; the second one (in vioif_netqueue_teardown) is right.
>How-To-Repeat:
Configure a VM with a _broken_ virtio-net interface that causes vioif_netqueue_init to fail and enter its error branch.
>Fix:
https://mail-index.netbsd.org/source-changes/2025/02/14/msg155513.html
(but this code made it into netbsd-10 and so needs pullup)
>Audit-Trail:
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59086 CVS commit: [netbsd-10] src/sys/dev/pci
Date: Sat, 22 Feb 2025 12:19:57 +0000
Module Name: src
Committed By: martin
Date: Sat Feb 22 12:19:57 UTC 2025
Modified Files:
src/sys/dev/pci [netbsd-10]: if_vioif.c
Log Message:
Pull up following revision(s) (requested by joe in ticket #1055):
sys/dev/pci/if_vioif.c: revision 1.114
PR kern/59086:
use right byte size of data resource to be freed instead of sizeof pointer
use of sizeof pointer frees only 8 bytes of the large vioif_tx_context struct
which leaks the rest of the memory
To generate a diff of this commit:
cvs rdiff -u -r1.82.4.5 -r1.82.4.6 src/sys/dev/pci/if_vioif.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.