NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/60752: compat32: memory leak in netbsd32_do_semop error branch



>Number:         60752
>Category:       kern
>Synopsis:       compat32: memory leak in netbsd32_do_semop error branch
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 20 11:30:00 +0000 2026
>Originator:     Taylor R Campbell
>Release:        current, 11, 10, ...
>Organization:
The Compat32 Kmemoryleak, Inc.
>Environment:
>Description:

	Missing kmem_free in error branch with timeout argument:

    226 	if (nsops <= SMALL_SOPS) {
    227 		sops = small_sops;
    228 	} else if (seminfo.semopm > 0 && nsops <= (size_t)seminfo.semopm) {
    229 		sops = kmem_alloc(nsops * sizeof(*sops), KM_SLEEP);
    230 	} else {
    231 		SEM_PRINTF(("too many sops (max=%d, nsops=%zu)\n",
    232 		    seminfo.semopm, nsops));
    233 		return (E2BIG);
    234 	}
...
    246 	if (utimeout) {
    247 		error = copyin(utimeout, &ts32, sizeof(ts32));
    248 		if (error) {
    249 			SEM_PRINTF(("error = %d from copyin(%p, %p, %zu)\n",
    250 			    error, utimeout, &ts32, sizeof(ts32)));
    251 			return error;
    252 		}

	https://nxr.netbsd.org/xref/src/sys/compat/netbsd32/netbsd32_ipc.c?r=1.23#251

>How-To-Repeat:

	code inspection

>Fix:

	consolidate error branches (or, better, start using
	__attribute__((cleanup(...))))




Home | Main Index | Thread Index | Old Index