Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2660619lqp; Mon, 25 Mar 2024 06:02:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVHMXT7qH8D/8heLUOHhVhIqzkSvLHd8BxaCva1nLRGzPQQ2cczc3TzLrzSo6+YYsU7VH/7E+Rv+O6FCIimg99nuxhKKLxZi/oLBmv4A== X-Google-Smtp-Source: AGHT+IFq180blSOjPpgnJmvfuh8y/zOCifS3pT/PmbshdKTeeeNJJ1vDbAee7zMGelqr8WLfxHGY X-Received: by 2002:a17:903:22cb:b0:1dd:7e2:b9c2 with SMTP id y11-20020a17090322cb00b001dd07e2b9c2mr9405522plg.10.1711371773754; Mon, 25 Mar 2024 06:02:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711371773; cv=pass; d=google.com; s=arc-20160816; b=K3FbmL/mYe1Fy13hDOKbdfb4ImfxNy/6IKVQI2M89X4uBRa1JkIBgHamiGDbIi8T++ zRevrhMs1ym6P89Ub9IjoxF/afdL2lkKO0jZX76qm7G7wsy4O1/x7u53/svnW6dhFtqE K+3HpUgo1EugbDxWFTW1fI06cdJb/4gU44I1l6Sddmet/UVk2dtAvHtwk/WYrbGHmFfG XcOYANRBZIPbEBnnU38jk6BU9cOXT2NAge6mV78TpApmDwVP7MyPDsa8dLmNCkOBbwkw +G0VRNeqHB56D57ANoyCdAFUEg8vH8Pbptfve9+4mjXMpPzLi9+dPysvB590h8aEyTZ6 Jhpg== 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=6LV/qa13SVYCZWak/mgzveirLp1OgNfLwjmiXXtr2JM=; fh=dgo3dL5Ngz52VJMGt6UDJJnqNktK2XCNXvZPbHFVsmM=; b=sQo7IfYFLSMCfX2PBB/e5fnBgL6NbS2y9mP2MfYi+FRdpnyE+3BYfLhNf8Z/KtQe7m V9genqZi30SCjqWPiM+2gyAxHuCkFn5AJ3yHz60+G8ZMa4+ybSOhE0Ol7WmRLL1dDgh9 W7ivvfwqbVhC8Vlj7n6aZTdN/Dtvg/4UpAy75ZitgaEx7c4FExgFb4hYzv9OvKT+M+Ck BpKQG733JX2cnEjyhnscd62iS3K1k8EdYTWhsrPHld5rm45CXqKLxforqinhB+hl89lW dCwbVgmZNZI2QLtpT0NzL7+PPa5MzBThO8jR2isvc5LDdn7I6lhSfRB1/pe4nrDuMpg7 eIXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JdnD/51P"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116164-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e4-20020a170902784400b001e0afd270d8si3479165pln.302.2024.03.25.06.02.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:02:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116164-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JdnD/51P"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116164-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116164-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 26CCFB2BF9B for ; Mon, 25 Mar 2024 10:18:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9DDA3B4839; Mon, 25 Mar 2024 03:32:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JdnD/51P" 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 5DFC75C612; Sun, 24 Mar 2024 23:42:15 +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=1711323735; cv=none; b=DYSt9AjuyiUM5WcRj7mJ52M2c29r5ytwppC6vkHSWaqyugFEtVDK/kt/P7CMG6jMdobu4OFG2FBjIzbZ0f6IH/3WCKJ4zQH71II3yaYQGh3GleDxwKfbsNomh/b5r27vpNYLkbsA1KryXmpXhN2bX5jCj+TpK6uClRt5K+Vq8Xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323735; c=relaxed/simple; bh=b/wMywr+EGLN30fL09KtdBNQj6X+lx9C77tGafzwHN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hvEBCjgF6FdAMy/GoXSa8+nANadheNsC4+iscOJ6jH96hHUIgbmSx3vnb8LL4rtGE/m0A8wx645rTrXOac2z31UkYIt8hApH5DfIClJblY5gnxXCpPUpg1uPwz/DeVZJC48LEuZDsaY6g7InxgFgeAGhiVuGOkRk4hMKZFHxJBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JdnD/51P; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99C3CC43394; Sun, 24 Mar 2024 23:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323735; bh=b/wMywr+EGLN30fL09KtdBNQj6X+lx9C77tGafzwHN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JdnD/51P+w4MtdeO1ws9YnDqYwClXEDlI/a5ggIqLhig8feQwPA6KGZ/lbC0+vd12 x+axgdKVVerc+/t+qqBVuooBEx1Sc4UBEj0n6Fw+49THq9/KBJQCFHALgIHCbgxLE3 pku61c39wRD4xDJVnVvh1jKqaMs9AoFfNWDj+KpLigGKmGnRRvXQVrPXtEu4gz7SXv dBeemMiSOeRG9cRQILef78WawyrBJLgNdAtigb3psPIlLi8w8N0B76hl89MnbyF+4A srbqf4Op7qhPYg4QLBmehCdztR4JPXJezlHL0UDtFmUm6mg8mpGxiIF2ayqeK5+ZQk xEDgxheJN0kmg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gavrilov Ilia , "David S . Miller" , Sasha Levin Subject: [PATCH 5.10 109/238] net/x25: fix incorrect parameter validation in the x25_getsockopt() function Date: Sun, 24 Mar 2024 19:38:17 -0400 Message-ID: <20240324234027.1354210-110-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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 d6eb8de2015f0c24822e47356f839167ebde2945 ] 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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Gavrilov Ilia Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/x25/af_x25.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 161dc194e6342..a7ecf2956cdd6 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -470,12 +470,12 @@ static int x25_getsockopt(struct socket *sock, int level, int optname, if (get_user(len, optlen)) goto out; - len = min_t(unsigned int, len, sizeof(int)); - rc = -EINVAL; if (len < 0) goto out; + len = min_t(unsigned int, len, sizeof(int)); + rc = -EFAULT; if (put_user(len, optlen)) goto out; -- 2.43.0