NetBSD Problem Report #55509
From www@netbsd.org Tue Jul 21 20:19:03 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 1FECF1A9213
for <gnats-bugs@gnats.NetBSD.org>; Tue, 21 Jul 2020 20:19:03 +0000 (UTC)
Message-Id: <20200721201901.E92901A9217@mollari.NetBSD.org>
Date: Tue, 21 Jul 2020 20:19:01 +0000 (UTC)
From: n54@gmx.com
Reply-To: n54@gmx.com
To: gnats-bugs@NetBSD.org
Subject: npm install -g electron crashes the kernel
X-Send-Pr-Version: www-1.0
>Number: 55509
>Category: kern
>Synopsis: npm install -g electron crashes the kernel
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: chs
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 21 20:20:00 +0000 2020
>Closed-Date: Mon Jan 11 18:17:47 +0000 2021
>Last-Modified: Wed Aug 17 16:45:02 +0000 2022
>Originator: Kamil Rytarowski
>Release: NetBSD 9.99.69 amd64
>Organization:
The NetBSD Foundation, Inc.
>Environment:
NetBSD chieftec 9.99.69 NetBSD 9.99.69 (GENERIC) #0: Tue Jul 21 21:32:24 CEST 2020 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64
>Description:
Rewritten manually:
kernel diagnostic assertion "semcnt >= 0" failed: file "../kern_uidinfo.c", line 241
chgsemcnt()
ksem_release()
ksem_close_fop()
closef()
fd_close()
sys__ksem_destroy()
syscall()
syscall number 256
>How-To-Repeat:
Install nodejs and npm from pkgsrc.
$ sudo npm install -g electron
/usr/pkg/bin/electron -> /usr/pkg/lib/node_modules/electron/cli.js
> core-js@3.6.5 postinstall /usr/pkg/lib/node_modules/electron/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
.... and kernel crashed
$ npm --version
6.14.5
$ node --version
v14.3.0
$ pkg_info npm
Information for npm-6.14.5:
$ pkg_info nodejs
Information for nodejs-14.3.0:
$ pkg_info nodejs
Information for nodejs-14.3.0:
Comment:
V8 JavaScript for clients and servers
Requires:
libuv>=1.37
libcares>=1.6.0
icu>=66.1
nghttp2>=1.40.0nb4
Required by:
yarn-1.22.4
npm-6.14.5
Description:
Node.js is an evented I/O framework for the V8 JavaScript engine. It is
intended for writing scalable network programs such as web servers.
This package holds the latest release.
Homepage:
https://nodejs.org/
$ pkg_info npm
Information for npm-6.14.5:
Comment:
Package manager for JavaScript
Requires:
nodejs-[0-9]*
python37>=3.7.0
Description:
npm is a package manager for node. You can use it to install and
publish your node programs.
Homepage:
https://github.com/npm/cli
>Fix:
N/A
>Release-Note:
>Audit-Trail:
From: "Chuck Silvers" <chs@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55509 CVS commit: src/sys/kern
Date: Mon, 14 Dec 2020 23:12:12 +0000
Module Name: src
Committed By: chs
Date: Mon Dec 14 23:12:12 UTC 2020
Modified Files:
src/sys/kern: uipc_sem.c
Log Message:
when updating the per-uid "semcnt", decrement the counter for the uid
that created the ksem, not the uid of the process freeing the ksem.
fixes PR 55509.
Reported-by: syzbot+9d04b3ef2ca180ef9b06@syzkaller.appspotmail.com
To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/kern/uipc_sem.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Responsible-Changed-From-To: kern-bug-people->chs
Responsible-Changed-By: chs@NetBSD.org
Responsible-Changed-When: Sun, 20 Dec 2020 23:50:01 +0000
Responsible-Changed-Why:
I fixed it
State-Changed-From-To: open->feedback
State-Changed-By: chs@NetBSD.org
State-Changed-When: Sun, 20 Dec 2020 23:50:01 +0000
State-Changed-Why:
can you confirm that this is fixed for you?
State-Changed-From-To: feedback->closed
State-Changed-By: kamil@NetBSD.org
State-Changed-When: Mon, 11 Jan 2021 19:17:47 +0100
State-Changed-Why:
Fixed.
Raw reproducer:
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#define _LIBC
#include <sys/ksem.h>
int
main(int argc, char **argv)
{
intptr_t id;
id = 0;
_ksem_init(0xffff, &id);
setreuid(0xee00, 0);
return 0;
}
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55509 CVS commit: [netbsd-9] src/sys/kern
Date: Wed, 17 Aug 2022 16:43:01 +0000
Module Name: src
Committed By: martin
Date: Wed Aug 17 16:43:01 UTC 2022
Modified Files:
src/sys/kern [netbsd-9]: uipc_sem.c
Log Message:
Pull up following revision(s) (requested by chs in ticket #1501):
sys/kern/uipc_sem.c: revision 1.60
when updating the per-uid "semcnt", decrement the counter for the uid
that created the ksem, not the uid of the process freeing the ksem.
fixes PR 55509.
To generate a diff of this commit:
cvs rdiff -u -r1.55.4.2 -r1.55.4.3 src/sys/kern/uipc_sem.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.