Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2489307lqp; Sun, 24 Mar 2024 23:15:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIG2uORcdQYBmsZ+1nsIbB6eomEl2NtuzE7EhxjetKNkQGx5P/w3M04taMHoU8xepJEQtB3t793ZedaDutaIzTGlxG5xu7ejHRDMsMhg== X-Google-Smtp-Source: AGHT+IFlLBwPKzlTeMR3NKKo70H9OUx5ALmYzecRciYJSb6oaAVp9/6wtW2lXUS0sHJRfT9hJXII X-Received: by 2002:a05:620a:1103:b0:789:e8fb:9fb9 with SMTP id o3-20020a05620a110300b00789e8fb9fb9mr6328241qkk.57.1711347306671; Sun, 24 Mar 2024 23:15:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711347306; cv=pass; d=google.com; s=arc-20160816; b=QmN+DOLbfivPLmBUbG6G4IFYXD/SAMYletrsqEsKrVDzPWWZBXEiN7lKQqGLzYaD0c voLx1/K7ylfbQiuO4ma1Q/Yd3+JNRCs2v7IR3pju2lPn265MH0inodP5KxLMUXkB9brx Phgf2FZLkCC6uVLsKEmqPFvjKMTzy65O8MQ7gzcG/XDqSnsV6LxGhjQxQaobnH9jvHQT H7XGk8Hi4vKtwyc+Y8bVM+h17SgTvMjeX0ZcS8ckWRdJ55x+ujnY0xeChJRXzMkTjkxb LMbJhrOcboIutJjKLLdCNJLoSh56ienx4r82qiOzU+SYZthymAbO9Hcq3z2Z8bhd41H5 5FTw== 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=LsMN7KoIA/EUt4B6VDNBrvUXd08mZan/Px7X2lvYW1I=; fh=dgo3dL5Ngz52VJMGt6UDJJnqNktK2XCNXvZPbHFVsmM=; b=yxco8bdH8cB/E5PDjvYS4EGHdb0EKKCVnn2HH7Ow/8moPx7vmt/VPDVufPc6Yjn+w+ XuCLpDwfyc+rxswatwiayHR/q9fQZTSFoXYYiIXgyYeN5L/FXc6r2MXuav36vlEaPoKE WyN5pSKt/u0dZsUGXf/yZUSx9OOeOH7GzmAksMqYMDoO9qD2292GJTB+NHpmKDV+hJuU cPzJOD/iLQWsSmuqs6btWLMlHwc8PYUs2bh+jAONdR8Y22uRlJcb96cgax9DGWfdZ7LV 6WhhiASKyVrg6uC7+7ZlPAJRFcIK339lbbxC1pk5RxzBFRse5Pr9PmsSGHM4qPtFqF0d BW+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vs134Gea; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114528-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. [147.75.199.223]) by mx.google.com with ESMTPS id i12-20020a37c20c000000b0078a3c669016si4629632qkm.70.2024.03.24.23.15.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vs134Gea; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114528-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 67E8E1C2C2E2 for ; Mon, 25 Mar 2024 06:15:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCD2722B68C; Sun, 24 Mar 2024 23:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vs134Gea" 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 0BF1822AB8E; Sun, 24 Mar 2024 23:15:52 +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=1711322153; cv=none; b=hx7h1XDjpYQEYe6b3V7USmhaS13H7GKpwSt9a/NFKZurUEgpgahSgD3sVewrV+uT1gk/d43jf6okr/Eaz0Lnqc8W3nIfashhI05IBHDeqMVgL48gKg9uNrafuxOfNn46qwMR4+5T2PMELqRuw9g35N3bLA5NVsDBXKR0PnE6DsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322153; c=relaxed/simple; bh=CbLgNHq9wuBDvXwk6sKhAkCYE4QpPtRCb8lxBQLNJHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XUNf7FJMfAccYPazURJbBlIr6mRnfVBy7nHd+YAAG48lydlEV1C21CpsjMKTSGlHA+n/uxUifHzrniiddzIN2m+OJX4C/4DHfOV4wC6RXJNoZpWxHvgWO5ypxlbg1ZMftg9PQx4HLF2PwEFtLuP7IEBFhYtgp5LE4ND/8lsr5ys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vs134Gea; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 499F3C43399; Sun, 24 Mar 2024 23:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322151; bh=CbLgNHq9wuBDvXwk6sKhAkCYE4QpPtRCb8lxBQLNJHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vs134GeaL7PR8u+haNfq3TrQqUHXMKcYxH/5uY7UkV7DBhIAPpDQ85mkMhjYuzr8k wLcAX2k6iTQAezKIBNEOqM3QYv7Bmdwmo0G2q9IWeixuUOwNtR7JfTUluXyoFAFRYv 3p9z96kGEA/lcEJvkQti+wnA1q/nKn2b8qIaYwOLqTFN9jThlSHL12IBCWmEvCDj3u M1Swng5lZfBYD90qTjyw2KGjIoGQs2TJcdOl4IYhM7jZZRzfDxHcslA0JD2Ypl4+7c aBF1y++SlaStLwScL0HfT0x2CQqjcRvvlSPVrYzeSIBJ1RCofjeZwD1/CR8KUc3iK3 x4Qwf9gyXKmDw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gavrilov Ilia , "David S . Miller" , Sasha Levin Subject: [PATCH 6.1 229/451] net/x25: fix incorrect parameter validation in the x25_getsockopt() function Date: Sun, 24 Mar 2024 19:08:25 -0400 Message-ID: <20240324231207.1351418-230-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 5c7ad301d742e..5a8b2ea56564e 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