Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2380075lqp; Sun, 24 Mar 2024 16:50:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnX3BSI6RC+BwOxjcXEgizufbmAZu32scJam0N3wfZdCZFxtkRsr6xidSm7g672gGJt7/Iq8s2z7nYRpLLhnPMY0iQ3KaiTD3PuG8HTQ== X-Google-Smtp-Source: AGHT+IHvy5lxM6sdrd9dWD4dWON5Vt6DlSQtFC76sxF3Hkp2xZWr3bE5u9evBeemjGGkVyL6IBar X-Received: by 2002:a05:620a:2945:b0:78a:54b1:1da3 with SMTP id n5-20020a05620a294500b0078a54b11da3mr3272004qkp.1.1711324220976; Sun, 24 Mar 2024 16:50:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324220; cv=pass; d=google.com; s=arc-20160816; b=kRK4YSoKCU3vqQN9octtB91hdR6SRpCf7q2vwOuBNYP6gzfS6Ct5o8k9jbwjqIb6fC S09GUvFC7HooH+kGvxHRdKunUYJe/k6Kyf/qRCYUOnGCrouR47EDH24W5idi7SeLtvTw b5xXi+jlPpKe67sI19ZAdUqySh925uo00hVqNumfFYNuXk3ijOx0qgxaNd3G9SsM7Yal OUT4zvEwt7jKW5vXjf5fSi9K+tqSMQe64vcHlsV6efV9X1Qx4WW1S7EV+P92aAWO5r32 fZNpWfobQPgDc8KSbUtXwTVkSLqpIush4VcAfsBJm1ytGasteO/+kE/GVX9exTujPUIi UZww== 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=ooigjyoyV0rVdRDzTGexY4DekevjnWOvAmposyPgw6w=; fh=+iamld+pzIaip9PhfcrfuplwlUuwsrXlqnf2AkeoSUg=; b=I7R1uVAEs9hsYpAfOECDPiUgPxHf0Lp0cKVVJ8kr4+sfdClS71FvN9KQjsan5GAr5x g8QBQKD4JiasIKRufhrfIW12edes72dVYhg7/wW8+Zez+uogfF0wqTDE3tVGCKL3rbB8 qADEm+gyRKh3soc5ou6txoKGnlKJHVUWdWCYNs3ywv+ihMLrJ8L8yQ1aVoKD+8Sh99yw a7bQ3MHg5kixxCmkUmCV1+/oaBgdkhIBjPOcbQyc9a2PO/3Y+/hRPhMi0yCIC+HPaHEO UHTwYbuuJZhtmcHzPitLuxMOK1D3RCUMQ0KyqtjV/oJccMZ8oqvEd7i3OCGeLl9jiESp J0oQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aYULRwlJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113230-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d3-20020a05620a240300b00789de1262edsi4827023qkn.380.2024.03.24.16.50.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aYULRwlJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113230-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A8BCE1C22A63 for ; Sun, 24 Mar 2024 23:50:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28D7313C8F2; Sun, 24 Mar 2024 22:40:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aYULRwlJ" 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 4015317ADF6; Sun, 24 Mar 2024 22:40:31 +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=1711320031; cv=none; b=OgklmFEm1YsMOaWGEB32FtCmO92gFcTWxATOTgvmoGctXWqRIUdPTWver6jD1BsgxkLSwp2QL1MMIbSss/gVF2vavwAvvsutO+STZXYxq03CL3IqfI9fWTkyPDzyCNGE4ZH43G97ilFJ+6Id4K/ojvHtV4GKwbJzeO3bt51/QmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320031; c=relaxed/simple; bh=OQsM+h49KmJCuY/Vc4xjJEjsD2hIGGvvSko+Q3j56jk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TL4C4y2Au/FwgTgGWTPFdKcXvtvxZPg4uOy0rpPB6UsdrQh2N3AxTb1GdZkoVIYtcOL/x3ftnIGXuG6flDCbBcLVUUhizIFC/Oxnx3RJmncXuJN3M8TpYUv6p65xVdcKpnolClvv0gRg/QniH/1s99rO2LgTgCHG477ZL2A1mgY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aYULRwlJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66660C43399; Sun, 24 Mar 2024 22:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320031; bh=OQsM+h49KmJCuY/Vc4xjJEjsD2hIGGvvSko+Q3j56jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aYULRwlJ/djr+dv4WDo+TDKpLcYJ0GvckMxx/YYGjUh2gEh33KoOOnG7lO/YlZijO pn6IPfDIhvWvDmqZm6qZ0+7U3nQ+e37bUCAV/kXKv18pvA6Ae+y22zKO49SQaGkgER kDX2n77/BTzE+wZqqkJ1kPXB7fGO0iQCheRK/25kXldCBUXKCDj4U/sArXqI+hrdrs IaqEqk7cRamQubfvC7zITvvg5e95yr7pALaNuKVQayjHumgNHJVCaVRLsslX0tmf8F Q8QvtBkXcjLwkdi9k0L+FLCibGc7sAnmBDs02wzwnOb++cLEqU+0NZk6er6+Ktpck8 4XVm6UU4iOkoQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gavrilov Ilia , Tom Parkin , "David S . Miller" , Sasha Levin Subject: [PATCH 6.8 339/715] l2tp: fix incorrect parameter validation in the pppol2tp_getsockopt() function Date: Sun, 24 Mar 2024 18:28:38 -0400 Message-ID: <20240324223455.1342824-340-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 955e9876ba4ee26eeaab1b13517f5b2c88e73d55 ] The 'len' 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 'len' as read from 'optlen', where the types of relevant variables are (signed) int. Fixes: 3557baabf280 ("[L2TP]: PPP over L2TP driver core") Reviewed-by: Tom Parkin Signed-off-by: Gavrilov Ilia Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/l2tp/l2tp_ppp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index f011af6601c9c..6146e4e67bbb5 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -1356,11 +1356,11 @@ static int pppol2tp_getsockopt(struct socket *sock, int level, int optname, if (get_user(len, optlen)) return -EFAULT; - len = min_t(unsigned int, len, sizeof(int)); - if (len < 0) return -EINVAL; + len = min_t(unsigned int, len, sizeof(int)); + err = -ENOTCONN; if (!sk->sk_user_data) goto end; -- 2.43.0