Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp965896lqs; Wed, 6 Mar 2024 02:07:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQbRYisuWxt+ITkiUZIYQzm1Z7L6fKrdYQmjXqDL73UZEDcIuaAIkggNa/8Z83XGcMXKNZxXg6IY9G0VhpIpNztk/1sCiBo+osbB2n3A== X-Google-Smtp-Source: AGHT+IHedChjA8ewUH/QcGPJU96ZKpHO5XxGcpyBvHG4Cq/Baga9ai82LQ2sOD3hHN1bKrXdNX5G X-Received: by 2002:ac8:5804:0:b0:42e:9146:a0bd with SMTP id g4-20020ac85804000000b0042e9146a0bdmr5419667qtg.49.1709719620700; Wed, 06 Mar 2024 02:07:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709719620; cv=pass; d=google.com; s=arc-20160816; b=XWyn3J9cl9GMFRgmUIXlUHtHthr0rxSHNtjqjfYcHh2OshR/8n16ho3dlbl7aWLFzv Ls0fMHQXOd4Bnq2wcLtNIuGzBV9NGf60r5RYBYgg/c4TiNzOnB/EkbcnD9Qd2XcICqlJ dHiC4xJju6L7TsXJA5j152ChmS01kLQRNyrHHWBqnI6FM4BMkmQFB5Mnt4haOcAXqkOJ CAMHMOKcjc7SHD6mULrqmCXbaielSGgB1vUhrUC+wAwcLM3Fl6LxnAncccgdSrfZYhTq eJXtXCBsjlQgELzx5YiTzffzbIWH9f5qtzIG1KQvHkph0DVv/vk1ziomruNK7dJWn/nA 0a5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature:dkim-filter; bh=gPbzrGqFAouR5hcLlY+gaWABmi/r7e8R71W/dDRlrQo=; fh=fGDOmjW7GqYcV8tkuPX2Cetw6gnt8HF8zfzVyVY2yZk=; b=oJq6GtjwTsOIzGxqRmg3HOxXcGeFSFnhPmHcq3DAOByp1jZjB4hgcb3MUH2JZA930k Xk07xGu2NLEfYBthNx2bF8TLsijHgyYdj04czKzgeTMnktVtUvTVq68XPfLB8SOkVXaU GCIMghQrYo5vDZDNJlm/dwgIieeL8/xzS7rngkcWqryvPOnbsQJxIgQ6rNITyfn7lCKl R+n2xJSY0X2QuXH7ONL0/FJzMPpnQzrXYazqrXu/edJW0XxLr2Tle2MbQEOmcrSaQ1WH OtmCOBRiIDHdJiUC+ZUIN69dr+xPKzHro9Km6muYZNcs/zUpz4G0KV9+LryJZCKX4dJ6 WYpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infotecs.ru header.s=mx header.b=iqN75l99; arc=pass (i=1 spf=pass spfdomain=infotecs.ru dkim=pass dkdomain=infotecs.ru dmarc=pass fromdomain=infotecs.ru); spf=pass (google.com: domain of linux-kernel+bounces-93701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m12-20020ad45dcc000000b0068f9cca90d6si14245884qvh.353.2024.03.06.02.07.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 02:07:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93701-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=@infotecs.ru header.s=mx header.b=iqN75l99; arc=pass (i=1 spf=pass spfdomain=infotecs.ru dkim=pass dkdomain=infotecs.ru dmarc=pass fromdomain=infotecs.ru); spf=pass (google.com: domain of linux-kernel+bounces-93701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=infotecs.ru 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 2F3BF1C23BD4 for ; Wed, 6 Mar 2024 10:05:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B7815FDB5; Wed, 6 Mar 2024 10:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=infotecs.ru header.i=@infotecs.ru header.b="iqN75l99" Received: from mx0.infotecs.ru (mx0.infotecs.ru [91.244.183.115]) (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 39E635FB8E; Wed, 6 Mar 2024 10:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.244.183.115 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709719502; cv=none; b=bT+It/fJKP2uDQ3fywjgvqCO0AD909jUw2LVRMUCzZ4opBMXgdIXsqwrtheH9ZGT+OIna8AGHFGtfXATrRSOSjWqYaPnAndnrc+9nwMUaRQxi5m922f+nY3Nqp2A8zRs/g6WfvzthFgy2sQPrG+8RBs5FMJNn1p6ScjyFBweywY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709719502; c=relaxed/simple; bh=EWA4DLGnGdG+5TPbOBKZ5Nq7PebMpaY+EX9+K4hAu3U=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=tNnuWhXSkmGJnOcxpHrhpJZLiOaoTVRI/QYucmGLqGrWhejbTH39eRjvCN8R29q35VLKFc4enW2X8uVzD7QFCjQCuN+KI3awajvz7SlRwo7x/eGdRkvRMGseQQkJZuW7VG5k56dRzk6lMk77AiYLQxFxHia6DitRRghAvuP52mE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=infotecs.ru; spf=pass smtp.mailfrom=infotecs.ru; dkim=pass (1024-bit key) header.d=infotecs.ru header.i=@infotecs.ru header.b=iqN75l99; arc=none smtp.client-ip=91.244.183.115 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=infotecs.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infotecs.ru Received: from mx0.infotecs-nt (localhost [127.0.0.1]) by mx0.infotecs.ru (Postfix) with ESMTP id 57A63146F491; Wed, 6 Mar 2024 12:57:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx0.infotecs.ru 57A63146F491 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infotecs.ru; s=mx; t=1709719077; bh=gPbzrGqFAouR5hcLlY+gaWABmi/r7e8R71W/dDRlrQo=; h=From:To:CC:Subject:Date:From; b=iqN75l99x7FQJ+5q5qvplWjk4gb5A7O4j4tg7R5dfJ7F133VobzoPJsIDGxCreiJH Lqwndu6/so9GDDTIcWEVpwIM6ZRbMjWY1INeH3QAbvRtCrIWzkiXEHugkJXvrRTw+Q 0ASiAj9E2P23k0Gy98XzagN8kEqgqXjaCAFJ8nh4= Received: from msk-exch-02.infotecs-nt (msk-exch-02.infotecs-nt [10.0.7.192]) by mx0.infotecs-nt (Postfix) with ESMTP id 54DF3318FDDC; Wed, 6 Mar 2024 12:57:57 +0300 (MSK) From: Gavrilov Ilia To: Willem de Bruijn CC: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "lvc-project@linuxtesting.org" Subject: [PATCH net-next] udp: fix incorrect parameter validation in the udp_lib_getsockopt() function Thread-Topic: [PATCH net-next] udp: fix incorrect parameter validation in the udp_lib_getsockopt() function Thread-Index: AQHab6zDS4CyiiE6UEiU3tkyNekepQ== Date: Wed, 6 Mar 2024 09:57:57 +0000 Message-ID: <20240306095436.1782250-1-Ilia.Gavrilov@infotecs.ru> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-exclaimer-md-config: 208ac3cd-1ed4-4982-a353-bdefac89ac0a Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KLMS-Rule-ID: 5 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Status: not scanned, disabled by settings X-KLMS-AntiSpam-Interceptor-Info: not scanned X-KLMS-AntiPhishing: Clean, bases: 2024/03/06 07:48:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2024/03/06 02:14:00 #24008090 X-KLMS-AntiVirus-Status: Clean, skipped The 'len' variable can't be negative because all 'min_t' parameters cast to unsigned int, and then the minimum one is chosen. To fix it, move the if statement higher. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Gavrilov Ilia --- net/ipv4/udp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index e474b201900f..17231c0f8830 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2792,11 +2792,11 @@ int udp_lib_getsockopt(struct sock *sk, int level, = int optname, if (get_user(len, optlen)) return -EFAULT; =20 - len =3D min_t(unsigned int, len, sizeof(int)); - if (len < 0) return -EINVAL; =20 + len =3D min_t(unsigned int, len, sizeof(int)); + switch (optname) { case UDP_CORK: val =3D udp_test_bit(CORK, sk); --=20 2.39.2