From nobody Sun Feb 8 07:26:51 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E47E5472D9C; Thu, 8 Jan 2026 11:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767872337; cv=none; b=Hps2l/WyyhlDsbQZbLmEZgBlw/BfFj/9LcbwMcgU002w9NIXNYu7y3sbxPyMm9FR+PbpRBZtt0Q/ZtAyq9rl4dNpjJ6avQnWzAWzRe3mDw9hvURq8lBvEX7+YGhbUI3W8YlB7JXg7SAAkM9ppceKES+vRlg5GmJoYzjbKWKVW/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767872337; c=relaxed/simple; bh=+eR7D2KfjGbkCbqsLHlFXsILmSKDTy5psf3XB+R6OII=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=BoNw6QA67d/uutG1BtNBHbzF2CtOgJCimeJNkMrRrznWrzkNGUho+oVoLKpsh/HXSFVETferLuDWy2y/iRvv1oo6+i316ckQGsRCptnrdZRDWb2Ney9PcLxGKKPRswFEWCHzgffyA5gDPifX9IYldKLju6gGyIEXHcAxZR/YEKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=uq+YrUWW; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="uq+YrUWW" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=HLCPfAXg6GTM4ywBo/4+C+lNGOv5NAwx0aGaiPbwG/Q=; b=uq+YrUWWosb2STJC44y1jKd86CZCBHO7eZwoQnPAmlNwnTX4Np7OeAmZR10XStdlQayS6h21M embsNOGS8ZVsHF65qunIq+syHS7P6uFvRBrOrorlxdTUy5cb9S1l/HhjqyJzG/7AsbGuhrvUGyY pxQWSE2/koPLEDh927qsFeo= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4dn2s02t67z1prKY; Thu, 8 Jan 2026 19:35:32 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 6F7A24056A; Thu, 8 Jan 2026 19:38:50 +0800 (CST) Received: from kwepemq200002.china.huawei.com (7.202.195.90) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 8 Jan 2026 19:38:50 +0800 Received: from M910t.huawei.com (10.110.54.157) by kwepemq200002.china.huawei.com (7.202.195.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 8 Jan 2026 19:38:49 +0800 From: Changbin Du To: Mauro Carvalho Chehab , Jonathan Corbet CC: , , Changbin Du , Mauro Carvalho Chehab Subject: [PATCH v4] tools: jobserver: Prevent deadlock caused by incorrect jobserver configuration and enhance error reporting Date: Thu, 8 Jan 2026 19:38:36 +0800 Message-ID: <20260108113836.2976527-1-changbin.du@huawei.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemq200002.china.huawei.com (7.202.195.90) Content-Type: text/plain; charset="utf-8" When using GNU Make's jobserver feature in kernel builds, a bug in MAKEFLAGS propagation caused "--jobserver-auth=3Dr,w" to reference an unintended file descriptor. This led to infinite loops in jobserver-exec's os.read() calls due to empty token. My shell opened /etc/passwd for some reason without closing it, and as a result, all child processes inherited this fd 3. $ ls -l /proc/self/fd total 0 lrwx------ 1 changbin changbin 64 Dec 25 13:03 0 -> /dev/pts/1 lrwx------ 1 changbin changbin 64 Dec 25 13:03 1 -> /dev/pts/1 lrwx------ 1 changbin changbin 64 Dec 25 13:03 2 -> /dev/pts/1 lr-x------ 1 changbin changbin 64 Dec 25 13:03 3 -> /etc/passwd lr-x------ 1 changbin changbin 64 Dec 25 13:03 4 -> /proc/1421383/fd In this case, the `make` should open a new file descriptor for jobserver control, but clearly, it did not do so and instead still passed fd 3 as "--jobserver-auth=3D3,4" in MAKEFLAGS. (The version of my gnu make is 4.3) This update ensures robustness against invalid jobserver configurations, even when `make` incorrectly pass non-pipe file descriptors. * Rejecting empty reads to prevent infinite loops on EOF. * Clearing `self.jobs` to avoid writing to incorrect files if invalid toke= ns are detected. * Printing detailed error messages to stderr to inform the user. Cc: Mauro Carvalho Chehab Reviewed-by: Mauro Carvalho Chehab Signed-off-by: Changbin Du --- v4: set self.jobs to b"" instead of [] (so no type change). v3: format exception with repr(e). v2: remove validation for all bytes are '+' characters. (Mauro) --- tools/lib/python/jobserver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/lib/python/jobserver.py b/tools/lib/python/jobserver.py index a24f30ef4fa8..616411087725 100755 --- a/tools/lib/python/jobserver.py +++ b/tools/lib/python/jobserver.py @@ -91,6 +91,10 @@ class JobserverExec: while True: try: slot =3D os.read(self.reader, 8) + if not slot: + # Clear self.jobs to prevent us from probably writ= ing incorrect file. + self.jobs =3D b"" + raise ValueError("unexpected empty token from jobs= erver fd, invalid '--jobserver-auth=3D' setting?") self.jobs +=3D slot except (OSError, IOError) as e: if e.errno =3D=3D errno.EWOULDBLOCK: @@ -105,7 +109,8 @@ class JobserverExec: # to sit here blocked on our child. self.claim =3D len(self.jobs) + 1 =20 - except (KeyError, IndexError, ValueError, OSError, IOError): + except (KeyError, IndexError, ValueError, OSError, IOError) as e: + print(f"jobserver: warning: {repr(e)}", file=3Dsys.stderr) # Any missing environment strings or bad fds should result in = just # not being parallel. self.claim =3D None --=20 2.43.0