Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2380399lqp; Sun, 24 Mar 2024 16:51:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXkjHfbwbXT4C638h71RkHiOERYNQ+fHDwtUIOgxhV59fj93leec9oLzBC/Pv75p0jnHiMb+5X0xnbz04Ou8R6QPRw9N8Zwt3cTErs0A== X-Google-Smtp-Source: AGHT+IE+735pEhmvFRhGC3TntibCuBF59IwyLn8RoOGg2yhBLs+CiTVIMMNpMZDLkypIMtxgSWCE X-Received: by 2002:a05:6830:11c3:b0:6e6:cd51:e87f with SMTP id v3-20020a05683011c300b006e6cd51e87fmr4023438otq.8.1711324291802; Sun, 24 Mar 2024 16:51:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324291; cv=pass; d=google.com; s=arc-20160816; b=PJGscCvwQiaEP0QQeyvSrBgpI3tHRqaTX1P0+cFqQ24cty/XurwbNtszLBWfpaJdD9 cQHSkwZh63swOtCG1slezzv9t7bErxOiYneGZo0gvk7ed4HUJgaqAQDE1jsuqI0XsEMB F7JgHcMQpxW9WU8irqb0MtZv58UTMjqqWmeBY8d7D+Z3H2elTtFQ6Kx9P8Nv0DE8P3jt 2pMx+B4cJpNpayahSbvoEzGny1A12InR5h+fRju2J0n9P+g15O6xtgYSKYcly/NkYOrv Or+qjBXp2YDUVwujQRz4syGoJqkkjzK05q5oXx6HsxSIEGQkM8Sbz1o1bc6fMbYaMJDO rRIw== 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=Iq9tkbD1OkPCHFPrKwRIpS5X9EVA3Bt2AeHUUqenVUo=; fh=dgo3dL5Ngz52VJMGt6UDJJnqNktK2XCNXvZPbHFVsmM=; b=YU6GJ0VbkeefVIWLf3OKDg4FfHTmFNp3Sm3zDB5Euu22KAwEdceSp/+XvQo7YYWmv8 KcSYbQEPs56FO29rq7r3MRKz3oujKWPrM12+ropWBz/Aa9cVtC6OCuFtz6aMlYIcutYw oxFwfUkLeQnblFb90Il0ZjyI4VMs3kzC+Kh6mqlg3V0ohBbG01xupp6Je0StW8hYY6XV bzgXQwBAvu1ASvbv8HKUuiFNs/wVX3c37XhJWJl2HvoGI9cShxC3NIAt8yVAZzTvJ2/8 kQRzC10G0U1Z5maUdCNyn4mTM/YhpYAF6xqQkec01Zb7RzogwAXtzLSpY6Y6lsDeSAoE 1hUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FFLRXasI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113233-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z37-20020a631925000000b005dccf9ac073si6391970pgl.282.2024.03.24.16.51.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:51:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113233-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FFLRXasI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113233-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113233-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 24D8428A651 for ; Sun, 24 Mar 2024 23:50:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4470D183BB2; Sun, 24 Mar 2024 22:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FFLRXasI" 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 5AE82183B92; Sun, 24 Mar 2024 22:40:34 +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=1711320034; cv=none; b=jk/XhPPSJ1oy6/tmvQXJVFSR86uDeKQDNN9/dq4fsZrEtLBRIFEEjU1pkehqhAyckf2GrJULaLwN3cSfZKEwxPl4kgKMwjxL8q2l5yTHOTDvDk2nk4zCME2NROm7/+QGPHDN/a6SJPue2XoRIQ1WWV2jHN6sw2Qy9Doa/sQDumQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320034; c=relaxed/simple; bh=Tbtb83D82ba5U9j7pO0kR77XqAV2NqjGsYQcqKEPiH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LOqdsfCOzQ9axX7o34pQ4T/qFGfTrnNHKZfD/PPdt5byRpIK48K4bwVEw8cTeQv2i/BdbaUGR/Ofbi9lDcimhExSpfwUwaz+m8zgjF7dRl8ek/VfjnlLC6tEAQrWcbzIP148u+99a1I2YaU9W9PusesvxS8ImskuyBcZ+fgvNDA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FFLRXasI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41998C43390; Sun, 24 Mar 2024 22:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320033; bh=Tbtb83D82ba5U9j7pO0kR77XqAV2NqjGsYQcqKEPiH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFLRXasI22Tfjx7R9Y89te2gVG/TrLaRx5CpLd60mllYWlRiLv0zZtCdVgvhqgKDm XlVxCryp3dYDE+HgCa+dQn+qNw9n4vBHwuen1F/iJL6m7GUHJwDCqIYf3F1IEk/Nq/ rfhtSm/OGubgYeNDz/tvqxsr+uxT3gr0vPdYQEaLOGdOIskObJgnfW716cVxAmrLz5 Ce4BxeETRxOBgJzakX5FEqXvFrAqypIJqYLkAKp9LlILnN02FVrKaKa6e3m69f+dn3 HntdbS5R+rt693+yFNDn7RuU4TeMbAQubt+eftuBsoJLut+cE64aravO6dUNbYuK7G WqcV1oDF9kdCw== 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 342/715] net/x25: fix incorrect parameter validation in the x25_getsockopt() function Date: Sun, 24 Mar 2024 18:28:41 -0400 Message-ID: <20240324223455.1342824-343-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 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 f7a7c7798c3b2..d18d51412cc00 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -460,12 +460,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