Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2380028lqp; Sun, 24 Mar 2024 16:50:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXE5StZYl1A0DR/mY5BuS0D7ugpZrxEWD/10xwe2ALF62iwxtMD9Db6fm4qxUSDcGgegPwCbHmTDIJHhhix71QTMOG9FLcefB1u1KX6JQ== X-Google-Smtp-Source: AGHT+IGfbjY/VKJrmiX5w2rw/JGvA4bmdrywZZQLAwTPCLJXN1+nzqhO9zN1J7/yG0ODknv8dbF5 X-Received: by 2002:a5d:558f:0:b0:341:c0bd:ab51 with SMTP id i15-20020a5d558f000000b00341c0bdab51mr4189779wrv.10.1711324208391; Sun, 24 Mar 2024 16:50:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324208; cv=pass; d=google.com; s=arc-20160816; b=PauPT9Y6kimqiBYayHhm2Z/cn/NbLf3Gqf3ap0dvuyXng/iQHqttH4lKKazj7pUIPw ikefYXjSTfJ9PtrfjiNutk/g0bMkZaLt1f4Q68oU5Rgf+RH0BLUD7lwkuyvDTcQiQ3Ju JOPZDQ0D3C9UOcGP4ayVcQKU+T0w3DNeRvIgy/1Ct7tMvIBzU/adOGX96GBBGXQWFBhc D/lMHkebj7gJhfnQ2AXLYJsO/gwAGhX4I5VR9RCLasZ7BdPVARWbr4cNaNxD76xveod1 ciayyaiZtNXl9anqyl17Z8WObOmUMWaDI/wlFzQaZikgP85DYZ9J8WnaPK7vcH3Jy9mg PEZg== 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:dkim-signature; bh=jjreBQNonoTDowbAH68CK/pBHZ6sHRw3kF4JMwCboPg=; fh=dgo3dL5Ngz52VJMGt6UDJJnqNktK2XCNXvZPbHFVsmM=; b=etcAmAuj0Zp+lcNVQDZeZNm457i++LD4ZoqPLfZfse0p1RbYkpqbOoxWv6t3eumrPl 3RKYzhHeQiOGlvtN2yY3DuyRelqwJlUaI0MwolgVYN+JoZbpXRe56kM97F79y3c99vfa Wirfd6aZuyHM5yTvMJWbFTOu/sKOi6tXtaSZJ+QH/rEa8mLSlog3MW3+WJ9YeL+HRqNu dQ4thr5OVB89m0qXWCfV+SM6Iy0XJWJI9qerjxsjUojSYgPVyHXBw1GPlReUm7mlaJXy rtxyKvprQrKVvS8Pk9jwMofwtD2AJA7K7/3JWWaBXCsvVZptlIfZamNFMSyA6m6tTWT4 YGag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bdk1dxN5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113229-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113229-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c23-20020a170906529700b00a4747bdb536si1602586ejm.255.2024.03.24.16.50.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113229-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bdk1dxN5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113229-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113229-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1355A1F21E9A for ; Sun, 24 Mar 2024 23:50:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39FD617ADF5; Sun, 24 Mar 2024 22:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bdk1dxN5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 41C2117ADD8; Sun, 24 Mar 2024 22:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320030; cv=none; b=JOUSv5bVaXwCAJ9H7c8m1qREq66+R0wzcBGm5ykbOH4Tvvq6qTSmSZ7+jhyI94A0O09PSvOMiEj25yGao4Aj082AhbwASYSj+YimpQv1M4PnmnHcLByK475F1mh5BIGvTYEvyfk1y/yIkcvIFui2UMIyzj3BWKd6lE2wB5Pqtb8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320030; c=relaxed/simple; bh=EqXoCEfhgL+N/2DamQ2dbWHZzTTUlT7qV+UoCXKktWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qy2C0MqapIixfGvnIk5rh/OUM2mBpTa8YELFYk2h2ww1+/R3bx6NCeIsUiay1GYhrKypAF+6ReRzO/3s40mi6PVq8kGgO9RTXQb7vJwgVLAQ8s3I583SYbBsmRT5iX48lX7je/G/xWJfXVXFdMnfOoSp/8Jlq8aPFzqcgFwVT5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bdk1dxN5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C12BC433B2; Sun, 24 Mar 2024 22:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320030; bh=EqXoCEfhgL+N/2DamQ2dbWHZzTTUlT7qV+UoCXKktWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdk1dxN5ueZJG8D1xEq7hmI8WSJ5ptjeUCQFTkcy8/noQA/VwhjIwFFqS6+iW9Cur +QkhzZqB6d3rFCzSswS8idDOfU0v3o3zsArRireeRguPAzxnUKkVdcT946zSa9NR52 nd6rL9su/eVVj2pSRsRE2qN/EFv2kVKFsPhuP5uH8DqDZzmkibniGoVotOPtLirVsC 6Uq6uBXSgGXiiVHja7nBU5DqNliYnDrRdJAEt/JHJOv5aX6fs8xB0sG2Vn+80USC7g koEsA59NtimlPniXOgXt5DGGCrD8pnCowWqFuh6VOIEjlng3uKUSsxNnexEES6Xg8G 1BmZzfMZjWV1g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gavrilov Ilia , "David S . Miller" , Sasha Levin Subject: [PATCH 6.8 338/715] ipmr: fix incorrect parameter validation in the ip_mroute_getsockopt() function Date: Sun, 24 Mar 2024 18:28:37 -0400 Message-ID: <20240324223455.1342824-339-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Gavrilov Ilia [ Upstream commit 5c3be3e0eb44b7f978bb6cbb20ad956adb93f736 ] The 'olr' variable can't be negative when assigned the result of 'min_t' because all 'min_t' parameters are cast to unsigned int, and then the minimum one is chosen. To fix the logic, check 'olr' as read from 'optlen', where the types of relevant variables are (signed) int. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Gavrilov Ilia Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/ipmr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 3622298365105..b53c36c473a5b 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -1603,9 +1603,11 @@ int ip_mroute_getsockopt(struct sock *sk, int optname, sockptr_t optval, if (copy_from_sockptr(&olr, optlen, sizeof(int))) return -EFAULT; - olr = min_t(unsigned int, olr, sizeof(int)); if (olr < 0) return -EINVAL; + + olr = min_t(unsigned int, olr, sizeof(int)); + if (copy_to_sockptr(optlen, &olr, sizeof(int))) return -EFAULT; if (copy_to_sockptr(optval, &val, olr)) -- 2.43.0