From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 4C51B242D7F for ; Thu, 18 Dec 2025 22:00:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766095202; cv=none; b=W65aTo5AsdyweJPDSPPVKvBzwxPLjIsUSDS63DiXNR/5ozqbv6lFrkeWcofQG6nW9CA6pm45/muZSsK9rM8mlac435Z5Vklsbp09NVjDMXEYp6XZc2j0qaYpjDUuIqjUdwi4J6u5codd1gv4FxjRcLyyWOETTrVS3FlkuGguM3s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766095202; c=relaxed/simple; bh=XKkT2tZz7eWrLkWjuPs0kYDLhUmTVv+sxfAAI2qI3aw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F8O2Dcr6KCCf2++Ft+pHln9MJWP9ayGUYDYnMgTtzPrb2y2qWQqI6oloj3QNLv8XKBaq7mmA0aJD5APa11zsacub0cJSgj6iCdh6rhU836F2uKi4qXu+wN9cWExTNXgRRJuzQpZE2ytaf30JZXI24GmCC201Q4f639lkOX5cDm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nck7VPsB; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nck7VPsB" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-59581e32163so1401508e87.1 for ; Thu, 18 Dec 2025 14:00:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766095198; x=1766699998; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=t/sjp0jU275es5lIyrSH+clAsUhfyndmb5HbMmt8PNE=; b=nck7VPsBZvb6p02J7OTJNRGVUAcZMQKiS2w6iZ9g8i6uX4S9QrGQgXcB8mMBhKvwLo KecGArqO2X3Kt0hBO0iacduPErDaA6vWkXjySm8BuegXDDZklUhJkF3MDX4ScjGZ7o+Q fZO+UhafbQmyHIhewQF9lTpEpwqWUJDDW9CQ3RZvtd28EpaNT5czGEPxFPwKmlUcqhle YTbRrPVNoYpcSQ6zXbAeXwMOsO/TMcS8PmNQWn/3toPpE3V7x92011Xff2r+zitv5DAQ 2Uv52vQK6kXni1FCIQWyBs7aH8nOiedVeszurQEQxTpFdW/LHOSntYaZVxG33WwQ1RgD o4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766095198; x=1766699998; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=t/sjp0jU275es5lIyrSH+clAsUhfyndmb5HbMmt8PNE=; b=H8ObnZ95qCoXAoGjzJvR2JQ7ELwN0bR7d4EHTG+JJfZihn6Se8GocHunmJAZeX9p83 UQLXj/H1kHpqtYl031FHd6xAJCnQmbys75J8iddY2qIdx4zJ1TLqM71iBCqlkULl9l2a roL/oHhn4GcKRgAVPMNdSNc8abPX1fbba6OZdxzSYdsUYkH6JJUGEmuqJz04kQY3rySm q2OMahJ4aDELn9KtoVfl12qnVLG+JHfy0gLD2sfkNLP1JEJtR85JUqRcdhDnil0mx40h J6PBrUfa/i3W46HHTKd2NTScJkdR5uUk5NtGdsXPhQQSYEKXqohkegQUp4BJ/ZfEsJ7g BV7w== X-Gm-Message-State: AOJu0Yyhdrz/UDdhYCIwfRbx2Xmhcjplae/mZr0QpfJS3H2XmBOY4Wxz uLY3tZQqu7HXF5Fr9mA6RYR7IzvDIYmF/fIueusCqw78OAc6P8KZyJsAbK+3ow== X-Gm-Gg: AY/fxX7lcIDbV6PTzo9xx2lhKPYFkxni3y7vNCxODUsaIP2iBge9ISn9shTg0NRs9Cm 2Ja9jlaDLIvxR1urJsOB+0Bi4OKfpKc32Iai+ynh4kyWSUvI0jLrud2YsZPHzNUNk07gTQs91m7 RPhPLiC0UcuVw6WzpSdUzvBEoLB11B47kk5MY56aVFCdBLtOIVR77jbjyDSIOnqopDDIZYO5lqH YHPQsosbAq1KV0eMmjNRKC3S6fSGaDBmBIguoVmFcNmUzIQ6cjLwbXwQZUvAkTmH1G+MwhVESw1 6mLge3PGNTUVb0Xd0tQbdZBXB91QDw10tThHGyAZwP4I/xOK0BzhMHDK3EpCV4UOGReAygH6LD6 HAJAvjjrhJ7WgVn51R9eaSAgHYfPyYPaHSZ0VCBlkXvQ/vwFUZ7xhMtaM4izpyZCwAgfElym2hl LNSheZc289uL2mWJoOveXyS3odfZScNe/NaXmf6Ubr53eVt7ysvaEb X-Google-Smtp-Source: AGHT+IHQbU+iOqzaiFiPp8MK9D9JLLWz5I3nysW2I9Q92SyiIPFWBxMnrn97EMLGECK7bx8NAmxYpg== X-Received: by 2002:a05:600c:4fc6:b0:465:a51d:d4 with SMTP id 5b1f17b1804b1-47d1953b768mr4547825e9.6.1766088919259; Thu, 18 Dec 2025 12:15:19 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be27c2260sm56813515e9.15.2025.12.18.12.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Dec 2025 12:15:18 -0800 (PST) Date: Thu, 18 Dec 2025 20:15:17 +0000 From: David Laight To: Matthieu Baerts Cc: linux-kernel@vger.kernel.org, mptcp@lists.linux.dev, netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Mat Martineau , Paolo Abeni Subject: Re: [PATCH 44/44] net/mptcp: Change some dubious min_t(int, ...) to min() Message-ID: <20251218201517.2f2d91d4@pumpkin> In-Reply-To: References: <20251119224140.8616-1-david.laight.linux@gmail.com> <20251119224140.8616-45-david.laight.linux@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 18 Dec 2025 18:33:26 +0100 Matthieu Baerts wrote: > Hi David, > > On 19/11/2025 23:41, david.laight.linux@gmail.com wrote: > > From: David Laight > > > > There are two: > > min_t(int, xxx, mptcp_wnd_end(msk) - msk->snd_nxt); > > Both mptcp_wnd_end(msk) and msk->snd_nxt are u64, their difference > > (aka the window size) might be limited to 32 bits - but that isn't > > knowable from this code. > > So checks being added to min_t() detect the potential discard of > > significant bits. > > > > Provided the 'avail_size' and return of mptcp_check_allowed_size() > > are changed to an unsigned type (size_t matches the type the caller > > uses) both min_t() can be changed to min(). > > Thank you for the patch! > > Reviewed-by: Matthieu Baerts (NGI0) > > I'm not sure what the status on your side: I don't know if you still > plan to send a specific series for all the modifications in the net, but > just in case, I just applied your patch in the MPTCP tree. I removed the > "net/" prefix from the subject. I will send this patch with others for > including in the net-next tree later on if you didn't do that in between. I'll go through them again at some point. I'll check against 'next' (but probably not net-next). I actually need to look at the ones that seemed like real bugs when I did an allmodconfig build - that got to over 200 patches to get 'clean'. It would be nice to get rid of a lot of the min_t(), but I might try to attack the dubious ones rather than the ones that appear to make no difference. I might propose some extra checks in minmax.h that would break W=1 builds. Detecting things like min_t(u8, u32_value, 0xff) where the cast makes the comparison always succeed. In reality any calls with casts to u8 and u16 are 'dubious'. That and changing checkpatch.pl to not suggest min_t() at all, and to reject the more dubious uses. After all with: min(x, (int)y) it is clear to the reader that 'y' is being possibly truncated and converted to a signed value, but with: min_t(int, x, y) you don't know which value needed the cast (and the line isn't even shorter). But what I've found all to often is actually: a = min_t(typeof(a), x, y); and the similar: x = min_t(typeof(x), x, y); where the type of the result is used and high bits get discarded. I've just been trying to build with #define clamp_val clamp. That requires a few minor changes and I'm pretty sure shows up a real bug. David > > Cheers, > Matt