Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp592132lqi; Thu, 7 Mar 2024 06:24:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXhZ5DNTIKG8OzLHUSdCZaALOaTuoL5L6Zoayr+kYCesZ1kiF2f3A6b9D1YqdHF5qFRteJgn22++0GW9QEdxLiNTICC9kBMQeB0w2wwaQ== X-Google-Smtp-Source: AGHT+IE++J77aOPacw4zbr/YjnAjJxvU72JvOosfPz7dMR80+FH7nKwOxfxaHMupcfeEef8ME7ia X-Received: by 2002:a50:9f67:0:b0:565:9f59:b3b6 with SMTP id b94-20020a509f67000000b005659f59b3b6mr332334edf.3.1709821494256; Thu, 07 Mar 2024 06:24:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709821494; cv=pass; d=google.com; s=arc-20160816; b=btYXCftl6VUQ+60AxSVxsMG5JMnvx/0GujtXw23r6ZYT4pchfjWv8xVH3He3GGMtnr FhfvWUCzVE4j8RZ7TwBJ7u46gCEjy112MU7pIsAHbP7cU0n/VQ8TaN8fiJYfLDiuD3os fyuKuhdPkC7wg5ZlH3JyBbSCfEL6jXBwBzF+NNLRheizvHOaQZDd3qsl9HACm4ZvXI7w QgKyYUK32UwYokuIPErzxHyN3eFW3O7Yanqqshk+lhhmGkNBvCQXV6VqLixyumMZts0R dY0WiqueBuPOSM9HVCO6y78Idx/nTuuae/0XGiuIvcW1nYXeESx5e+9xIrbvH+hch0bQ fI6w== 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 :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from:dkim-signature:dkim-filter; bh=jwhtPOdDBSnbts5GSh1Hp50/yNRBHBaJHIGVXA5KGK0=; fh=JrUXji7fCBEKV9Wv1A8ZhThUd1V2rrReR6KLCPAd03A=; b=DJ0PdMBF7nx9cyAJOQsWTa6YNv4JHLAwUYYfTxCNmh53VdbPzGvTrH5IOnOPTIn697 wKrD3/jifZlsXgToxjWjRRt9xbn9H5sEVwn8aVWLc22AoEodhp3CwMzSXOtUvkZDTf5f 1eOz2Rz8hQoGXea0/4gcYb6mp3cI1lDXtvqlogg2J6lpXOWMpqJdHSId1HWsIoB3aqVn C5YoRf9rJ0NEaUV6q+bdhTqAhcgMO4dc4+AXeeNJaQ2DnMLTVSfAcCIsSVv5/DEibKWP wSzif1lCpgXb0oEbI/U64cIjh7FDKvOlxZ5xOmP8rfGxVNtHn7NJsOTzrTb1Oruj5hUv lsPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infotecs.ru header.s=mx header.b=BHDg436W; 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-95724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ig12-20020a056402458c00b005681ee6b2c4si160222edb.641.2024.03.07.06.24.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 06:24:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@infotecs.ru header.s=mx header.b=BHDg436W; 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-95724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95724-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 am.mirrors.kernel.org (Postfix) with ESMTPS id EDA1B1F22F6F for ; Thu, 7 Mar 2024 14:24:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35B8312F58F; Thu, 7 Mar 2024 14:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=infotecs.ru header.i=@infotecs.ru header.b="BHDg436W" 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 A4C0912D745; Thu, 7 Mar 2024 14:23:52 +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=1709821435; cv=none; b=KxQgsfD7QZlf2jOH6s3rGLdfJ9McvchUE13coP/kV9iwjkTlq8C7t0pEmAdrYhlKeoOaPZ6qQStlAj0qheswNM0tjo/exh2addlkMBV3ksSW0rQA4EZuDnjXChnB8GyltXOw/ZleDPtTG2zhGrbHjL5cr9IiWda+o2MXJhsVfaE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709821435; c=relaxed/simple; bh=CEXkOS+mriQWsWIUYob9llJ3dlmRIkZyGVNcMX66MRQ=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=B4MGGbLbo1nDpGED9LGHD5fVdUOO0Ib2SeSG0q10y0P64KU+6GFn5knKLwr3pgwfM0XhorHMhNxASF2wtxGdkUoG/unmWjc66MATYz4juiwH1GAHh2k8k+JWkqh6hhnwnHAGefbcXCemt3scu4jxPJTRrNz3mbkdcs4pf23Grr4= 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=BHDg436W; 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 9E4EB14CD2A3; Thu, 7 Mar 2024 17:23:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx0.infotecs.ru 9E4EB14CD2A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infotecs.ru; s=mx; t=1709821430; bh=jwhtPOdDBSnbts5GSh1Hp50/yNRBHBaJHIGVXA5KGK0=; h=From:To:CC:Subject:Date:References:In-Reply-To:From; b=BHDg436WgP0hlp57M+1zZLDvLpDPdST9IJk9inpZGrX3QoU1kwxYrleLbqICi3gHL QoEcogViHS5b3jihvPMxcSvvQah2x3IVQR3IncyCBLChMWIW8mkV3lThxCGtFeRFcB zfKdKlkla7/N2Kan8Ym2UplTiwMxvq5/NX7CoPpA= Received: from msk-exch-02.infotecs-nt (msk-exch-02.infotecs-nt [10.0.7.192]) by mx0.infotecs-nt (Postfix) with ESMTP id 9979431923B0; Thu, 7 Mar 2024 17:23:50 +0300 (MSK) From: Gavrilov Ilia To: Willem de Bruijn CC: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Simon Horman , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "lvc-project@linuxtesting.org" , "Willem de Bruijn" Subject: [PATCH net-next v2 2/6] udp: fix incorrect parameter validation in the udp_lib_getsockopt() function Thread-Topic: [PATCH net-next v2 2/6] udp: fix incorrect parameter validation in the udp_lib_getsockopt() function Thread-Index: AQHacJsSjDbf8+7IiEaacwBYhQfFYA== Date: Thu, 7 Mar 2024 14:23:50 +0000 Message-ID: <20240307142030.2708698-3-Ilia.Gavrilov@infotecs.ru> References: <20240307142030.2708698-1-Ilia.Gavrilov@infotecs.ru> In-Reply-To: <20240307142030.2708698-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/07 13:22:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2024/03/07 10:14:00 #24028863 X-KLMS-AntiVirus-Status: Clean, skipped 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") Reviewed-by: Willem de Bruijn Signed-off-by: Gavrilov Ilia --- V2: - reword the patch description 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