From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.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 253CD281369 for ; Thu, 20 Nov 2025 15:48:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763653703; cv=none; b=QyNHdADlsjDyUPmG+Px4xc9tZaCZKeowmajkcehSCV7L7dHJnNdPgSt6549MRvfZfEmBHzvSQ7/NohCU/cjJBxmL/HYcNXZFyEqqoWnIShVRB8N9cCCq40p4LAlw2HRA493wInrLX5M5W+C6WzWhovqZ2HZk7KpZaOnWAdkWD7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763653703; c=relaxed/simple; bh=aCn9gZaQVzumD6IQjqIbMMJUqGd/yGdawIRwj+FUhxQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gR9XjzdwhinCRe7kLl4RpcDwNiXjXDQkIBDpkQ5nlkru98ee1TgMa0ZHFMYKoS8rqH13zXi8GmA27Lnhrv3XgKjeDXXH9p3zp1jbDbWY3SXOR7hxxchw1OqiqQu4AFbdpFlGLW8lcy3j57V1xxz/aywpllwoK1n3ORNl4/Urw8o= 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=ajwgUQyZ; arc=none smtp.client-ip=209.85.221.46 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="ajwgUQyZ" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-42b32900c8bso640965f8f.0 for ; Thu, 20 Nov 2025 07:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763653699; x=1764258499; 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=ZTQT/Ft65l/vtNgvHrqGRcFmZM/IEadU1h3kwzC8RRs=; b=ajwgUQyZXyNUzjuN/nDCMF22LJehqHMCrS+lpk7JB7ML4LPfhQAhg/jU5fMNajJVDV 6rvg+XoYepKwQ7gJ20B8VX0xMkae1NbD0cT/GycXZ3sQi1aQQuzd1fjzY11o2k6bKe/Z fJokNilaAoni/1UoNpLwaGoG8pnab5Z2cO2UyLw7/d4hQ4RL65MGWXP3C1pX9zM8fhGl lq2D5N+JtMeVDNqdOWdqQGMCmrtiHMpBYZp6kk6sApnTBAJtN6z2VRpk22Wjhox+GE2V pK3a97Tv1C3AKQgcOENv8KoYDxsSdSIhnvtEN2GhUVDKL1Y4Fn0RREWxkMiS4DU/SYDC ZTlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763653699; x=1764258499; 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=ZTQT/Ft65l/vtNgvHrqGRcFmZM/IEadU1h3kwzC8RRs=; b=obxcBsPJfoAt5PTCeNQYZYLPJOrgeUklkAcPLQE+QCAgZ+ozsmpdnfYenJDrkycY/I QyoM2wRIoYsA99jQoeUcTvKecIrmGR12roK7aV2dd+5Annn2KcivzzoAl/VZ4qS7hliP rQIKTNI2NhUNoS4vCA82DR6BMQsE+/CpCTA6hVvsQOR+X5FP4nV2kmFOlEL7SjP0TYVz jhKYKA5MLyTpLLG6KE92fWPxF0sHyrt7a6MPfGfamaINvfEcRaD9GpQeWQP/+F7JKbAC lt0Lh7kSZ8MKONoYwT3zPirIb8AC3JsmptW4upN+GE1HUOFLK/RhYYHjbSCmzUoVKxhI YqVA== X-Gm-Message-State: AOJu0Yzvv/yBy3uJjqaXJHZdwoJrrjlcKgnvNyzYUudoh9aP0/VdK2ek rjXAveweJCl2OuWG5GhQwzId73b9fAJvUSg3UC+41IxxlylguxKWcV0o8zAvdg== X-Gm-Gg: ASbGncv+L9bNNe3PvJMVAr/Y4JlyxARh55RpAtqWL4ZEVar07nDpQqDhU2sxW2cRcfx YIM80R8z2OkiRjtXYsgXVxmNwMKHDt3ulXAfjFL8JftUnADMZkgfDGI1sPYGhl7/GdxUnA3zsHy u69fczEFJYR1HXu31Zp11twZEg6WJRYoJ4YKpAMOzm6Zu8AHiMFgyALnQQsiKHsCuLtim0mtc75 4/ZESkYMz6C2UWkcgbi9KISJJMUmsA4yKw7yHqrMnv/aDu/mpvECyZTwLC9Sl9GXIYhgsjHSB+O eoT7EGdMDarq2idtoEDVdKVIpOWayvlEnx7PcoO8tubQaVcSdPPy6Z93U8xKQ67FPKrqiJlospo S7OoXRv/+L/Cusoxw8/HEZLLAqnJXvldw/MZ34ndJFlHthb6A1jv8jDACV6S2c5hOkGg3NbcslB 9N81RdDdwqMIRJ/kOocZU4DzMX8jUNA3vfB+flwmBkqLTGPGNs2t9K X-Google-Smtp-Source: AGHT+IG130IcFcxfmIIxu3a8dkYSnRNnzVoOyx2r/mxKGHgE1JL1U38dzXHLcqVCEptCGKDtv+9lCg== X-Received: by 2002:a05:6000:26d1:b0:42b:3978:158e with SMTP id ffacd0b85a97d-42cbb2a4303mr2783685f8f.30.1763653699224; Thu, 20 Nov 2025 07:48: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 ffacd0b85a97d-42cb7fb9022sm6072019f8f.36.2025.11.20.07.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 07:48:18 -0800 (PST) Date: Thu, 20 Nov 2025 15:48:17 +0000 From: David Laight To: Jens Axboe Cc: linux-kernel@vger.kernel.org, io-uring@vger.kernel.org Subject: Re: [PATCH 04/44] io_uring/net: Change some dubious min_t() Message-ID: <20251120154817.0160eeac@pumpkin> In-Reply-To: <3202c47d-532d-4c74-aff9-992ec1d9cbeb@kernel.dk> References: <20251119224140.8616-1-david.laight.linux@gmail.com> <20251119224140.8616-5-david.laight.linux@gmail.com> <3202c47d-532d-4c74-aff9-992ec1d9cbeb@kernel.dk> 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, 20 Nov 2025 07:48:58 -0700 Jens Axboe wrote: > On 11/19/25 3:41 PM, david.laight.linux@gmail.com wrote: > > From: David Laight > > > > Since iov_len is 'unsigned long' it is possible that the cast > > to 'int' will change the value of min_t(int, iov[nbufs].iov_len, ret). > > Use a plain min() and change the loop bottom to while (ret > 0) so that > > the compiler knows 'ret' is always positive. > > > > Also change min_t(int, sel->val, sr->mshot_total_len) to a simple min() > > since sel->val is also long and subject to possible trunctation. > > > > It might be that other checks stop these being problems, but they are > > picked up by some compile-time tests for min_t() truncating values. > > Fails with clang-21: > > io_uring/net.c:855:26: error: call to '__compiletime_assert_2006' declared with 'error' attribute: min(sel->val, sr->mshot_total_len) signedness error > 855 | sr->mshot_total_len -= min(sel->val, sr->mshot_total_len); I'll take a look, I normally use gcc but there must be something subtle going on. Actually which architecture? I only tested x86-64. David > | ^ > ./include/linux/minmax.h:105:19: note: expanded from macro 'min' > 105 | #define min(x, y) __careful_cmp(min, x, y) > | ^ > ./include/linux/minmax.h:98:2: note: expanded from macro '__careful_cmp' > 98 | __careful_cmp_once(op, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_)) > | ^ > ./include/linux/minmax.h:93:2: note: expanded from macro '__careful_cmp_once' > 93 | BUILD_BUG_ON_MSG(!__types_ok(ux, uy), \ > | ^ > note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) > ././include/linux/compiler_types.h:590:2: note: expanded from macro '_compiletime_assert' > 590 | __compiletime_assert(condition, msg, prefix, suffix) > | ^ > ././include/linux/compiler_types.h:583:4: note: expanded from macro '__compiletime_assert' > 583 | prefix ## suffix(); \ > | ^ > :319:1: note: expanded from here > 319 | __compiletime_assert_2006 > | ^ >