Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp1122996lqs; Wed, 6 Mar 2024 07:03:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWbWx76kiZKxA9u3CCx+CkpBQvS8crwSaXUFZSR7gTj360RSsNXwafiKZmrTYj8DJXaTJajITCagwg/GNjTr8nTfxRtPLCHfW7Tck6iAQ== X-Google-Smtp-Source: AGHT+IHtrxjvvYZ1SpeldkN1PHFqvHOfxd4/WfRr4Za4GgNulpHesO/WM2vkF+ZbLScyRPSbRRk/ X-Received: by 2002:a5e:9507:0:b0:7c8:8016:feb0 with SMTP id r7-20020a5e9507000000b007c88016feb0mr209990ioj.0.1709737398620; Wed, 06 Mar 2024 07:03:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709737398; cv=pass; d=google.com; s=arc-20160816; b=kXnlXvvs9PvXwnT8sbAG/x3C3f5byTxrpodJKU5RKv8cBA3wrVh6GAOBU6j7U89kn+ RddLsdO70k+0rGat6i2Qqh7NgS7QR1emlJICwokc5QZaOBwGmYRs+bZs5sgJS6y/20u6 cvuQZrGCYbfiUYsoyScb/jbkt4ceFvU7922V6zzFZzhnwZ64Mv99vNqzYnE8QlwxlQam 1k0FCvL0dLsQYzxXBrZLCqczrP1PwIZFap+d/NeoR1KYPUzgfb2k5pLx84lgVle4dhb3 tx9Mq67YbCBukjry4/hzaoDyNO31Lx9dyumYwJixoSH2xddodYBE6R3sDjOxQ/DttPkG m2ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=AIQwTTuZb/bkpUI1B93DUztoPtr/cSqg9ygDBJUJ4wg=; fh=3qNKWXkqnCBlSehg5U6pXXgWEeEl21gZ7AVXQnHW8ns=; b=wsoIlbBlKvlI8pK35zslCfex8iTiXmPWCg++9qvpfj35fVD7iJeTsTEinEwDjknGTX J8EeEeEkAC1EWDQPk/fPH2rP6LWHPJK2VewqvvPybwkxEQOSYH6yb9UB+EOM7TaVktvg S6szgXIYiW+6O9mViXL7QdWsJ2LomtbF2KN0Ych8b0R6a7RQpXg52oI1Ui2QwtZo0Yo3 Ms7hgyLjn5z79eArn4jcD1JPWtAOxkmJOgbnafm5LJDhHkGdxicmefPXRWabww5Z12vI lqhttQ1O/bZbaTQRiVvjDrImr6hK66C4tSzwJcC1+02WXAL1GY62fQDG7bGUhcE8Ml+u KmIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PCA3pxET; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-94098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94098-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n24-20020a5e8c18000000b007c828dc6b2bsi1658213ioj.91.2024.03.06.07.03.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 07:03:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PCA3pxET; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-94098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94098-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 BB03328A227 for ; Wed, 6 Mar 2024 14:56:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1DB8134CE3; Wed, 6 Mar 2024 14:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PCA3pxET" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E43613473B for ; Wed, 6 Mar 2024 14:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709736959; cv=none; b=h6gzgUdCkVYwR6pq/RCayIQSLerOQIQ9iSb7aUFo9+gKnnCCG4dJT2cJpUVJthg3wCNBMTUJf6JvEuYbWkeeHfI1vAsQl8dE2wEDUvI66hGCYIQy+F4oQchrtoVHmiythnqTkY21GKCNEgj0JFERYZChkm+Tw0Mup0Sr5yY+n78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709736959; c=relaxed/simple; bh=AIQwTTuZb/bkpUI1B93DUztoPtr/cSqg9ygDBJUJ4wg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BNGUAQ4n4PJWP2efWDmcJbRzeDihk2NBiQ/ZqGhZNtucKHF9c2UHDo5WcK3vqouHW5xohpW6QIq7GuRgNo561rGvn50lUTIc9fUuBFTruMXNzqYVK557V4rXfp8/AFk47kmsIXBJgjGnyiY2cFrGd9vBLonpLPCvaPavztXakg4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PCA3pxET; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5654ef0c61fso14355a12.0 for ; Wed, 06 Mar 2024 06:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709736956; x=1710341756; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AIQwTTuZb/bkpUI1B93DUztoPtr/cSqg9ygDBJUJ4wg=; b=PCA3pxETtyhyNcthYqkghg6Y2KQoHBMMzvwveS/aFvk8jlWMAfwxxAFidSZq4HjgAs Zq3t5qhpPcLaz1HYn7A4NMrVmdkowBn/AJiaM2UZtBCKJ2fM63LlfB4y7knxXrjcxapL 0M2yquIhHs3qACve6Hw73Jw5UcBLxnWFrTyjuUzfHHHLyBEC7R6v5FIMwidWLqq88mGs qxON+bFaTGzjIOnvGbr3JmR6hA6XK3H309BXhfUmM736Mhl9E44TtXPGnogYTHStBgeY TzVo05octd4cESPwntuZOXdLhJkfx+qdX4k+nGZhOQZE0fuQsyraS+Jmm0jWHsDo9Zwy cahw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736956; x=1710341756; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AIQwTTuZb/bkpUI1B93DUztoPtr/cSqg9ygDBJUJ4wg=; b=BGHJ5W4WajUI4IsI+URTtC9XkbexptqN65oeg/5odJOv1B3HiioYX6IMQG1Nk8opx+ CV7b6D3HBrM/gHRDi85h6gxylnzYeGi4k2uPwIhZZmeUhnzqRKKJ9ykeQy54EmCf8Hop 5NQhluJFbrw1HpjvGf9I09ZWN+v8gM0wiLrClQ340bWGtbo3ahhPcFNftRngUOFpwaTN xdAydS1CXTTaPthQSbc1dOna7jTYT0d1L5U8w6NIvV9GKs5M0teS5/A3oRpXpJ6Fax6Q w3VRUZqbrJ0PFNz366SqZIa8xe40eoDGbPCU3+HaHOXJPPHDHMpGF5uGCSC64ZZFC3y/ Oviw== X-Forwarded-Encrypted: i=1; AJvYcCUzSJEKjgGEPOHdYbdkGnZzVz+qZATGEnBwXea/oUo1tbERGTVk64us9rHGOjZZR8w2Hus8YRR5YpTWKuOp0OI6sfy3Wq3WTPhZYsIC X-Gm-Message-State: AOJu0YwBWG3ExM5ldkXNnHMR6tGihms+9NO6PLt0xxM5DobbeM1xhbLF TT0LJLfY4tL8j8lrMConLmb2N7/8cYKAn8x3wUTsmk7+suSkSclozs2QhyqZbXFWn69h4UqRDyJ oxBVGxPTtyzu8SVpTXqyiYgEnVBFRDLePAH9q X-Received: by 2002:a05:6402:11ca:b0:567:eb05:6d08 with SMTP id j10-20020a05640211ca00b00567eb056d08mr154089edw.6.1709736956088; Wed, 06 Mar 2024 06:55:56 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240306095430.1782163-1-Ilia.Gavrilov@infotecs.ru> <095ce1d0f2cd6771b30ab1d73ee6aa8e8460c7c8.camel@redhat.com> In-Reply-To: From: Eric Dumazet Date: Wed, 6 Mar 2024 15:55:45 +0100 Message-ID: Subject: Re: [PATCH net-next] tcp: fix incorrect parameter validation in the do_tcp_getsockopt() function To: Jason Xing Cc: Paolo Abeni , Gavrilov Ilia , "David S. Miller" , David Ahern , Jakub Kicinski , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "lvc-project@linuxtesting.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 6, 2024 at 12:57=E2=80=AFPM Jason Xing wrote: > > Hello Paolo, > > On Wed, Mar 6, 2024 at 7:36=E2=80=AFPM Paolo Abeni wr= ote: > > > > On Wed, 2024-03-06 at 09:57 +0000, Gavrilov Ilia wrote: > > > The 'len' variable can't be negative because all 'min_t' parameters > > > cast to unsigned int, and then the minimum one is chosen. > > > > The above is incorrect, as the 'len' variable is a signed integer > > The 'len' variable should be converted to the non-negative value as > this sentence: > > len =3D min_t(unsigned int, len, sizeof(int)); > > See the comments of min_t(): return minimum of two values, using the > specified type. > > After executing the above code, it doesn't make sense to test if 'len > < 0', I think. This is essentially dead (defensive ?) code. Most compilers optimize this completely, no big deal.