Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2508318lqp; Mon, 25 Mar 2024 00:17:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWxQ58igW+T7l/1RTY3Iw0TZb3WI4+puJGxah4M8k9NpnT0bQ1QdhUmk0hmmX6Rto6Pb4jRYPy5mZmWWS4pZjNdQJWU5xVqsV96azAbA== X-Google-Smtp-Source: AGHT+IFAkBnB/AJIPVncRVDhiXf3rTNhSwZkPtaT4Va5Mg+7zpzzRVIy63Aa/vJOelcAujN2+65l X-Received: by 2002:a17:903:3204:b0:1e0:972f:de7d with SMTP id s4-20020a170903320400b001e0972fde7dmr6970856plh.5.1711351022322; Mon, 25 Mar 2024 00:17:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711351022; cv=pass; d=google.com; s=arc-20160816; b=hp0/ygYkl6Le4Kc0HvcU+19VvSQYTkz/xLoV1NPu9dcKUg0UAhOQKkRkc48xDHkdVU OmhLt5HcYiqBAeTtsQtavPSVvUCCh3b5prU9XJ2+WotAZiTrB24bsi/h5aeW+lw1YNcI UmGS/44PVFAaugzE6oqX3bhtmcPblODOAujEMH/wj03hZ0oexwN13/Jr0BFWY0DUIHGh OFm81DfqVEq3siwIh3/7SamT0peLEDi1FJyzRX3KtG4xO7YIcy5ss+dnCrs3KfN5MMBp aIjwKggekQTwLBgd5RFiQHI/3B+REwURXm/URA/Y8boCukoMQna4+LksXk1NHv6DMVM/ rZmA== 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=y4OxC3zTZAuaDYUUKGdmweZtY50VKjBste0+YHa3+ZA=; fh=dgo3dL5Ngz52VJMGt6UDJJnqNktK2XCNXvZPbHFVsmM=; b=nd90uEsJ0G/INvZnLRvDLjjIelp/TmzRifqq4lzmQBkifEtjhxzuVzAwg2/mVZIOKc uSyAHryhVVT68ICbLY3AoKS7NeEk7M5pXx0thjQ+huAnlph1MSU3ilvmgXLbFolvYExR fq8P0Et7nf7E+NWPUJzBj9R7MYeHKpswzWJy/b19EFy21n/vQ3ehtLcsSQvvTyg+cb5h IaLySnvbG5SpDUSAt5NSbHwisO2cwCzuzfQVjHc0d1gQv6raZLw5Fs54pt7BZ2s0y92P dRz0VpeLlpdukL/bBD+ztUMec3/9R5yRaKcm2HE6e0zG1le8li5DWe0lRqWyyghkyf9A g8ww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NhDCFYsc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114826-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 w5-20020a170902e88500b001e0a29aa038si4492460plg.19.2024.03.25.00.17.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 00:17:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114826-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=NhDCFYsc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114826-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 B0C9EB23FAA for ; Mon, 25 Mar 2024 06:43:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB68F2C099D; Mon, 25 Mar 2024 00:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NhDCFYsc" 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 4F90A278998; Sun, 24 Mar 2024 23:37:29 +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=1711323450; cv=none; b=uvRSPw0BuhNcVdVZVArs8cirsVZfaduozOi0KIZfNtaoiJsjD/EiZIwJsCV0E3RYVXajNKkUtCODRyXrGNmezkIKJS7WETqyo8MC9q7KFQUr4EfdiYluxqf4Fs14uPJFgr1GeE1ZypwQzielwO5U/S5aZGNW0Z6eDjHomMWZLwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323450; c=relaxed/simple; bh=fRURc9EA+Wjz171uYkXIOhdPEisDxnzCuFLmzd7uGvk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KUhBmJk5RwoLLJZS2B2NluKf/Ss6GCjWm3v/agzRl6VMuwUStdKc7YR1B9UVZaTOadKj3tg++fGzmpQyfZ8ZhrvtUOJPuyLxuR31AANcJdqFHrG6D9MhpSnmI5CdfG4lgmOca9tKEMVNbbEZrFG4Pt7zqul8plp/9o0fUknTa8Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NhDCFYsc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ECBEC43394; Sun, 24 Mar 2024 23:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323449; bh=fRURc9EA+Wjz171uYkXIOhdPEisDxnzCuFLmzd7uGvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NhDCFYscYM8o+voEkqJdXEeA1t/zfVZ2X5NwQDrG+jfQrYscgLPjdIFsdBnC1Di5B zuBD9LfgDvcngCb4KPvwnPAkJKSv0dfbtPRUv5OfJwZHv0AkNXzNECqCyuul6x0FMy WtyKJ9cx5+DinhjKXJomJyQ9BCRKq8pLMjGqz1Q0VLva+NgA7JbVr/6BPw4FLG1gEu I3h9vI4xLi7ufccaWK+FlcKQvG7PT8exXKJBB4OUucNyps1VnYFXgyGkFPBPe0IOjb k1cusa3gfMVVYzKKJsRMm4LuTffPnV7wOejC+AE6eQFNElDlqAFdb8kSzeX1YCgmob pjxhmqfJbqvNA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gavrilov Ilia , "David S . Miller" , Sasha Levin Subject: [PATCH 5.15 152/317] net/x25: fix incorrect parameter validation in the x25_getsockopt() function Date: Sun, 24 Mar 2024 19:32:12 -0400 Message-ID: <20240324233458.1352854-153-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324233458.1352854-1-sashal@kernel.org> References: <20240324233458.1352854-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 07f6206e7cb47..1e5152fdee589 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