Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1357085lqb; Thu, 30 May 2024 08:01:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcC8ojfBLnASJ7DOitUReb/BgygfeepmZq4q3+GW7sI2nZoCPyg5aGE3LfQtaK2RUiL+G0tF5fHNTEaQPB/PW1O73M+q31UWxRMgjl5w== X-Google-Smtp-Source: AGHT+IFCMrSKv35gh5HdK3FlfNyePk5PjixunHg5qKqdN/24jEbtxFo0JXjEYwjhamDLF1st2b1k X-Received: by 2002:a25:ac0e:0:b0:dfa:57e4:2df8 with SMTP id 3f1490d57ef6-dfa5a5e77ffmr2665911276.23.1717081277737; Thu, 30 May 2024 08:01:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717081277; cv=pass; d=google.com; s=arc-20160816; b=ejT9XN3sHU89WiY+La0VF/zlHMTfhApevzZ/QB8yrBw7BD1N9got0WSuJvKwCLCRvV 9eHAIXzec+/leu0/eDnwTu6Cfrp546+RE4Ph4uU4BgAfD+7JaQrRPsL4yZpIFoSKGpQQ SGCbuyBg1sz5whTuoTGQ+LCzCx9ugQEeL17NNbSuLNbGkiR709lwUgftxd4KxwaJeLa9 NeXpojkIOkw1AOZ0JWg/qrzu9rDbc4Al+TzHw4kqADg4H5P4VdQJC+7CXOK5G+/lFSky pXbOHLJitVF4emd48OfuHJSjY/rKgtPguF3VIaHFygtrzTjKHNq6/z7sVghjalM/h4uR TgtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=q5NfhVeNaT+0lRkxQUdF8m2fB/4Z4CT2F/YlLWNs8dg=; fh=uo5u2TQK/HQlhydMwGLjBAnuDwaLxndJ/cgWTjIagS8=; b=o51TxAGFo5q0MARG9tfcHfKLhicoOG/kmssKZ8gh4UKsqFJu8ssk2qnTrM9Ye1m9NJ Ig2loxeckjOBmOFKrUiw2Zfx9ZkNjdHhDLL4gm/9mSaLkAjkzClu893YHNWdfYZwxqcv 71p7cz1bX7/KxK+4XBGzYyhp4HbscdxGPNi9C4thwc0BkPQI2Y6JdKeFlBkKw71khPmT sTduUdmm++T1QgDamJNls6XrPkHioqsnKplg1nAE79XmqC78IXQNEg2UFcps1LYRKh9T 4DvDZLgkkfqn9aU4G9GIc4kZ3/oeA+EK5lvWE9Ea0HPM3o099aFeN8NZRjnpVumPBFfO GH9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-5038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5038-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 3f1490d57ef6-df78e594367si5695129276.117.2024.05.30.08.01.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 08:01:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-5038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-5038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5038-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2B3231C23BA7 for ; Thu, 30 May 2024 15:01:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56D7A16F0DA; Thu, 30 May 2024 15:01:03 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 C3BF0145A01 for ; Thu, 30 May 2024 15:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081263; cv=none; b=tE6bqGfsqFufnGdGi5I8puc0cx5L9Fax8M6omxHnNWvx2eg9bzbK8Gl9TA45ZtJg2Xz30Iw1VZ1bOX0Cc22QUgcN5DA3Fz5W4kbbg9JYXd6NsS4MXWHjUXv8seLK+G8YUXgCJm7zvCZAeWSC+bKFVHF+9mI/OZ2QzkxhDFTZd0w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081263; c=relaxed/simple; bh=zTCzTXSatAKZBJ5sPdSyoJ6iX/dT7b91Sw2MA+Zf84E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=awN6c04v7ai8bbI43vOPfA+bRfxgPAtUSnqrEPqUW08OpxtliZ7CDoxeq/0LFYKseA9IK6vLH8cLzlAaB79s+vhMf50227i824qvTiFDDlOWcZqP0U6od60erEvfjoNMvneM7HpBHsbdj4IXhiDckOceNa4/qp/hgabv4HurKU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 1F8522000F; Thu, 30 May 2024 15:00:59 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ 5/9] shared/mainloop: Fix integer overflow Date: Thu, 30 May 2024 16:57:59 +0200 Message-ID: <20240530150057.444585-6-hadess@hadess.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240530150057.444585-1-hadess@hadess.net> References: <20240530150057.444585-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: hadess@hadess.net signalfd_siginfo uses a u32 for the signal number, but siginfo_t uses a signed integer for it, so an (unlikely) big value for the signal number could result in a negative value being passed to the callbacks. Catch that and bail early. Error: INTEGER_OVERFLOW (CWE-190): [#def44] [important] bluez-5.76/src/shared/mainloop-notify.c:132:2: tainted_data_argument: The value "si" is considered tainted. bluez-5.76/src/shared/mainloop-notify.c:137:3: tainted_data_argument: "si.ssi_signo" is considered tainted. bluez-5.76/src/shared/mainloop-notify.c:137:3: underflow: The cast of "si.ssi_signo" to a signed type could result in a negative number. 135| 136| if (data && data->func) 137|-> data->func(si.ssi_signo, data->user_data); 138| 139| return true; --- src/shared/mainloop-notify.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/mainloop-notify.c b/src/shared/mainloop-notify.c index 33be3cf8d78e..11989512e013 100644 --- a/src/shared/mainloop-notify.c +++ b/src/shared/mainloop-notify.c @@ -15,6 +15,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -130,7 +131,7 @@ static bool signal_read(struct io *io, void *user_data) fd = io_get_fd(io); result = read(fd, &si, sizeof(si)); - if (result != sizeof(si)) + if (result != sizeof(si) || si.ssi_signo > INT_MAX) return false; if (data && data->func) -- 2.45.1