From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 D574D2F5B for ; Wed, 19 Nov 2025 22:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592147; cv=none; b=FmTb8Vbi1iMcMFPQ9rYac1ZihtdaHycUfXpIaxJNDh4bd5AB59k6za8eyFZ0zFftoX+8XTj1qe620uoZ5wQUUEdPrQc925FdTbYsdr607WBv1Cqs6uXmE2zB8jQplaJYe3n8qlf2hX2VBTjudWYwL7OYrCbRq08aJkEmkEf3oig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592147; c=relaxed/simple; bh=6yWhhXYgGcUn4QL9ghlc+Ij4NW7mP0lIKRznCASuiwI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=un9t89pk5ri0/hQRKEbDRz5LPBmaKoxkr180K1lGUJNxLS2yMtr3PTTzv8hvfFkdiCBzEO/h9pkpJg6l8+N6zwdx93IqETienvbJua9OijgL6tZoWZo6UamgsHDYlb/XfX4jC0roi1z7T592fbdVPyMiU615ajZsedgw9rQc/4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=pTSbZE29; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="pTSbZE29" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsP-006klz-Vz; Wed, 19 Nov 2025 23:42:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=E5Q/Ca74NTiVrvwxl/o3FqU3Ejo/I/sQOiFlEnXH7TE=; b=pTSbZE291mpIF33Oql0ZIyr7kF fkFBLAlpeY68Zsn3ti4+jN0nPby2+cDoBUzJ27NGRozmgJKG6/bKKyd0YHK1XdXCOR4oCZDx9VldQ bugZ9qH+PScmtQmSlxRBo+WWl4WG7aKj8z/CWY2ks9r5w+1REdSkivzOpjt4cVD/RwH7iYlg80M7C BFEpgBD8s9RMHWPYRMdXWokUDGE7reEkwdv2D3iSu9lVmFPX/+8FC+P3YtfFTjpFftq9Nx4lOK/rv +aNSE9ZuNnG2zYsXBV8eonS3XVcsiJMAaRjIZXbGNpzROkMEAfeTHo+5pRGrA/b8EOV8eXpRw8GSh JifZWE/Q==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsP-0007ze-Md; Wed, 19 Nov 2025 23:42:13 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsF-00Fos6-29; Wed, 19 Nov 2025 23:42:03 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner , x86@kernel.org, Yury Norov , David Laight Subject: [PATCH 01/44] x86/asm/bitops: Change the return type of variable__ffs() to unsigned int Date: Wed, 19 Nov 2025 22:40:57 +0000 Message-Id: <20251119224140.8616-2-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The return type of variable__ffs() is currently 'unsigned long'. This makes the x86 __ffs() be 'unsigned long' whereas the generic version is 'unsigned int'. Similarly change variable_ffz() and ffz(). This may save some REX prefix on 64bit. Detected by some extra checks added to min_t() to detect possible truncation of large values. Signed-off-by: David Laight --- arch/x86/include/asm/bitops.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index c2ce213f2b9b..2e8a954d2e2d 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h @@ -240,7 +240,7 @@ arch_test_bit_acquire(unsigned long nr, const volatile = unsigned long *addr) variable_test_bit(nr, addr); } =20 -static __always_inline __attribute_const__ unsigned long variable__ffs(uns= igned long word) +static __always_inline __attribute_const__ unsigned int variable__ffs(unsi= gned long word) { asm("tzcnt %1,%0" : "=3Dr" (word) @@ -254,12 +254,10 @@ static __always_inline __attribute_const__ unsigned l= ong variable__ffs(unsigned * * Undefined if no bit exists, so code should check against 0 first. */ -#define __ffs(word) \ - (__builtin_constant_p(word) ? \ - (unsigned long)__builtin_ctzl(word) : \ - variable__ffs(word)) +#define __ffs(word) \ + (__builtin_constant_p(word) ? __builtin_ctzl(word) : variable__ffs(word)) =20 -static __always_inline __attribute_const__ unsigned long variable_ffz(unsi= gned long word) +static __always_inline __attribute_const__ unsigned int variable_ffz(unsig= ned long word) { return variable__ffs(~word); } @@ -270,10 +268,8 @@ static __always_inline __attribute_const__ unsigned lo= ng variable_ffz(unsigned l * * Undefined if no zero exists, so code should check against ~0UL first. */ -#define ffz(word) \ - (__builtin_constant_p(word) ? \ - (unsigned long)__builtin_ctzl(~word) : \ - variable_ffz(word)) +#define ffz(word) \ + (__builtin_constant_p(word) ? __builtin_ctzl(~word) : variable_ffz(word)) =20 /* * __fls: find last set bit in word @@ -281,7 +277,7 @@ static __always_inline __attribute_const__ unsigned lon= g variable_ffz(unsigned l * * Undefined if no set bit exists, so code should check against 0 first. */ -static __always_inline __attribute_const__ unsigned long __fls(unsigned lo= ng word) +static __always_inline __attribute_const__ unsigned int __fls(unsigned lon= g word) { if (__builtin_constant_p(word)) return BITS_PER_LONG - 1 - __builtin_clzl(word); --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 817FB339B30 for ; Wed, 19 Nov 2025 22:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; cv=none; b=Ni4lfKdLGqRnjdwRWsImsoZmk991pBekl7XEU32Ows9TjIWCJVX1Kpzm6f14AUAw803yaehyReJ1gLz+JW0ZDeeMdEsv+7hugSGi/xKe/o5MjfZu37mO6v1CSroh6gQBnGSMKUw767EQZjYO5U8aswvqYt8eL1lgzhle4OpzJ+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; c=relaxed/simple; bh=B+CuVWSEnjv6apDf8L5h6dPvWF5EKrerRkT/3SM1e0A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LEN0/cC9P+ha1RW+uyxRxkS5YlsjNVIEh1yHJ+qmBy7Ffr/GaMzXYFw9kZjM/u8OIckkb0XSIq95y1auc9NIKQkRf6sbXxGgFAToXuyPKM7b8LSH2Xoj0BZdThGFbMpH58zvNGe27mwaUtpoimZvKl0rYywAJgAsGXrqviylEOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=u+FTl50r; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="u+FTl50r" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt5-006kzI-Lk; Wed, 19 Nov 2025 23:42:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=j9oCSSBZzBkPtvRfjBAuEGRtwy0B7xvGWFsoQtyzxh8=; b=u+FTl50rmEe/5i/+MoBpS2Q33D 6kgaICrHucVByc3skpZ+Y9wZV0GCSGmHsVxzszm0YG2B/KLufryU8cwnsPlFNfaRvjjg2uhJJX7ft jsWlK2n9WJWr/pukLGQRvyCQSjv77305Yj1/M7pmg0jt9UiGwWKys2AjlKk48jC8JfSrZwX1X6Tuz 8KLvDNn8r0Gkw6zETtheN31hMHIQGskvPIxqa/TgERIIcc/wAZvVNeSoZYF6j1pggIgnVV7+2Xkn/ mJ6zxZbLUedzV+ktQyPIH5+ui/rrWqfWnfOWJ/FVV1RVMFomp4YqIfPkJuoAl40KwvXaB+eo9UwHc IahpZXbg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt5-000873-7o; Wed, 19 Nov 2025 23:42:55 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsU-00Fos6-TH; Wed, 19 Nov 2025 23:42:19 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Andreas Dilger , "Theodore Ts'o" , David Laight Subject: [PATCH 02/44] ext4: Fix saturation of 64bit inode times for old filesystems Date: Wed, 19 Nov 2025 22:40:58 +0000 Message-Id: <20251119224140.8616-3-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight If an inode only has space for 32bit seconds values the code tries to saturate the times at the limit of the range (1901..2038). However the 64bit values is cast to 32bits before the comparisons. Fix by using clamp() instead of clamp_t(int32_t, ...). Note that this is unlikely to cause any issues until 2038. Fixes: 4881c4971df04 ("ext4: Initialize timestamps limits") Signed-off-by: David Laight --- fs/ext4/ext4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 57087da6c7be..d919cafcb521 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -909,7 +909,7 @@ do { \ (raw_inode)->xtime =3D cpu_to_le32((ts).tv_sec); \ (raw_inode)->xtime ## _extra =3D ext4_encode_extra_time(ts); \ } else \ - (raw_inode)->xtime =3D cpu_to_le32(clamp_t(int32_t, (ts).tv_sec, S32_MIN= , S32_MAX)); \ + (raw_inode)->xtime =3D cpu_to_le32(clamp((ts).tv_sec, S32_MIN, S32_MAX))= ; \ } while (0) =20 #define EXT4_INODE_SET_ATIME(inode, raw_inode) \ --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 2700831A549 for ; Wed, 19 Nov 2025 22:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592175; cv=none; b=CDeFAIN9F2E8J57m7l9rCNKoJ1FEhiKVYhhoeAQo8vyctn84hp4qTH7KGwFvKeV85PbYOr4uPeWWSbSocZvbdMFvGi5xVlYC/AsRqwWTm2f3qYTNRtMbw5zOSrXyuISP4+nO+wdB6yvXY5jSZkjJ3HMZGs1r1EAA8O3LO2yH24I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592175; c=relaxed/simple; bh=li52uobPk66+BkwIH/b8VJKjGDYh3+gh2uWOK3B772E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ftv4HB5+GLmt/5GTTguCcqDIFxhvaM9fnalzxo3C8C4rWad1zP/EHNV2Z5vKy7ndDeC1H9f+u06rZItHZjvPbJDUsDnw0tEUhisOzKCtNc13SEElVXCg7iukDOP2D7f68nowXu2WEX5mghmBYk6eQDDmAqUm23mthyE3qZmI6XI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=DGUWUnvz; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="DGUWUnvz" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt0-006ywJ-Tp; Wed, 19 Nov 2025 23:42:50 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=N1DxFU65G+nM7q0zov0KSr3WF0ez8nK/PjfzsNDA87s=; b=DGUWUnvzyRp3eBNft6KMmq33+r cqzFxHUt1cMknmNzAL0QK0DdLp7DRfT/3Cj2QO9XgbvpOzu6XPMDzjz4TtMdxFGHgcmx8VPz0qUoM POrh0zfp3/9JbKuncjnr05y1RaYfnJ8OjYAnSj8NGE5Z3uQ2/heQ4SjGigBs6Bu+TvGbfPU2qTgHR UeGPfULMqTboFHcEKrSLWXXf0oBLw1+++XgdPlUii6w+jsK6ITl56xerANPGwyF+uVaWX/nOOJbJm 5svE9KfLf7Srtp0RdeqynV4E/5FzJskMjBRlNFtoiODpcx4OMiDuQMhKc+kyt5oX9UM0ilLa72+e+ 7cF7cbYA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt0-00086M-KX; Wed, 19 Nov 2025 23:42:50 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsV-00Fos6-DY; Wed, 19 Nov 2025 23:42:19 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Peter Zijlstra , David Laight Subject: [PATCH 03/44] perf: Fix branch stack callchain limit Date: Wed, 19 Nov 2025 22:40:59 +0000 Message-Id: <20251119224140.8616-4-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The code that bounds the brs->nr to event->attr.sample_max_stack incorrectly masks brs->nr with 65535 before the limit check. Replace the min_t(u16, ...) with a plain min(...). I guess there may be another limit on brs->nr (which is u64). Fixes: c53e14f1ea4a8 ("perf: Extend per event callchain limit to branch sta= ck") Signed-off-by: David Laight Reviewed-by: Dapeng Mi --- include/linux/perf_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index fd1d91017b99..f91c875ea311 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1430,7 +1430,7 @@ static inline void perf_sample_save_brstack(struct pe= rf_sample_data *data, if (branch_sample_hw_index(event)) size +=3D sizeof(u64); =20 - brs->nr =3D min_t(u16, event->attr.sample_max_stack, brs->nr); + brs->nr =3D min(event->attr.sample_max_stack, brs->nr); =20 size +=3D brs->nr * sizeof(struct perf_branch_entry); =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 AEC35320CA2; Wed, 19 Nov 2025 22:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592175; cv=none; b=YeG1w57OXpIvGx8+9apvF/daU6+APvOJGtsw8s52IrK3+LOSe5GYKPZU5t7uUqy8i34Uei/rQ9EEz6EBDu7Q0GsZGo7kknWYXXRv2LdfMdnW2j+GElA3qM4GJhfqbA/RJcnIhLRwpEAkaUEJiSldtkle6T+hfaPpjUhzi8kP9D8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592175; c=relaxed/simple; bh=EHCU7lsqTITN0JArAIrf/ydpOv9qgaNKENZvKoKlquA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tNgH7qlz3nSj3mE5xhR7gjf0X3+VjgH79tQRguogTf+fExglYMh45g+ylggkZG9U29pgpHi8Ot0Gh7rVh/NLvvzSK4IZRnE4Xn0fvwO7wfQeHGCvuHPSuO+V4gPJbRX9CFZcjORlsYKdyOjmL9nXzHIjmaacEdCrZeTVgLx/E8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=CPfhLjmx; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="CPfhLjmx" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt0-006kxN-Hf; Wed, 19 Nov 2025 23:42:50 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=ffasTl97fub2t0VouM2GGBABLZMcuYWcFCpA19DY7Nw=; b=CPfhLjmxH+S1BU+z+2EBjHlhfE VibMWwBHqw3qoHwq3ZSO9Mgv1/OYHLTyGjl8miE8wG/0w1c0Rfsauknv2vxZZ5Rg3gGDBRFgbTa/R g/RKfomRTViwW8LpJCia25/268tb2VtJ7WZVxGdoS6fKd7aluRZMuPMqmhEQ7kwzhehtSFcagxfqd fUjSa3KN/SP+VLA/I6i4ETxQwL80a+dPZywjn/An/hszasOfGOHGXeENLKpVthkrHol9MC47JjKro 8/6mHaZdTZI/eaZ1WcOdo93o3XKS/RFWv0glTgrrOzWU2KR+iARarsGzBxxZjOzXMDNPtOQxVCenr XQjg9bvw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsz-0000Dj-T5; Wed, 19 Nov 2025 23:42:50 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsV-00Fos6-T9; Wed, 19 Nov 2025 23:42:20 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, io-uring@vger.kernel.org Cc: Jens Axboe , David Laight Subject: [PATCH 04/44] io_uring/net: Change some dubious min_t() Date: Wed, 19 Nov 2025 22:41:00 +0000 Message-Id: <20251119224140.8616-5-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: David Laight --- io_uring/net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index a95cc9ca2a4d..5fcc3e9b094e 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -483,11 +483,11 @@ static int io_bundle_nbufs(struct io_async_msghdr *km= sg, int ret) /* short transfer, count segments */ nbufs =3D 0; do { - int this_len =3D min_t(int, iov[nbufs].iov_len, ret); + int this_len =3D min(iov[nbufs].iov_len, ret); =20 nbufs++; ret -=3D this_len; - } while (ret); + } while (ret > 0); =20 return nbufs; } @@ -853,7 +853,7 @@ static inline bool io_recv_finish(struct io_kiocb *req, * mshot as finished, and flag MSHOT_DONE as well to prevent * a potential bundle from being retried. */ - sr->mshot_total_len -=3D min_t(int, sel->val, sr->mshot_total_len); + sr->mshot_total_len -=3D min(sel->val, sr->mshot_total_len); if (!sr->mshot_total_len) { sr->flags |=3D IORING_RECV_MSHOT_DONE; mshot_finished =3D true; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 E546832D7FC for ; Wed, 19 Nov 2025 22:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592168; cv=none; b=d1FI8MmMZJ0IqFX+jtALNxzEwoqINXaC8WlkaMNJ7/yvS5xVL39T5o7ATKoP5zbzBpYBMt3B/hsEgNp/dlBQgwX1YfrhL52PwCpcmq8sk6xupiSe4mnDzt/Q/oAqjfjp0djRa031ufCzi4YUu/Rz6L7eNNebUHd6btLHyLMTVkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592168; c=relaxed/simple; bh=IG3afSJYxIMPbWj8qHS465BEo1xpWrZZeTJqB1zXaPA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gc7ZqErrVYZ+3cOJu6dhWOGJzBxrSG2/CYjCIiZ9sFuDjmrPMk/tBBKpjraN4858r6vj1W8RB41Johd11t6zRq5bp4DCteVU6FcqsjrFr3TAhplFuOjPfDb5PuP1ax/gXOwAOwHf8lSnvORnpodzSQB5wGjQtmxveLH/AkNw6w0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=GFeWqRHO; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="GFeWqRHO" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqss-006kto-Rc for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=zQju7qyVPpm7bTqGjDsv8+EOunlz4aOhCwApp83FVt8=; b=GFeWqRHOD/Wlz8ZMlnlnpOgmht vKIVXzGSAuMK+33k5FwyRXkgNS3fJ9VLZ173sKzPoemNk8yVMFRyg24S5XJ2tBJRn0UXWThIT8Vq+ JGf6NcMWU3ECtpg1VL/MXoXZ4JZbAb3aOwLB+bjnhuJXig5nc5VdvoyMj5BeCWT+Al135vX9EVlwo hDdHZQLtx5hOjcmCku11Vhw2nbk+bjw1sfiT2fF12ueeRIKILR+CY3SyQ628eqUEqoUnAsh8JRCh7 v5mEX8IaIYiTHWD2bs15ilxvNikz7b69C64uGGkSE5pIzKbbo0LCo9/gSOeTFh6wdQYfLQBSiAqRu RpAv7bZw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqss-00085T-Gt; Wed, 19 Nov 2025 23:42:42 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsW-00Fos6-7E; Wed, 19 Nov 2025 23:42:20 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: David Laight Subject: [PATCH 05/44] ipc/msg: Fix saturation of percpu counts in msgctl_info() Date: Wed, 19 Nov 2025 22:41:01 +0000 Message-Id: <20251119224140.8616-6-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight While the percpu_counter_sum() values are unlikely to be large the code tries to saturate them using min_t(int, percpu_counter_sum(), INT_MAX) This just doesn't work since the high bits are all masked and then the (possibly negative) value assigned. Replace the min_t() with a plain min(). Fixes: 72d1e611082ed ("ipc/msg: mitigate the lock contention with percpu co= unter") Signed-off-by: David Laight --- ipc/msg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index ee6af4fe52bf..34e607add006 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -501,11 +501,9 @@ static int msgctl_info(struct ipc_namespace *ns, int m= sqid, max_idx =3D ipc_get_maxidx(&msg_ids(ns)); up_read(&msg_ids(ns).rwsem); if (cmd =3D=3D MSG_INFO) { - msginfo->msgmap =3D min_t(int, - percpu_counter_sum(&ns->percpu_msg_hdrs), + msginfo->msgmap =3D min(percpu_counter_sum(&ns->percpu_msg_hdrs), INT_MAX); - msginfo->msgtql =3D min_t(int, - percpu_counter_sum(&ns->percpu_msg_bytes), + msginfo->msgtql =3D min(percpu_counter_sum(&ns->percpu_msg_bytes), INT_MAX); } else { msginfo->msgmap =3D MSGMAP; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 881FD32C92B; Wed, 19 Nov 2025 22:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; cv=none; b=tcNEuFkJwTpWSBQTajwj5kQxd8k+vSvFz0ATSysNuvgrWFU5QNu3VYfjBqFU0S8N9eSFUbFRkA2v8BFyFxMhWNFyZmGWDwrHRSn7CwcY6RMaX2O6v3nzP4qfiubPRp1EitX/6akIaYYyjV+xBLk6bPoMWfEO0A9da6T+pabJ/go= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; c=relaxed/simple; bh=p/DR/FykffMserbGV6pix+DJEuXiCs5JkS8z/3JAX+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OZ0K4UilTvcq09WN+TShdlxuCJPG+Qb3GT3KLOe7SaOVE9ynldDNSlfLLb+G0azY13Mli5WwnmeWnYF+QG+zQm8J0F4zrjcnRZizPmvHXY1pQic/04l3C78aQdUnDue/SNf0mjif7sWHB43QMJXYyW+5ek2ZJEEflyinCtRejhE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=tXEnrd0F; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="tXEnrd0F" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqss-006ktm-Ml; Wed, 19 Nov 2025 23:42:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=zMBuIAwUIhlU23riZVslwHF2pmtSGAEsu39ThErsacM=; b=tXEnrd0FsCIeJdJS23xtND5qma /nyz4LKFnCGT8cX0llevptwGUar6RlozBMNTjjI4qSDiv6Zo3IWFBbZyCjadX3oTN0HTvoszmtMCw Ub7syVi2ALmfPGqC1wAb//U7KFTiTI1m+E1k7vJsN/qI4QPZJsL7u7JX4xLDsmgeuuDubF4z0u6wL kf9iNyvkpqoJNzSUgoAmDW5sOdAYLdawnePjuCd01vo4lwZ7AKFPOhf8X6tkAPVr6rJMeFFTAgdVU XBfPiHxne2fNsTCHc39RFot23sa3jacc9UZdHGfYEmS5hc9aYhXQJ1n8hMzFVDN9YWGFtULZd5Zsp 0fbgnv9g==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsr-0000Bm-85; Wed, 19 Nov 2025 23:42:42 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsW-00Fos6-Mx; Wed, 19 Nov 2025 23:42:20 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , David Laight Subject: [PATCH 06/44] bpf: Verifier, remove some unusual uses of min_t() and max_t() Date: Wed, 19 Nov 2025 22:41:02 +0000 Message-Id: <20251119224140.8616-7-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t() and max_t() are normally used to change the signedness of a positive value to avoid a signed-v-unsigned compare warning. However they are used here to convert an unsigned 64bit pattern to a signed to a 32/64bit signed number. To avoid any confusion use plain min()/max() and explicitely cast the u64 expression to the correct signed value. Use a simple max() for the max_pkt_offset calulation and delete the comment about why the cast to u32 is safe. Signed-off-by: David Laight --- kernel/bpf/verifier.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index ff40e5e65c43..22fa9769fbdb 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -2319,12 +2319,12 @@ static void __update_reg32_bounds(struct bpf_reg_st= ate *reg) struct tnum var32_off =3D tnum_subreg(reg->var_off); =20 /* min signed is max(sign bit) | min(other bits) */ - reg->s32_min_value =3D max_t(s32, reg->s32_min_value, - var32_off.value | (var32_off.mask & S32_MIN)); + reg->s32_min_value =3D max(reg->s32_min_value, + (s32)(var32_off.value | (var32_off.mask & S32_MIN))); /* max signed is min(sign bit) | max(other bits) */ - reg->s32_max_value =3D min_t(s32, reg->s32_max_value, - var32_off.value | (var32_off.mask & S32_MAX)); - reg->u32_min_value =3D max_t(u32, reg->u32_min_value, (u32)var32_off.valu= e); + reg->s32_max_value =3D min(reg->s32_max_value, + (s32)(var32_off.value | (var32_off.mask & S32_MAX))); + reg->u32_min_value =3D max(reg->u32_min_value, (u32)var32_off.value); reg->u32_max_value =3D min(reg->u32_max_value, (u32)(var32_off.value | var32_off.mask)); } @@ -2332,11 +2332,11 @@ static void __update_reg32_bounds(struct bpf_reg_st= ate *reg) static void __update_reg64_bounds(struct bpf_reg_state *reg) { /* min signed is max(sign bit) | min(other bits) */ - reg->smin_value =3D max_t(s64, reg->smin_value, - reg->var_off.value | (reg->var_off.mask & S64_MIN)); + reg->smin_value =3D max(reg->smin_value, + (s64)(reg->var_off.value | (reg->var_off.mask & S64_MIN))); /* max signed is min(sign bit) | max(other bits) */ - reg->smax_value =3D min_t(s64, reg->smax_value, - reg->var_off.value | (reg->var_off.mask & S64_MAX)); + reg->smax_value =3D min(reg->smax_value, + (s64)(reg->var_off.value | (reg->var_off.mask & S64_MAX))); reg->umin_value =3D max(reg->umin_value, reg->var_off.value); reg->umax_value =3D min(reg->umax_value, reg->var_off.value | reg->var_off.mask); @@ -6128,15 +6128,8 @@ static int check_packet_access(struct bpf_verifier_e= nv *env, u32 regno, int off, return err; } =20 - /* __check_mem_access has made sure "off + size - 1" is within u16. - * reg->umax_value can't be bigger than MAX_PACKET_OFF which is 0xffff, - * otherwise find_good_pkt_pointers would have refused to set range info - * that __check_mem_access would have rejected this pkt access. - * Therefore, "off + reg->umax_value + size - 1" won't overflow u32. - */ - env->prog->aux->max_pkt_offset =3D - max_t(u32, env->prog->aux->max_pkt_offset, - off + reg->umax_value + size - 1); + env->prog->aux->max_pkt_offset =3D max(env->prog->aux->max_pkt_offset, + off + reg->umax_value + size - 1); =20 return err; } --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 92A962ECEA3 for ; Wed, 19 Nov 2025 22:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592158; cv=none; b=Hf7XmwirBGiOpdKZXaxRyPhxsf5SYNTDRrs5UMYVBctKLQy6OUUGZIsZFoHnxaKtmzHFuX5gxcICYDv9JRDH1L69Cv5bwdpa/UvoN4YgHGDDn3QBknnyIeqQw3eb3OIIEMiT+A37cj9MO9uILJKCyxvG6pcTctpaatizRwGRHcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592158; c=relaxed/simple; bh=jdsdnQfEeKhULD5LDqMlrha91I1CSQoU+7lDJH7uZ2U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X3/NidrlppBPmAihVBXqxxPy2ruuQ/vUjDCfKVDbs/Qsy809msIga4bgJuPh4x36egDW3Bq7nwKAYW1wnStZ1VphJsXiFSadQot468eNQ8n54Wxk4NvDWCmUHyDudSeiKKU4Pz/vIecOLQniKp1YoCxq2puB9bDJMISxTjaW7Rg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=VRJDXSOs; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="VRJDXSOs" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsj-006ks0-Ux; Wed, 19 Nov 2025 23:42:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=7JhqI3glyw6HOLsTlPkKP1J1UeeD/y9Xa20+m5h05cg=; b=VRJDXSOsQBIkifujQR+BqUZfjh LmSs6duSgOrYsPpRuXEIfjXer5MWRtQxgc5O4jGe+sOY6Pny84w8HKxjn/hSiR+CxIseyLeot1XUB HBGJwL22Rh9lF5Fjaf9ntGhAlPLaHahZ8D700puGP80PVsIenOz+6Bg0ACnzsipHAnS67IW+2Bpfu bQrFKhdJ0PQBvuewryQr++oOcgPZvu+psqsvBxTQ+mSbzgV+4mHehqNEjVffjdbpEczL9oWsxWTjc CUC3+6+HVVDw/9JqnQsUga1PYmxMjDKmkySiKrhTef7xZofgOuhhQK5ScVsGK83U864Te2YqRcmn9 uV+fNu1w==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsj-0007zu-MV; Wed, 19 Nov 2025 23:42:33 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsX-00Fos6-8W; Wed, 19 Nov 2025 23:42:21 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Laight Subject: [PATCH 07/44] net/core/flow_dissector: Fix cap of __skb_flow_dissect() return value. Date: Wed, 19 Nov 2025 22:41:03 +0000 Message-Id: <20251119224140.8616-8-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight There are some dodgy clamp_t(u16, ...) and min_t(u16, ...). __skb_flow_dissect() tries to cap its return value with: key_control->thoff =3D min_t(u16, nhoff, skb ? skb->len : hlen); however this casts skb->len to u16 before the comparison. While both nboff and hlen are 'small', skb->len could be 0x10001 which gets converted to 1 by the cast. This gives an invalid (small) value for thoff for valid packets. bpf_flow_dissect() used clamp_t(u16, ...) to set both flow_keys->nhoff and flow_keys->thoff. While I think these can't lose significant bits the casts are unnecessary plain clamp(...) works fine. Fixes: d0c081b49137c ("flow_dissector: properly cap thoff field") Signed-off-by: David Laight --- net/core/flow_dissector.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 1b61bb25ba0e..e362160bb73d 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1023,9 +1023,8 @@ u32 bpf_flow_dissect(struct bpf_prog *prog, struct bp= f_flow_dissector *ctx, =20 result =3D bpf_prog_run_pin_on_cpu(prog, ctx); =20 - flow_keys->nhoff =3D clamp_t(u16, flow_keys->nhoff, nhoff, hlen); - flow_keys->thoff =3D clamp_t(u16, flow_keys->thoff, - flow_keys->nhoff, hlen); + flow_keys->nhoff =3D clamp(flow_keys->nhoff, nhoff, hlen); + flow_keys->thoff =3D clamp(flow_keys->thoff, flow_keys->nhoff, hlen); =20 return result; } @@ -1687,7 +1686,7 @@ bool __skb_flow_dissect(const struct net *net, ret =3D true; =20 out: - key_control->thoff =3D min_t(u16, nhoff, skb ? skb->len : hlen); + key_control->thoff =3D umin(nhoff, skb ? skb->len : hlen); key_basic->n_proto =3D proto; key_basic->ip_proto =3D ip_proto; =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 92B3C2F83A1 for ; Wed, 19 Nov 2025 22:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592159; cv=none; b=nUrUm4W7lCi7sb0V9iiabwJiNPSyFcV1k6+n0VAPbqvFJ08JpEUCf6AtBdr7C95NyU8hkZpNpqWOOKCKudk5bsbR+u1sSr3wcOX9ymimeSvAVlib9LT3c/On35QlQYPRPp3eRgakhWXoGy1qTmqQ+O2fsu88s9ISC+nVsTxQg2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592159; c=relaxed/simple; bh=OFaVoQDDWiVDx4c2WXlL8vnBK1/eYof2473GrDd+z20=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fnctzm3g9cMW8w7bo3eG18nolkWtm7Ma5uyFViIDSsPJdhrJmWyiEDfPD4mN9QO2e+MQQCoXFQpWQ8Rs4oCCnRyXoQD4xPoZfRcV2osm51u5iGNV+zq6YIlI5ptABN3KU0pu9hKRKVa8ngR3M9DNYdhZ+ktYgaTvD4+DQjUQhO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=mF/O4SqD; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="mF/O4SqD" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsk-006ks3-BL; Wed, 19 Nov 2025 23:42:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=ROLxgtuAVt/BzKpbOFcQBVPVvKjXAYO6Mvo+kOdOmhM=; b=mF/O4SqDl18pINjtwUQmsPxwog liVwA+IGYpf3a28aKbL6BjgyfeRcXGnt2zSfggukEe147xoFkC1NvTaRupwBJ62DV+pQitFnZGSE4 pG6B0KjgYV6e1u/QX/xS9j5AgzUr0fqXZEqmVQCzoUqNg+NR3INRR2z9H2c3x75U5VI2haDmIN1gu cwDqdUAvWnPZ4lbd2CNY19vx52egwEvxLZ6MIEGqrlT13pQ96tkgA4X0hguJlcDYg7hji2X4s1QFg yERus/EPM+YSBDe+bA3uof3SQ82hOK6Zsp23Pu+0EiAPHhPWQerPMrjFORepRSVvALpeqRTPoN1HE Oh7ySs4w==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsk-000051-2O; Wed, 19 Nov 2025 23:42:34 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsX-00Fos6-RO; Wed, 19 Nov 2025 23:42:21 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Laight Subject: [PATCH 08/44] net: ethtool: Use min3() instead of nested min_t(u16,...) Date: Wed, 19 Nov 2025 22:41:04 +0000 Message-Id: <20251119224140.8616-9-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight In ethtool_cmis_cdb_execute_epl_cmd() change space_left and bytes_to_write from u16 to u32. Although the values may fit in 16 bits, 32bit variables will generate better code. Replace the nested min_t(u16, bytes_left, min_t(u16, space_left, x)) with a call to min3(). Signed-off-by: David Laight --- net/ethtool/cmis_cdb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/ethtool/cmis_cdb.c b/net/ethtool/cmis_cdb.c index 3057576bc81e..1406205e047e 100644 --- a/net/ethtool/cmis_cdb.c +++ b/net/ethtool/cmis_cdb.c @@ -573,12 +573,11 @@ ethtool_cmis_cdb_execute_epl_cmd(struct net_device *d= ev, while (offset <=3D CMIS_CDB_EPL_FW_BLOCK_OFFSET_END && bytes_written < epl_len) { u32 bytes_left =3D epl_len - bytes_written; - u16 space_left, bytes_to_write; + u32 space_left, bytes_to_write; =20 space_left =3D CMIS_CDB_EPL_FW_BLOCK_OFFSET_END - offset + 1; - bytes_to_write =3D min_t(u16, bytes_left, - min_t(u16, space_left, - args->read_write_len_ext)); + bytes_to_write =3D min3(bytes_left, space_left, + args->read_write_len_ext); =20 err =3D __ethtool_cmis_cdb_execute_cmd(dev, page_data, page, offset, --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 A66D52C178E; Wed, 19 Nov 2025 22:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592158; cv=none; b=bqpsdxLUJGLhkPYQQ5aFbLpDzdl2IZMhDisVPuhTONkEGhz9+gRsPe8xDjCcc4biG2ExYW+UxqTQt2sUaFFeOYGjUphkWF7emA8L3EREYv0E/PECSUPCvWBmiQ7reWJC8ECtllnf4fNi9l/tRINSM6Q4Uu17E4fs01Jz87UUDw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592158; c=relaxed/simple; bh=/88llFjR+aW+sKimOPnEFHk+cZxtJ0WQo1sV7i/jqyk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KxP9R3WLtJLmvdaGCJAJV+w4xchyWKWDQYVuF8YFZTi2kw5pp3GRC9bR8hMjQkFI0/b43n/bnk6LpKljC845mU7imEfat1oGpILNTVHrce/oE1E3s+AoAtf8ITMgZelTRDE7BjKUj31Hq4hhanjRj32yKu3EKM2g/HZP5swzVBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=hvsFicVn; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="hvsFicVn" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsk-006ks8-OU; Wed, 19 Nov 2025 23:42:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=yHVSmeGdA9+Qmi1v5uWkOlHaQm/+UGKct/GaarfRyAc=; b=hvsFicVn5RMO7/y5voskYgS44h L9lC1HCvmHl3qGjSylT6IZsHmcy9DKwyM18j8Zi+85p6ChAyfSEkpNeEFOxu8qwUiE0Hxm612urJ1 cQ0JIK6wT/S3x6qeUe4IZ3rSw2nLwh9bdqSs77iSCw9Yav6kYi/2lbZIG4BqDZahOj/3XvTAcFPjU OKoh0aE/YxDLhoyOmWoEI+VIeA3ullbFfuWzyRjVnWzxyZb2L2DKb5rBQ74qgn9QUKa0CCx/23KzL uJS1QMFE+YXGO6SAP2PQl8HWzwrhfKLE054TEFyBtxKLIi6IbMycYy50R5o1Rh4YTj/hJYylCcJwu ilkZArtQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsk-000057-Er; Wed, 19 Nov 2025 23:42:34 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsY-00Fos6-DI; Wed, 19 Nov 2025 23:42:22 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: David Ahern , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Laight Subject: [PATCH 09/44] ipv6: __ip6_append_data() don't abuse max_t() casts Date: Wed, 19 Nov 2025 22:41:05 +0000 Message-Id: <20251119224140.8616-10-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The implicit casts done by max_t() should only really be used to convert positive values to signed or unsigned types. In the EMSGSIZE error path pmtu =3D max_t(int, mtu - headersize + sizeof(struct ipv6hdr), 0); is being used to convert a large unsigned value to a signed negative one. Rework using a signed temporary variable and max(pmtu, 0), as well as casting sizeof() to (int) - which is where the unsignedness comes from. Signed-off-by: David Laight --- net/ipv6/ip6_output.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index f904739e99b9..6fecf2f2cc9a 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1440,7 +1440,7 @@ static int __ip6_append_data(struct sock *sk, struct sk_buff *skb, *skb_prev =3D NULL; struct inet_cork *cork =3D &cork_full->base; struct flowi6 *fl6 =3D &cork_full->fl.u.ip6; - unsigned int maxfraglen, fragheaderlen, mtu, orig_mtu, pmtu; + unsigned int maxfraglen, fragheaderlen, mtu, orig_mtu; struct ubuf_info *uarg =3D NULL; int exthdrlen =3D 0; int dst_exthdrlen =3D 0; @@ -1504,9 +1504,10 @@ static int __ip6_append_data(struct sock *sk, maxnonfragsize =3D mtu; =20 if (cork->length + length > maxnonfragsize - headersize) { + int pmtu; emsgsize: - pmtu =3D max_t(int, mtu - headersize + sizeof(struct ipv6hdr), 0); - ipv6_local_error(sk, EMSGSIZE, fl6, pmtu); + pmtu =3D mtu - headersize + (int)sizeof(struct ipv6hdr); + ipv6_local_error(sk, EMSGSIZE, fl6, max(pmtu, 0)); return -EMSGSIZE; } =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 EF783328B4C for ; Wed, 19 Nov 2025 22:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592163; cv=none; b=jdoYrVQ9W6s1vfC33uMe9Z8AsDxwIX2LJJYwGWVMNn0gLhinMTqrjsVG5L8BOWIIokKEiY/eRjqoBi+gwcylFABdVJcLcQcA5j/v2hLLr2d+DJ+6Tm+54xehwBxMpTqvI5FAt2wUMic5uu1nnSYLCKq6pJzgNBF1wLYxeBgfwlQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592163; c=relaxed/simple; bh=Iuwlqj+cR4EIiZpVo8JQkyFnSzUomIc1WiA0HfIaGD4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EPPjo60sCULYWKVccCMAAZIIuB+lvmNky1EJQ1InDtGIRcIQD6N6O8xssw1/MoSAeXcHl8O2zJkFYm1ZKsqA7bQoIOm5wjTmB4GSTA0Q5X2DNKMx8El5mELqo7LYmnM6fBEZVe2/+Vn+dBcuUeRvXwW7tmMzOhBl59aqO6Ef1iw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=z9ELswja; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="z9ELswja" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsp-006ktD-A2; Wed, 19 Nov 2025 23:42:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=paduOCJQk+DPYxit3GhnkX6dVmwwtH01YWvMrtzPP34=; b=z9ELswjazmYV72gtqHnTnudeeT +DT5cJ60Jh+Wtja5PwgyL9jMdTNCCdA6ufR6KKDHQruKKCGbTNLKD45REENWw5mt2KzbOscMr2Ycj VTNagf4jJmWNpBc9eGHR4iG+CKmzPHT/DcHdZzC+i0yVrKOdfJFfQLcJ7IlEtDgAfk3QaagGuBUfq 0mmE1Ag215XC41fuALDJJKmPfwp9x6Zd7ysYgUchEWXVh64y7f2hdG/WvU4EU3XsEV6qDBG4aVREN aBYjAhEFvDvrtrMYEGn5jDOjwO7fFs86Sxq1GzKlBDJdvLGQ+fZl2tzbbYiWqcbNAORi7A+jww9GG eUgRhLvQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqso-00008Q-Dm; Wed, 19 Nov 2025 23:42:39 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsZ-00Fos6-28; Wed, 19 Nov 2025 23:42:23 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Cc: Borislav Petkov , Dave Hansen , "David S. Miller" , Herbert Xu , Ingo Molnar , Thomas Gleixner , x86@kernel.org, David Laight Subject: [PATCH 10/44] x86/crypto: ctr_crypt() use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:06 +0000 Message-Id: <20251119224140.8616-11-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- arch/x86/crypto/aesni-intel_glue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-int= el_glue.c index d953ac470aae..f71db4f1c99c 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c @@ -693,8 +693,7 @@ ctr_crypt(struct skcipher_request *req, * operation into two at the point where the overflow * will occur. After the first part, add the carry bit. */ - p1_nbytes =3D min_t(unsigned int, nbytes, - (nblocks - ctr64) * AES_BLOCK_SIZE); + p1_nbytes =3D min(nbytes, (nblocks - ctr64) * AES_BLOCK_SIZE); (*ctr64_func)(key, walk.src.virt.addr, walk.dst.virt.addr, p1_nbytes, le_ctr); le_ctr[0] =3D 0; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 B8E533126D1; Wed, 19 Nov 2025 22:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592169; cv=none; b=Xra7MNfwTOHbZtItmeaHdOO3KyE5veOj4xmZiX1QDQ2q66Nrw6BiE62e2whtSzt3CzAiO4/fI6QHLe3BbwKRbN4TRSZsOvD72cUERrvnD+N0ZPQuz9EI0Jc8jprjkPlukH+WvM0nM48n6msg4puUl4ielM2fQE1WXBnW8T5Y3cI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592169; c=relaxed/simple; bh=sKT1pp0kXgC9eDN7tUsZHEvBOw4i30duGD5WD7ELpo4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AIKb63FNdMYxYeonPMCGaD/ayR0MNC2GWn2EH5sLMOmLwBM/E7/YO5LJiEm9QIZ/GndsPXtEFrfV+7tItXWK850vMAZNFR75ixpzrFFuHvrTePSKD1ufFnwivkOnbk3gV2jnzAYgkEx0lWLuOzQFtujxRUsk5kQ/Ld8FOpaMYXA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=gn5UXjfE; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="gn5UXjfE" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqso-006yp4-NH; Wed, 19 Nov 2025 23:42:38 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=Qm5JY2mMJkohgmQ/bUwBjPkYq8QhcEnzUcW/mrBnhJ4=; b=gn5UXjfEU2284sEBoGiWjavm4X EB/7NLMjxofZMbQwQ91xNRSXeDP9YESyj5W6el8R8X67GJZcrt4gQ7YUktrH+S2U/CKIxfIqVe1iV cXgnNU/7iCR1YeGdq0yZ/KeZJJtd4/GfIx/2oivr/VBcaX77HairvKASZTS3dCv3w8SbA65a1gSgh k+dyHhG+YX1OSY7ZCIrZBEJa32bXvlm9NmoMDuLl0CpHvxF+qhJkC8aue6C/EpCksC31xgHceJggI uNvDHxRp876h66LBm63lxSMlyc1T1fF04qODV2lwPrwnlWWP0EziKUq1TlQx40u2xtitRwKCOljEk /bwFtaiA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsn-00007D-Es; Wed, 19 Nov 2025 23:42:38 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsZ-00Fos6-Mj; Wed, 19 Nov 2025 23:42:23 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Borislav Petkov , Dave Hansen , Ingo Molnar , Paolo Bonzini , Sean Christopherson , Thomas Gleixner , x86@kernel.org, David Laight Subject: [PATCH 11/44] arch/x96/kvm: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:07 +0000 Message-Id: <20251119224140.8616-12-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. (Similarly for max_t() and clamp_t().) Use min3() in __do_insn_fetch_bytes(). Detected by an extra check added to min_t(). Signed-off-by: David Laight --- arch/x86/kvm/emulate.c | 3 +-- arch/x86/kvm/lapic.c | 2 +- arch/x86/kvm/mmu/mmu.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 4e3da5b497b8..9596969f4714 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -861,8 +861,7 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctx= t *ctxt, int op_size) if (unlikely(rc !=3D X86EMUL_CONTINUE)) return rc; =20 - size =3D min_t(unsigned, 15UL ^ cur_size, max_size); - size =3D min_t(unsigned, size, PAGE_SIZE - offset_in_page(linear)); + size =3D min3(15U ^ cur_size, max_size, PAGE_SIZE - offset_in_page(linear= )); =20 /* * One instruction can only straddle two pages, diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 0ae7f913d782..b6bdb76efe3a 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1894,7 +1894,7 @@ static inline void __wait_lapic_expire(struct kvm_vcp= u *vcpu, u64 guest_cycles) } else { u64 delay_ns =3D guest_cycles * 1000000ULL; do_div(delay_ns, vcpu->arch.virtual_tsc_khz); - ndelay(min_t(u32, delay_ns, timer_advance_ns)); + ndelay(min(delay_ns, timer_advance_ns)); } } =20 diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 667d66cf76d5..989d96f5ec23 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5768,7 +5768,7 @@ static void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, root_role =3D cpu_role.base; =20 /* KVM uses PAE paging whenever the guest isn't using 64-bit paging. */ - root_role.level =3D max_t(u32, root_role.level, PT32E_ROOT_LEVEL); + root_role.level =3D max(root_role.level + 0, PT32E_ROOT_LEVEL); =20 /* * KVM forces EFER.NX=3D1 when TDP is disabled, reflect it in the MMU rol= e. --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 9E6E2330B14; Wed, 19 Nov 2025 22:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592171; cv=none; b=rpTVZHUugwAWTSZydNYyjPtD5yanw93Z3aDSftD5wz9H8Y4BcXPZNZXDQJJrAsMGRopFS69zUnw7kTzlUATt1n2hJzWRmmNlE3McTVdiZRjzcUcVokImjowlugNx3REljSXBX6vhuVtDa2hMQlroZZPP9qu1gHFibvgHxg0wCNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592171; c=relaxed/simple; bh=ZZNNuTRuiX53llVmFMgKwGGhIW58g3kFCa2xIK5PUCc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T0t7jY0T/rfF1FRueCZ8ZlJOzV4HTFTUawUbteJ/pjagJuTKHfpY7qt1ckTkctFLzRz6OOoUjho8wZn5F4COJ21WHRaitzHKEcx9wK/+ramk8ew+OtjBe2BZ2BCA0b3WfwDyZFjS9F9s4r9QkCzvQUEMTkMw7Y/IzHeqeyOnv9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=GkUoEl0B; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="GkUoEl0B" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsw-006kvx-LU; Wed, 19 Nov 2025 23:42:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=Vhn8/vbnFTBTrLe40in1hyrWt+hwUetOS1daXHrGJRI=; b=GkUoEl0BxUcro5HrumgEhz6q7S ABk1zCOGPsPuJyp1ZRIagRRuwzkOCh0X4FJqoA+gb+WH43yS/9/fELw+4L+cMrKm286TWzaluczUD kmvzWGSBWmdHpO3mEp3toCKbeQ86UNgVPKKUiwQwfOpMaXOExV5xSOVtSklsVRJBUezKxOfJMeT5C Sy5jmu2eU1AXBMVmKlNkEb7n13V9qpNc3vRdyP0HdznRtS/x6QzaRGq2rxSzIN9g297yPBdk2jDtM WqrenPTlhBjHV2g2szbJ7y0zTVdf/yAXs98gfKaSlJ8/75ShkB42ktGPXLIyvMDkVFbRCGxyhEJ0O faXr9lTA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsw-00085q-81; Wed, 19 Nov 2025 23:42:46 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsa-00Fos6-9U; Wed, 19 Nov 2025 23:42:24 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-efi@vger.kernel.org Cc: Davidlohr Bueso , Jens Axboe , Josef Bacik , Tejun Heo , David Laight Subject: [PATCH 12/44] block: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:08 +0000 Message-Id: <20251119224140.8616-13-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. (Similarly for max_t() and clamp_t().) Detected by an extra check added to min_t(). Signed-off-by: David Laight --- block/blk-iocost.c | 6 ++---- block/blk-settings.c | 2 +- block/partitions/efi.c | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 5bfd70311359..a0416927d33d 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2334,10 +2334,8 @@ static void ioc_timer_fn(struct timer_list *timer) else usage_dur =3D max_t(u64, now.now - ioc->period_at, 1); =20 - usage =3D clamp_t(u32, - DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE, - usage_dur), - 1, WEIGHT_ONE); + usage =3D clamp(DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE, usage_dur), + 1, WEIGHT_ONE); =20 /* * Already donating or accumulated enough to start. diff --git a/block/blk-settings.c b/block/blk-settings.c index d74b13ec8e54..4e0c23e68fac 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -472,7 +472,7 @@ int blk_validate_limits(struct queue_limits *lim) seg_size =3D lim->max_segment_size; else seg_size =3D lim->seg_boundary_mask + 1; - lim->min_segment_size =3D min_t(unsigned int, seg_size, PAGE_SIZE); + lim->min_segment_size =3D min(seg_size, PAGE_SIZE); =20 /* * We require drivers to at least do logical block aligned I/O, but diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 7acba66eed48..638261e9f2fb 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -215,8 +215,7 @@ static int is_pmbr_valid(legacy_mbr *mbr, sector_t tota= l_sectors) sz =3D le32_to_cpu(mbr->partition_record[part].size_in_lba); if (sz !=3D (uint32_t) total_sectors - 1 && sz !=3D 0xFFFFFFFF) pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n", - sz, min_t(uint32_t, - total_sectors - 1, 0xFFFFFFFF)); + sz, (uint32_t)min(total_sectors - 1, 0xFFFFFFFF)); } done: return ret; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 9AB8332E72F; Wed, 19 Nov 2025 22:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592170; cv=none; b=Isu0g1fkeeH4OpK1WQ+eDvOmNZIp9Da1ZWKByWhiR/BaTVZytPQAvWeME+WgWC9uckMpiar0sDTP2v6pSouYcwbinqIz0wJNT7lg+6UX344SfyJxlmarLUDLbuX63Gf5w8Emm24TZqPqO2cE59goO0vTyE/HKjTpbHKY8Prm7rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592170; c=relaxed/simple; bh=fTWK9ZhtNPnMQsRMSYCwnTbkedaLi1ZBLXjISTRbQ40=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IPydhWJ6YLVcg9RT5vcz/dpQMcc7EBt0xPNaIeXJ3tQYcKWl3vv/Ri3QDWqC2rVKNsdjQxdTg85tQY3M/gIZOsFFnm9rTJQeaUcnyD2C2epJSeY1doltU51aylIv5KrhxYDBj+At/cx9oLpvVTktIrYBqBeTHQdqlidVzqGHyHI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=rpfaaLJ3; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="rpfaaLJ3" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsw-006ysY-Bb; Wed, 19 Nov 2025 23:42:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=C+jBZ6fI3hOCBTXkSkePKXZdnNx+tfzsbryObn4krGs=; b=rpfaaLJ3GB9BL5rQgtrWmJKuOi 3v/X1BM8s+PLxOA+f2mEmLixYZLH4HoxnWBqGeYqwWOpRMuPYaR/tSaU8dPYMmxLBr/Q7zjEqBgKX LyIpXoZvDZkod5fFIitgNWX0kJTGMOciUy/s5HDE7h2dfYdx1Q210no62RGtrBcBhk8QmLHiqsnfJ XKNPuPo1fnYZ3rPy4xMiqiFyvT/9XR8oLoeKv12Fku36vzF+75P61hxtSWJJ9cFdlQkuv7HMcQEyJ zpaF8rLGTofbIfEMa1n25J5B+pxcddaVPVAVA8xjK4/z+Sdh55WYqHhjfm7xQ7LqS1MhBEO8VNOQI oIWcER0A==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsv-0000Cx-Cx; Wed, 19 Nov 2025 23:42:45 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsa-00Fos6-Li; Wed, 19 Nov 2025 23:42:24 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: "Rafael J. Wysocki" , David Laight Subject: [PATCH 13/44] drivers/acpi: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:09 +0000 Message-Id: <20251119224140.8616-14-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 43d5e457814e..e427ab24cde7 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1280,7 +1280,7 @@ static int acpi_data_prop_read(const struct acpi_devi= ce_data *data, ret =3D acpi_copy_property_array_uint(items, (u64 *)val, nval); break; case DEV_PROP_STRING: - nval =3D min_t(u32, nval, obj->package.count); + nval =3D min(nval, obj->package.count); if (nval =3D=3D 0) return -ENODATA; =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 ADB60329E44 for ; Wed, 19 Nov 2025 22:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592164; cv=none; b=RwT/e8k8cuz+RcbVcF3wGl+D7y7G1nhBUgVejOrM2rTpm+QcTPr9VTmgc3h8/pb0aWQp5KWwCrYfneXZWiBs5dhxq2K91Xvstr8cyRvrlDuUd/xvjXTJudIbC6S2BaI6DwVVj4JUNjWcs4ffzT+Z8dPESSeQLm+m6O5wf1eoUeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592164; c=relaxed/simple; bh=gAmheY3BdyOTd5f22skV+ygZFPkYkHLxZlz8qlPKzQk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RCOBGoWoCnHu/B1iVctExHZb7K4z+f9LjyIggFl7Uiv9+bqzjeTpYPyYnyUtLBkgZ4yVs4M2WrJmSf9aEow9yZbju5WL/8OsKaqzi2z9fmVdDLvoRIWNNl4HA5SUk+symF3Pa1qe4bU/fzPB1ZqLUipzL60A/p6QThhKKi4lRVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=GD/J9RgG; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="GD/J9RgG" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsp-006ktK-Qe for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=RPjl5M3K/tkNOzGdTBgvu8hHZsDSFSPtP5rvQki70cA=; b=GD/J9RgGPwKDAchM9K8Mxz8ffi mtY0CaYUIrh/Ik1edJxi7EmD/h/sZht0bKV8HeKd6QWw8gGmblgT1oWnqhgy90zVRkKouqi3pm+tm 4azjYZ+F3G3ldL7OFIE7zsurowGZ05EEQskQBYZGv845ZoDx6tcJbtxlFDNXmZtotdhm5XOVwf/1T fMlHCG2SmhkRI0yHiCboRkphAaFbJ/LUXGZBLcCcfZheI4eNii6frmUUGNAAXRmti4IJyGlcEOW5v HqrF90FDfWB7pQvMMAtmgcpHvXkuQUQ2S60r0eh56Br8Ls5+dPQog2p6j6mpVXbuWWXDPic/k4Cft F2rLHYmQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsp-00084x-A3; Wed, 19 Nov 2025 23:42:39 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsb-00Fos6-38; Wed, 19 Nov 2025 23:42:25 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Cc: Herbert Xu , Olivia Mackall , David Laight Subject: [PATCH 14/44] drivers/char/hw_random: use min3() instead of nested min_t() Date: Wed, 19 Nov 2025 22:41:10 +0000 Message-Id: <20251119224140.8616-15-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(u16, a, b) is likely to discard significant bits. Replace: min_t(u16, min_t(u16, default_quality, 1024), rng->quality ?: 1024); with: min3(default_quality, 1024, rng->quality ?: 1024); Signed-off-by: David Laight --- drivers/char/hw_random/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 018316f54621..74c8eb1d9048 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -542,7 +542,7 @@ int hwrng_register(struct hwrng *rng) init_completion(&rng->dying); =20 /* Adjust quality field to always have a proper value */ - rng->quality =3D min_t(u16, min_t(u16, default_quality, 1024), rng->quali= ty ?: 1024); + rng->quality =3D min3(default_quality, 1024, rng->quality ?: 1024); =20 if (!current_rng || (!cur_rng_set_by_user && rng->quality > current_rng->quality)) { --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 151AD31AF37; Wed, 19 Nov 2025 22:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592164; cv=none; b=rc2g78CeY4xSvkv1EHUS+B50sLEQnj1Kw1iohF+hxc7LmIFF9prijZegpf9UHtNdKvoAsaHnsoYa4HTp+nzXBTb1HzMwgFebUx5sXy+kFRaMsvqwiuF9JfUWOmPRa+GNigElObzjlX8UJXYNnr92V5Q9n/YurIBXdSEdPMzqXPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592164; c=relaxed/simple; bh=8DFbDceo+hae0z8sHjqS3FDVV/8W5WkMGiMPkPluteU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GLAX9Eg9V+q+ewowGGoh1IWfAcN+Ng1MdXIz2Mgyv4b5yPJhjhwIoLHuhEseDN5bWdJ+eejJzB7QaESsB9uq+3sSR1Fb7bjrB137zeFAEocPzQwa3Eb0UudJRllu3a47WUGq1eBJx/8w6vkNs5kpqrBbDzU4INwB7w75I584JPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=29pbxlf6; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="29pbxlf6" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsq-006ktR-4E; Wed, 19 Nov 2025 23:42:40 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=6F7mH0wT5IZgQzK9d7ZZZ1QEVyvkSX2hmC/0mA0wSgA=; b=29pbxlf6zrfeXIK4c9MzK3fd2x O4WxZid2rR43NhzlyZroOSBvNb+kJThZixKb4cqfkiqXAR20/r6B44lXzFvveuGjecyf9NGLkx/5Z zNFA6dpVojFF9bUY/S2yA8BRs9tXGVgInOs96RrOjqwA1wZp37gjbtzWE9STqbGUgFwYUI8hNyBwE YBvD+JzcLCh1lDY6WCUCr3qHWi/jTy7T1tRTJkk6GbbrluAMoB/TVYLHjpqzKOCKSZpLd5aD6y5nH nbbVtonZW0MtA03f56mglgnfjYpPzjxSPHNIpeKGsgDWA2s+KlU0Qkoe3VUjGH7JlJeDR/Lem1N1R nE7tTZOg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsp-00085G-Qv; Wed, 19 Nov 2025 23:42:39 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsb-00Fos6-GP; Wed, 19 Nov 2025 23:42:25 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org Cc: Jarkko Sakkinen , Peter Huewe , David Laight Subject: [PATCH 15/44] drivers/char/tpm: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:11 +0000 Message-Id: <20251119224140.8616-16-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(int, a, b) casts an 'long' to 'int'. Use min(a, b) instead as it promotes any 'int' to 'long' and so cannot discard significant bits. In this case the 'long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm1-cmd.c | 2 +- drivers/char/tpm/tpm_tis_core.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c index cf64c7385105..11088bda4e68 100644 --- a/drivers/char/tpm/tpm1-cmd.c +++ b/drivers/char/tpm/tpm1-cmd.c @@ -530,7 +530,7 @@ struct tpm1_get_random_out { int tpm1_get_random(struct tpm_chip *chip, u8 *dest, size_t max) { struct tpm1_get_random_out *out; - u32 num_bytes =3D min_t(u32, max, TPM_MAX_RNG_DATA); + u32 num_bytes =3D min(max, TPM_MAX_RNG_DATA); struct tpm_buf buf; u32 total =3D 0; int retries =3D 5; diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_cor= e.c index 8954a8660ffc..2676e3a241b5 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -310,7 +310,7 @@ static int get_burstcount(struct tpm_chip *chip) return -EBUSY; } =20 -static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) +static int recv_data(struct tpm_chip *chip, u8 *buf, u32 count) { struct tpm_tis_data *priv =3D dev_get_drvdata(&chip->dev); int size =3D 0, burstcnt, rc; @@ -453,7 +453,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, con= st u8 *buf, size_t len) rc =3D burstcnt; goto out_err; } - burstcnt =3D min_t(int, burstcnt, len - count - 1); + burstcnt =3D min(burstcnt, len - count - 1); rc =3D tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality), burstcnt, buf + count); if (rc < 0) --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 2ED14336EEC for ; Wed, 19 Nov 2025 22:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; cv=none; b=IsTUMdAiqsZ2DZTdw7t/0vFsRC2bCT4i0Lx2TbZVGz0RIVKwL4KSrukkrVmxERHvTmYotQFjhNXaeAJmB8BaWGlFmaaPAsTNpin9I+spJK+IRg28/3s+2M1kwURgic6aKFo5M7ALIzKfdUgSRNDiC/JrqRfFCaf56Ad8S/ES+2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; c=relaxed/simple; bh=HmDHkRA9WpbrXOoEfJ/ddkjX0oLoATDvE1Jo76ssmHo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nA+cjiIJBrOUBuOz1t83jXU+mNE4f/btKk4AGgrHxvcJ8N6GJhhbdl9QgzgSeeqE7xaxAai5/70YcM1O4egIOfu0aWVdDny0wbE5IOUpHivfYRURyfYh/LmEzc909WrLP7cHt+Y1TgUAfsy855LPGvMlXgg8TCBuloxwobXA2VA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=yRuc+7k5; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="yRuc+7k5" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt2-006ky3-Rm; Wed, 19 Nov 2025 23:42:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=4WfkeXMO718uzCZ/CSShybOTo3+QWuW28/UydqaDh1k=; b=yRuc+7k5HDeesQBx0pKiQqGifX e2I31OW6Qn46JQlheBVxaD1nMBWzCRF3PLWvQGAfp0DCiQf5jX+J0sn9icn5xsUZLponENMBGAasQ 6w7YPqyRem/wX7QvjuZhyt5cpPbgUnPEsGdadEugR/w2x4FlQ4jQZLWSFi82cGcazF/PHu7Cf3GlY 2FpXez+RgZkqejoYbX1fbEvoCjLo4YPIGm7BIjKUoYxACp8dcl2E/CTRDKOSrnuZvXQRlO5N6Z8nr F3qakQB/Pk5JvOcO3c1VCjtBMFJKsM8zkwyTHdnBOdMmy7nAXmVCmgTnXGGp4+qLyL6mSm/rN75PZ Sb19vLhA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt2-00086d-JF; Wed, 19 Nov 2025 23:42:52 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsc-00Fos6-0b; Wed, 19 Nov 2025 23:42:26 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Cc: "David S. Miller" , Herbert Xu , John Allen , Tom Lendacky , David Laight Subject: [PATCH 16/44] drivers/crypto/ccp: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:12 +0000 Message-Id: <20251119224140.8616-17-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/crypto/ccp/ccp-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index c531d13d971f..246801912e1a 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -507,7 +507,7 @@ int ccp_trng_read(struct hwrng *rng, void *data, size_t= max, bool wait) { struct ccp_device *ccp =3D container_of(rng, struct ccp_device, hwrng); u32 trng_value; - int len =3D min_t(int, sizeof(trng_value), max); + int len =3D min(sizeof(trng_value), max); =20 /* Locking is provided by the caller so we can update device * hwrng-related fields safely --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 4702432570C for ; Wed, 19 Nov 2025 22:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; cv=none; b=SW5f1hUulhz71DzDqL7rqc3IMIZG+1c21Kcu9l48f82qnoZzsaPqHL2goXuSCVPi4Qzx3FU+IjkNU4hPMQag4mSqAEcs6ufHeRlOPvqocVpCQSmoIeaLNm7otSQLNHkuXHC9KCSqH1r4FE/J7Y+nDM39iAsSOsAKR+e91Im8CQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; c=relaxed/simple; bh=Dmi/gNc2WqTmoiCwsXtE9B4qvf+07Fr77NPdal7Sw7s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q/2bxFvyB81PVYAi5CN1QFTinRxsn01AgXrk5rUnPrQb1bYh+QzFPWXzIxPl8ccbE909W4f6rLlizRDVrhOP9aWosgLLLrabQmvPUtxx7sb722CSdC0sFmdDS1XLyy+vIxIuephWBiCnjwkiATgVSGvP2POW8rVp1HdWMmva7NQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=yfvISeaD; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="yfvISeaD" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt3-006yx3-9E; Wed, 19 Nov 2025 23:42:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=5MEknnuAKfJCHXLhDStxABn6W3caLDFPqFcUl+Xl1Hg=; b=yfvISeaDRfFAovzyue1CSfQ/GP cC7NAjRKGJ9qBaGGYP2GJlLbnGgp2/HRubwEQtx9qp0226/4WYXuCk3P465hHpwvpcpiu+U2sgD7Q m0HarcgKN7MYOMq91S5tpj6nCgsxh3CU56Bfni1xExo1F/QQalViyDWqzwl4QCM8l+HkZc2GyJRN3 354LvGa1FdtnzdWMm35F+8gJWqkRYevxbQswY1AWZIuT4HUqDL5bYaOG5euQ+mZ1vn01nyYu9wA2/ s0oFJnRK5SapWrFBFOl2KBiOCSXFgFvdoPksWpmYB0p1t6/SBTkgQc/o9dJwDUtw+wgKqmvuXKwwP gT967xGw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt2-00086j-Vg; Wed, 19 Nov 2025 23:42:53 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsc-00Fos6-L4; Wed, 19 Nov 2025 23:42:26 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org Cc: Alison Schofield , Dan Williams , Dave Jiang , Davidlohr Bueso , Ira Weiny , Jonathan Cameron , Vishal Verma , David Laight Subject: [PATCH 17/44] drivers/cxl: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:13 +0000 Message-Id: <20251119224140.8616-18-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight Acked-by: Dave Jiang --- drivers/cxl/core/mbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index fa6dd0c94656..17aec916e8cd 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -663,7 +663,7 @@ static int cxl_xfer_log(struct cxl_memdev_state *mds, u= uid_t *uuid, u32 offset =3D 0; =20 while (remaining) { - u32 xfer_size =3D min_t(u32, remaining, cxl_mbox->payload_size); + u32 xfer_size =3D min(remaining, cxl_mbox->payload_size); struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_get_log log; int rc; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 190E82F5B; Wed, 19 Nov 2025 22:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592159; cv=none; b=gte9o7jZaHXrSU1jSOFajSXcke2UbYOJ2/TRfNytujHx8E36yh9g310MwXGg3OTwLVzjzf+E8CZeaaRFxEsV0FUP85fdU5w5VrPbd8pL9EeFiHVUqNt44NQ5bUB++qSQsgK9RDEP3pGfD7ZetLs8+fAKck3UD35bAqYdSUHPdA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592159; c=relaxed/simple; bh=tt/IMPwEpLQecANGcddj+ukYcGqvpvlJ/TqDtm477Es=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tddBeuw9O173FsD6mWAJ6xPhc9hCljfl647hskyPFBLVDqv59OAHm5r2Uhs5vO5Q5+CoLYOWmS41sNDR5U2qmEQcd9MVBy1J0ZUDkmcFmycKkDwTec0qCEx9/wgVLj+MbFrL0xd0gy/GRJDxhb1rEKkI3uaPkj39KUU6RKTnljs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=EeHoapDu; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="EeHoapDu" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsm-006ksN-1P; Wed, 19 Nov 2025 23:42:36 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=FJlg4ul1sq6ZIhYuGCfri+UArhKIFxhGhDxLLUHAweI=; b=EeHoapDuKaTV8lNNWBHRSinGgN oGrN6E8WJGCGmQ/UZ8Jwwc0T7nrGHIqcSMnb8z/cZxhehiegTm/tshgB/kN4QR4hVhN9eSZwduGls 2PFLLd1+qwVa7We6HZ1csXYxMfEmciCyRSkMBIcruVyXpLS4RGdBf4LtH3eqk7bBBLCzERwb2FSI7 o9AlR4YV0O87T+tBljrwFgRuuzcQHRkgp8bftdjF1VkA2yXvs/KBIROiR6KWWjhC32bk7bf+h6q1Y Ub+//bZuqPHi3FznD0eTSB+kOmeKwg/2l9abP2d5lW5Xu4ncplHgmJSiFao5JzXAw62EDEkir/tYT fSWzAu0w==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsl-00080B-EF; Wed, 19 Nov 2025 23:42:35 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsd-00Fos6-6X; Wed, 19 Nov 2025 23:42:27 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Mika Westerberg , David Laight Subject: [PATCH 18/44] drivers/gpio: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:14 +0000 Message-Id: <20251119224140.8616-19-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(u16, a, b) casts an 'unsigned long' to 'u16'. Use min(a, b) instead as it promotes the both values to int and so cannot discard significant bits. In this case the values should be ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/gpio/gpiolib-acpi-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-acpi-core.c b/drivers/gpio/gpiolib-acpi-c= ore.c index d441c1236d8c..83dd227dbbec 100644 --- a/drivers/gpio/gpiolib-acpi-core.c +++ b/drivers/gpio/gpiolib-acpi-core.c @@ -1099,7 +1099,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physic= al_address address, return AE_BAD_PARAMETER; } =20 - length =3D min_t(u16, agpio->pin_table_length, pin_index + bits); + length =3D min(agpio->pin_table_length, pin_index + bits); for (i =3D pin_index; i < length; ++i) { unsigned int pin =3D agpio->pin_table[i]; struct acpi_gpio_connection *conn; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 6A55C32B9A6 for ; Wed, 19 Nov 2025 22:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; cv=none; b=msnHuKAgBnr5WTLFRPNFnalp5czD5NNMkpmbeDhafv3QLxi6AXyFW/NaPw4ASK6oCkPwXZ6ezEYHpvS1D+hZlqxLx1Rmpnejoi6tcRrWQ9YOsKrWgtDqWMmEDD2Or9JX1N+VFuBlvNY1Ulhfk7yu8/DL+tOF4loRe8FOxOnLVSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; c=relaxed/simple; bh=xCLv9FusCE6yLnQm5DohNUGPMWTDyVxGTMHgjF2cXEs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vvgk0KaxiHQfqksTpvUgqBN1LDvf7CwKeR8A0dPXmTHWpmCDXNArWiuD2YuDmpBdHj+bsdnoPd37EV06KsPfbGAJ6s5bjs7aB7kjtHaknI+Vu25rI+TLyyYz5BRdYzYHkSnEcCPKKLsMpUHNhlgb8PIHVEuz/Y1K6Oe2WhFS8z4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=mDlHjQLr; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="mDlHjQLr" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsl-006yoa-LL; Wed, 19 Nov 2025 23:42:35 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=KZaeZLqE5bpE2oI7JueUUAQfCDTGIs3rJJZPcaqXWlw=; b=mDlHjQLr3ylsbhaToLWMaW21yW 3UVy21XkacH0+aMXmbQJGgcaEEUcpaPdkWRfbeLgpnQWeuE5UazmtfWFCAxw4PAywzYxbWcWRE5wi yydZf/9QgusRj2ZIM70TwSLTYD0H8U34DcCttEXjGzQbWV1vIw2D5mA1dbb/AfJUSZxy0gC0UxGzm 3mhsqOossZ8FbtNoL7e/1hiK5mJJTtkE/SebrhXQF2cSm2NHVTf/4d9Tp7280RfRfVkSEXjg0swpr Gkjt72YT776jjIc8yqIXhdAFDxwNP31J3hEXpaDULau580GcJrDs4cTQLlPfzOIXGaBPL2mH0NWnz RW6tI2CQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsk-00005F-RE; Wed, 19 Nov 2025 23:42:35 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsd-00Fos6-R9; Wed, 19 Nov 2025 23:42:27 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Harry Wentland , Leo Li , Simona Vetter , David Laight Subject: [PATCH 19/44] drivers/gpu/drm/amd: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:15 +0000 Message-Id: <20251119224140.8616-20-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. min_t(u8, a, b) is particularly likely to be problematic In this case I think the values are small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c b/drivers/gpu= /drm/amd/amdgpu/amdgpu_doorbell_mgr.c index 3040437d99c2..1eb88327a18b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c @@ -211,8 +211,8 @@ int amdgpu_doorbell_init(struct amdgpu_device *adev) adev->doorbell.size =3D pci_resource_len(adev->pdev, 2); =20 adev->doorbell.num_kernel_doorbells =3D - min_t(u32, adev->doorbell.size / sizeof(u32), - adev->doorbell_index.max_assignment + 1); + min(adev->doorbell.size / sizeof(u32), + adev->doorbell_index.max_assignment + 1); if (adev->doorbell.num_kernel_doorbells =3D=3D 0) return -EINVAL; =20 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/a= mdgpu/amdgpu_vm.c index c1a801203949..124ce3e7310e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2388,7 +2388,7 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev= , uint32_t min_vm_size, if (amdgpu_vm_block_size !=3D -1) tmp >>=3D amdgpu_vm_block_size - 9; tmp =3D DIV_ROUND_UP(fls64(tmp) - 1, 9) - 1; - adev->vm_manager.num_level =3D min_t(unsigned int, max_level, tmp); + adev->vm_manager.num_level =3D min(max_level, tmp); switch (adev->vm_manager.num_level) { case 3: adev->vm_manager.root_level =3D AMDGPU_VM_PDB2; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gp= u/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 91c0188a29b2..0180675e76a4 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6257,7 +6257,7 @@ convert_color_depth_from_display_info(const struct dr= m_connector *connector, * or if this was called outside of atomic check, so it * can't be used directly. */ - bpc =3D min_t(u8, bpc, requested_bpc); + bpc =3D umin(bpc, requested_bpc); =20 /* Round down to the nearest even number. */ bpc =3D bpc - (bpc & 1); --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 F20F73314B9 for ; Wed, 19 Nov 2025 22:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592172; cv=none; b=PGH7UhaZOLlkS7T8SIn3JTgTXnvV+s2iC7QBAODvNGYMk8puXj4shR/NmTkXkk9hC8qGbwkXfWN3nGyzP+EMUTXQ+mTdJuIXIWEatFj6EHOBqcgNmvczrGXIRTIPmXD5BKGsvtRuY30AC0oGRxgnoZqJNB9mAlKzA18pbNvldRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592172; c=relaxed/simple; bh=BcSfZrTwXW+tG5DjjJVVlX94/P8il/6qd7mbhqcpDiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SInJD2AwUY4zD6kH74/zzDKhJ0MjdP5aU1qe7ufpT7bBkOqOkC7pr7sCNkcm0o7Gqw5d242uGacd0YlZWG/Xi9irK1Uke8aFuoHY4TNRyu3vFgyZ7dbMkEe7cYW553xny09nXuM3y8isYzdzYijwxg4P0gJn9wvwuFUbgWrNoiE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=pq2pDupl; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="pq2pDupl" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsx-006yuc-Tw for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:48 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=+Igy4kUQLGvcfJ0gjg5dhRoXIT9GJM+aTt6LKCSi1bo=; b=pq2pDuplkexq8wn8TWwg5//+lK 7bypaF24KoUBMmsCgmL/Kl6QeeIIAxklwSAXoUxxvZ6kn3ib2OXUbjMuJjkrgT4a+0urkbTuNR2Mv IUvU2WKS3ySO/zZasLvKLqfYGj59+S6vViVkMuBcrL8b1GDCoqXkjh+tYAv7eJS6ljEgikxkwj8HV kaXa5fTs1jRSoEpYifoJISCEcGmfhKx5Vnk9jspw4E60lQnOB6w/EZjLR5t+eRBlCuQC0atx+XG6a pVTp4qrSgRR3pFjUNQrjSaL4c/8POtkHYpX5pcuLqYZ6pvZ3G/j8zK/BUpIpAKIf827n1BZzfSHFy 7SIX7xaw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsx-0000DP-Es; Wed, 19 Nov 2025 23:42:47 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqse-00Fos6-8d; Wed, 19 Nov 2025 23:42:28 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Andi Shyti , Mika Westerberg , David Laight Subject: [PATCH 20/44] drivers/i2c/busses: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:16 +0000 Message-Id: <20251119224140.8616-21-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(u8, a, b) casts both its arguments to u8 potentially discarding signifinact bits. Use min(a, b) instead as it cannot discard significant bits. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/i2c/busses/i2c-designware-master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busse= s/i2c-designware-master.c index 41e9b5ecad20..8fc51d472a55 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -564,7 +564,7 @@ i2c_dw_recv_len(struct dw_i2c_dev *dev, u8 len) * after receiving the first byte. */ len +=3D (flags & I2C_CLIENT_PEC) ? 2 : 1; - dev->tx_buf_len =3D len - min_t(u8, len, dev->rx_outstanding); + dev->tx_buf_len =3D len - min(len, dev->rx_outstanding); msgs[dev->msg_read_idx].len =3D len; msgs[dev->msg_read_idx].flags &=3D ~I2C_M_RECV_LEN; =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 6D28E331200; Wed, 19 Nov 2025 22:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592171; cv=none; b=ZUuncyQy0fHLh3F4WGzUhqAa8ji4PFiSEJ30ePP81bFKSCnsc8BY7vvg/hMtWQfeGJOQTVUmgnTxyMmC7vwGGX+d98cqo5jRIjxEClrXbeH9egw+AxVpQfw2bbwJlpeYpJ5G3R19cXiLdj1SNfvmf6BHFK2oP/9nlcY562y5HjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592171; c=relaxed/simple; bh=N/IbnlmYobIBjqXyaLWDD1kKA/vX0o9XDEQuSq+W8wM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tBotLpMtOOGA5JlNLDJwecU/7mzS6okSJB7X8ulggN47EvsoWL5ERFQxgHFeeKTYL3S9YkAqXdg87+oQgUW73OSrOnI7hTFWOhbP8/xpKUpWPxmypD7ajl0KtI7TkN83jtPMJTTE/DcvRfA0TL1IQ0XNb82jjpzzzr3KieR2lDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=XxidVeAk; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="XxidVeAk" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsx-006ytZ-EF; Wed, 19 Nov 2025 23:42:47 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=jQD9MKwaMkNHkHE/mXSeUKUpKbq2OrrhCoKJpz21pSA=; b=XxidVeAk4xWpoE93OPqIGOKGSz MC1665YFQipa0pE12wbcTAvhBq3jvZPLoT+6vaYol0TutlwGCjGKw/j8E7G36xjmlYuvTK9gjCtGg W6/MJ9cU0RaqCTynZsiM5mrl9TzhXTvTu+yOGv543IjukGS23po7egyHwcp3giEiYYBIif1PTc7Df s6y1KvuXbs4YiWwvK29hsFTMGU48Fej1i7OHmTKQGmrTvd9HUXBiEGl1Fy+p9tBkiEY7HlraYEudl pARYc4IPO5OQNqdI98MVEOH9T6z9X91v3vLWgeXza/7D+0CfDny0VTjD/LUS4lKOeJiVu5GHvlBZ1 DR+/ly/Q==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsw-0000DJ-P3; Wed, 19 Nov 2025 23:42:46 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqse-00Fos6-TI; Wed, 19 Nov 2025 23:42:29 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Heiner Kallweit , Jakub Kicinski , nic_swsd@realtek.com, Paolo Abeni , David Laight Subject: [PATCH 21/44] drivers/net/ethernet/realtek: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:17 +0000 Message-Id: <20251119224140.8616-22-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/net/ethernet/realtek/r8169_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethern= et/realtek/r8169_main.c index d18734fe12e4..3e636983df4a 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4238,8 +4238,7 @@ static unsigned int rtl8125_quirk_udp_padto(struct rt= l8169_private *tp, } =20 if (trans_data_len < sizeof(struct udphdr)) - padto =3D max_t(unsigned int, padto, - len + sizeof(struct udphdr) - trans_data_len); + padto =3D max(padto, len + sizeof(struct udphdr) - trans_data_len); } =20 return padto; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 65F75337B9F for ; Wed, 19 Nov 2025 22:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592178; cv=none; b=gCa1RrlVPJ0qSer6VSFuwN59rDzxpsKPKgsUzGBsyqQCFJvqTMqxlT2jqNcKtmnSbX8+KgKZ3lhHpQb98hAMsl8YRnAdfQa5MSNgbwJJUEVm/WH3ICfhsT0lEwRpUmK0Es6EUUQbVuNbcUpIMUCJvoi5IfZthBlLga3Kq8n4iws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592178; c=relaxed/simple; bh=s5eG/ZkGuXk9LYMPeAxkm0dh52rV4sIH4WXC8/1L+B4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RFYnz7YUSqRuUvPZzZt2ozWcItiv8HBB9YajkKGZJ3i2Rl3ZhjXBYc8pgElbn1DJ4PaoB06GG0JKQMtyRX4BQCMXExcgwPEgl0swb7X6fTXOwkP8aWUrXoCX9yOwBtaUwqfAYYEJG8xz378ONx9ACTvjY4GZxSKQYRusQ1upKwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=yC8kwNa+; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="yC8kwNa+" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt3-006kyQ-MU; Wed, 19 Nov 2025 23:42:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=INS73H9fpfKpTzIXcq0TyWJMVVqIF72st9McdWRmVUY=; b=yC8kwNa+YVjK5AcjHJjwXb3Gvt uXqDA6KXj2213Be1u7D3HuvZ4X8Bds23OamTIfyV7fEylE8QAnQcsS+mOHwU9fWLlAr6u0OB4MZZj aBprvZBLOsh+3i3Ab8nBivV2nX1Zn5YfLKDOxZi5ZR7a0KAl7OUyRDD8XWfjP6BGhr7A0f9kJMCEm iWaY0rzLcN9hzhF4pPmjeldP842gJxTRxDACHKFKTCJRcjNc6EJqQwcgZ2cvnXs60Psl0X6PfsIih dMXTaKCM/8OK3aYf/RGYcOIJ8LzYUQBNHnGhI45L0ngkV3xNeAmJhj5yh/WU2ZTmgp+wzWT8XzEGS Wj/wmy3Q==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt3-00086p-CJ; Wed, 19 Nov 2025 23:42:53 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsf-00Fos6-Da; Wed, 19 Nov 2025 23:42:29 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , David Laight Subject: [PATCH 22/44] drivers/nvme: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:18 +0000 Message-Id: <20251119224140.8616-23-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/nvme/host/pci.c | 3 +-- drivers/nvme/host/zns.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 72fb675a696f..c74be555a7e9 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -3412,8 +3412,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci= _dev *pdev, * Limit the max command size to prevent iod->sg allocations going * over a single page. */ - dev->ctrl.max_hw_sectors =3D min_t(u32, - NVME_MAX_BYTES >> SECTOR_SHIFT, + dev->ctrl.max_hw_sectors =3D min(NVME_MAX_BYTES >> SECTOR_SHIFT, dma_opt_mapping_size(&pdev->dev) >> 9); dev->ctrl.max_segments =3D NVME_MAX_SEGS; dev->ctrl.max_integrity_segments =3D 1; diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index cce4c5b55aa9..c0b05a220f36 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -126,8 +126,7 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_n= s *ns, const size_t min_bufsize =3D sizeof(struct nvme_zone_report) + sizeof(struct nvme_zone_descriptor); =20 - nr_zones =3D min_t(unsigned int, nr_zones, - get_capacity(ns->disk) >> ilog2(ns->head->zsze)); + nr_zones =3D min(nr_zones, get_capacity(ns->disk) >> ilog2(ns->head->zsze= )); =20 bufsize =3D sizeof(struct nvme_zone_report) + nr_zones * sizeof(struct nvme_zone_descriptor); --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 AA13C31ED8D for ; Wed, 19 Nov 2025 22:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592161; cv=none; b=SEeFCy93f0UE+jb0YzLuJVubHq+Zn1gBXlU5eVMOggjSbkM2VenSYDSIgh8lpnCEpZp5V1I/RK6V0hRZq+0V8i86yXGExj0n6xWj9mCETzGSFOLzdoCOyjbBE4Jq8YBcZGNI1BT+lIhn6YCUM/FkvMK5V2BuFGoU7/jwE7Q9nBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592161; c=relaxed/simple; bh=e898BokG1qPdR+DZ2TG2wIV8DuBv4w9wPX1jSyQIdhY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TF4rxBX4bWrENBkaTdFvYuLnD9YgUTPZdEPw3JMfTDJyX2iurBywzCrpt6bCaOyiILPJaQCDl0hWy2IBWLson4EgqA7q4JMkjSyhBK2B4RnjyWQ2VHt3YL6mUduCV2pV/Y6IIYi435pIo9FfsQyFPX3LCPShQPQQbHWcer1da+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=HJRrLRdf; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="HJRrLRdf" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsn-006ksi-Gc; Wed, 19 Nov 2025 23:42:37 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=jLaB+RBxUfCJpH63+OYZi6YutZXQ6cqU42NpGBevRMo=; b=HJRrLRdfQ43uA2ITBg4J1EThEj Zi/XVxlVU2bzgH/kIrdCwO7V9uRWr+40fyuedQBGpQsc8+7TslekNVEu7JLnWwunAlCqjRbVd8zBK WOcl1FO24kCWaHXVIC9JXcmoP9D/qBeTU6mo4FFTqkuRbKIJY+pUhff9OIUnJe7sku7UVnoSzZaRj Ky0YIhFcU2daJF+l3ACs6kdXkkp0dxcsTB1DPqEAWx9g4Jelfi/UxvFxVi+xBgokK/l6Vx0Mus8hf caDh++RHWQLmjO47TD96JPeEotCogbYZ0uRhEHWQgPigzKJP/waXkCsFzWByLGpVCHj6adBpQBUXJ vJ9BlB4g==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsn-00006z-0A; Wed, 19 Nov 2025 23:42:37 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsg-00Fos6-0d; Wed, 19 Nov 2025 23:42:30 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Borislav Petkov , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , x86@kernel.org, David Laight Subject: [PATCH 23/44] arch/x86/mm: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:19 +0000 Message-Id: <20251119224140.8616-24-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- arch/x86/mm/pat/set_memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 970981893c9b..148c1880a823 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1459,7 +1459,7 @@ static void unmap_pmd_range(pud_t *pud, unsigned long= start, unsigned long end) */ if (start & (PMD_SIZE - 1)) { unsigned long next_page =3D (start + PMD_SIZE) & PMD_MASK; - unsigned long pre_end =3D min_t(unsigned long, end, next_page); + unsigned long pre_end =3D min(end, next_page); =20 __unmap_pmd_range(pud, pmd, start, pre_end); =20 @@ -1503,7 +1503,7 @@ static void unmap_pud_range(p4d_t *p4d, unsigned long= start, unsigned long end) */ if (start & (PUD_SIZE - 1)) { unsigned long next_page =3D (start + PUD_SIZE) & PUD_MASK; - unsigned long pre_end =3D min_t(unsigned long, end, next_page); + unsigned long pre_end =3D min(end, next_page); =20 unmap_pmd_range(pud, start, pre_end); =20 @@ -1591,9 +1591,9 @@ static long populate_pmd(struct cpa_data *cpa, unsigned long pre_end =3D start + (num_pages << PAGE_SHIFT); unsigned long next_page =3D (start + PMD_SIZE) & PMD_MASK; =20 - pre_end =3D min_t(unsigned long, pre_end, next_page); + pre_end =3D min(pre_end, next_page); cur_pages =3D (pre_end - start) >> PAGE_SHIFT; - cur_pages =3D min_t(unsigned int, num_pages, cur_pages); + cur_pages =3D min(num_pages, cur_pages); =20 /* * Need a PTE page? @@ -1668,9 +1668,9 @@ static int populate_pud(struct cpa_data *cpa, unsigne= d long start, p4d_t *p4d, unsigned long pre_end; unsigned long next_page =3D (start + PUD_SIZE) & PUD_MASK; =20 - pre_end =3D min_t(unsigned long, end, next_page); + pre_end =3D min(end, next_page); cur_pages =3D (pre_end - start) >> PAGE_SHIFT; - cur_pages =3D min_t(int, (int)cpa->numpages, cur_pages); + cur_pages =3D min(cpa->numpages, cur_pages); =20 pud =3D pud_offset(p4d, start); =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 AF35C30DD3A for ; Wed, 19 Nov 2025 22:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592160; cv=none; b=DdJFW0AfhlncOAVJLVTrwifXWtTdWsK0ICCx0XcszeAgKR4WTO6GxHP7/61s1sdmi03a9g+64gd11dVpaj6BbVgePsc40A7BgWkeUh4/dBYjqYRvZP+UtJTGfGeN93eM052v2TNVv/X38vSa1bSHzQmU8Ia38HHSJmGQ0DJUjtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592160; c=relaxed/simple; bh=hyzVVjTSJlC1E8OKMLO7XNxgAux/QpvEyehYdPBL3s8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hH2hrQZ3VyGgP+1X358EV0NpYnsUKIbRwnMIgYqMAFZLzFVbXHsgXjNSB5B7eR2x7ubKVeAihCkfhOTpvaRgCWK2jxp+5tf/TEBo0wA3JKRKnRCg0JGeZY1D18hvZKYp2yokkSSbJqnTKme/zeFSGB0+4kAJwEnn9YLDhWHsxqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=0R/F9b6g; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="0R/F9b6g" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsm-006ksS-Ji; Wed, 19 Nov 2025 23:42:36 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=o6mVTuxrgEQ+tTQ1DsDzrfzaC0rJ6013cLt7rd7pss8=; b=0R/F9b6gZ8zRBCHuDM8ws2te7k F5g+QW1s9ajDxb4KGewCKKcI2vocoR3K1uUJeXHNqEGizT7nRiDVjYhIN0gZ7rDDMi7IiAZ13Io/V rsU6los3KsBUpjjwxfF3CIT0E1FcBqhxh0/7zP6E4sZSEUOhpvoP/KmEeml4A3GFr5lUWQ/dXhlhh tIuhGk5yb+H2/vkeryPuYyj1QFrXsmtl5Io0Trlct1cy6jI+LwclfTyx346d/odDZ80h/ZGE8wdQU RPyI4RRGNsvtGm5474tPyRkbio8qDGij7Q1Js2QS769pCyrFgrCB9DTh/t5STyFvZwiSQl1LPOgTc b2vUjCVA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsl-00006N-UM; Wed, 19 Nov 2025 23:42:36 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsg-00Fos6-BS; Wed, 19 Nov 2025 23:42:30 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Srinivas Kandagatla , David Laight Subject: [PATCH 24/44] drivers/nvmem: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:20 +0000 Message-Id: <20251119224140.8616-25-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 387c88c55259..8d6e78343054 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -359,7 +359,7 @@ static ssize_t nvmem_cell_attr_read(struct file *filp, = struct kobject *kobj, goto destroy_cell; } =20 - read_len =3D min_t(unsigned int, cell_sz - pos, count); + read_len =3D min(cell_sz - pos, count); memcpy(buf, content + pos, read_len); kfree(content); =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 7D9D032C333; Wed, 19 Nov 2025 22:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; cv=none; b=GX6qg2PoasfqEpxhctENh3KI9EJH97s5YyFcSckGTEnkGJsDsAEFsB+2bfUtqbB1dnaxfjIbFPlCkFfFnH/z03OYvvddNY6FJ8sc1gkjgOsv/gAXIp9vA5J0FAkXVGcy5yv+roAUyZp5oVl9n0h8aw59t9UpbO6oIl8BblZVMog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; c=relaxed/simple; bh=xi1t4MFBQ1L8tT9qBtdZpKRHloM9ntgypdnghQeHWDg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KSAw9T8m8WoQKUkEiDngTWABlSCyhc0aEYBibZUD0XDDT7Bbtbcm6OPDC/LkxWQhN10bd/oAXkWIHUMHrrxOoc1sTq07CvDOpYpGOSptcgD74GwSyuYLa6af4GCk4D0biK5iy0H3aR3daLeVMKRWbGfup/p/Q5Tudkf4keO2hJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=ADyj2e5H; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="ADyj2e5H" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsm-006you-TB; Wed, 19 Nov 2025 23:42:36 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=VlTq4CSr8IVQYIyEUXYTQu65fyJbQD/rfAsxYUTy3tQ=; b=ADyj2e5H26WHkINTwYZB0c1OVX rE/Oj5NDMWcAhzBDVK7jHNJaFxgM23dxoPBAagy/pLzlObzYMvGIQ/+yYv4aaq4uI8A025mF5V1Fj rlDmX9ev18QxNIz0+YZGnXQEVT58UiYAqoBo6z28fhLSXhf7o/Qr71XSeu33wEQN9WvsFvlYKn+D2 DO1eJY9hjEms79MBX6LO4gBB9QCBMzO2BbKQyvooNrbUHAUgj4g+Ra1Uw/6032dtlaOlsbMZY9WeY YsXyhu1okMAAgMjJdw21k7RLt+45f7kk03EP9iOf4cgsw0VK22WQHk0oJf/gh5iRXQjEPaOdb5F9l YH1XSglg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsm-00006p-J4; Wed, 19 Nov 2025 23:42:36 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsg-00Fos6-Nd; Wed, 19 Nov 2025 23:42:30 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: Bjorn Helgaas , David Laight Subject: [PATCH 25/44] drivers/pci: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:21 +0000 Message-Id: <20251119224140.8616-26-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case although pci_hotplug_bus_size is 'long' it is constrained to be <=3D 255. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/pci/probe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 0ce98e18b5a8..0f0d1b44d8c2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3163,8 +3163,7 @@ static unsigned int pci_scan_child_bus_extend(struct = pci_bus *bus, * bus number if there is room. */ if (bus->self && bus->self->is_hotplug_bridge) { - used_buses =3D max_t(unsigned int, available_buses, - pci_hotplug_bus_size - 1); + used_buses =3D max(available_buses, pci_hotplug_bus_size - 1); if (max - start < used_buses) { max =3D start + used_buses; =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 C2985333437 for ; Wed, 19 Nov 2025 22:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592173; cv=none; b=QTt+3CH+tNCdVnhpNpKRpn0PVgKVzS4T+aRlKVwe7D8aDBK/8leze5+c1XzRyIhZ6CzjY4yoOpX9kuGmkO9sSv3tgB9eziMIVnu9LftHXtMgo7TUsFd/6HwDK8jWOhxgcYVaNq4dAc1M/1jHkOfB7iQ8nvgyZ8HMEk6GmDqblJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592173; c=relaxed/simple; bh=B/BgXU5jGXqJ8fx8DyMLnoTeMyEquDEs1wZn5Q9FMGU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JfnSorkM9QadexTVN00TpkIJv55jFOvVd2eofuS0/tFYg2c96ogI9CASnCje24JnFUQ+s3QzcFhap5h98k2wdqAELxggNHZ5BOhigucKXyHgrrabuyoUsMwga8Z+M6qEc9CAFvgsoDfjZ3pYiw2kuYpQNCXKDcjVaB+9lEo44Bg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=XpU1b4FH; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="XpU1b4FH" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsz-006yvi-PV; Wed, 19 Nov 2025 23:42:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=7Jg96M0LjfV6/eOJGD1SEnq9R+t62GdGi4Bj0LyUpIg=; b=XpU1b4FHNKlpt6uwtsYlM79geS N2oR9Qnt6KgDPVal4oFlF7GAgyv8JNyloJjV3NA88L0/vKvVHgLzHwi/MSf9LjntyiGon647xG7Rm /m4I8QSpM7TsIPNRzOmL5V1/LQqGuQbkWlGWoZdoxHoMuSLnRH5YXICQ3v7jPbYhTbVQba/374OEo 7TJ7q3meKGbrzxZvuKVxB6w3lqAJpjK49sWeZh96FNwyGm6m5vNjJkYQsOtRTosh509xr3Z6B+q6e CCa0pLHG+2ZnIylMoZrwON/A+JT0LK68d8lxpJPphtgysMjCmry62l4tagrDn9hqNjQA0/ld3QaDb fkrqhZGw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsz-00086G-H3; Wed, 19 Nov 2025 23:42:49 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsh-00Fos6-4t; Wed, 19 Nov 2025 23:42:31 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Cc: "James E.J. Bottomley" , "Martin K. Petersen" , David Laight Subject: [PATCH 26/44] drivers/scsi: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:22 +0000 Message-Id: <20251119224140.8616-27-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/scsi/hosts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 17173239301e..b15896560cf6 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -247,7 +247,7 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, str= uct device *dev, shost->dma_dev =3D dma_dev; =20 if (dma_dev->dma_mask) { - shost->max_sectors =3D min_t(unsigned int, shost->max_sectors, + shost->max_sectors =3D min(shost->max_sectors, dma_max_mapping_size(dma_dev) >> SECTOR_SHIFT); } =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 85B60332EBC; Wed, 19 Nov 2025 22:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592173; cv=none; b=jykhkwMPiFWR1OV2lCqVcgWLLKEx6nPW7aCYYo2wljdv5kL7btNOaLOR5LmXWV6mSHYXxdxK+GxZ8GFWP+SGOAhTAd2X2idsLJH5IWsYXOcfDhcCm9dw8fzT5s3erB4wTptKRIAwSwiPxCfZWMz0Yjt41J0yPvSFKIszq4nbUrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592173; c=relaxed/simple; bh=T0Sxp6xsTa8WHrZCPbphVeR1iBAUpsGRCq/LGdqVZ7o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qM/zo+ajYS3/IeF+OpyKKItfQRaMy+ZnLKGNYG8dpFe7HufDIQYqc1faV8Zc2Bt054QB6ggJuCVLXXTZiqHBW6OWQP7Rk+XzPp67RjNgQ8oL2uUcSC60gaDITPlYzvbg/q9LJZpL9kzJQr0Snnp0p7+3eVQJs3rcZAj9zgAcuRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=2QQoyEmF; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="2QQoyEmF" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsz-006yvY-CN; Wed, 19 Nov 2025 23:42:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=kajQNevhoLguN2aApJmIevDLTauYCAm5/mL/qG+eV6w=; b=2QQoyEmF89XnRHRftzYQ3PCMno j8slCyBoubJF4Z+hMjOecF3xZQOoc395Mx5+XcCxFu9p46TImC1VgYqxrVCejxPrsilkTX5pKhozr QkAWo3Nw7BVXcgdfnFADk2LmDf6/x8bM2NspHWc6ut3qUMxJC8Soz48/1vh8OLKYuJTMv2KG4v9bG OWYSx9Bh4tpmi4k1DFxUYTmFeZQLeoHV10+u53JB28l6E6HqKWN8N1ARPyzZWUwPyLSAEa50jyE2s 5dyKrg1fCbxEDzZWx72ZQwM1p74tntZC5G2VK9j0dCMqvPJCkvPyCCT50liutIYbfQ5byu/nfuDOl bMQsXtVA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsz-00086B-3c; Wed, 19 Nov 2025 23:42:49 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsh-00Fos6-JE; Wed, 19 Nov 2025 23:42:31 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , David Laight Subject: [PATCH 27/44] drivers/tty/vt: use umin() instead of min_t(u16, ...) for row/col limits Date: Wed, 19 Nov 2025 22:41:23 +0000 Message-Id: <20251119224140.8616-28-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The row/column bounds (for a screen window box) are changed from 'offset one' to 'offset zero' and bound to the screen size using: v->xs =3D min_t(u16, v->xs - 1, vc->vc_cols - 1); This has the side effect of converting zero to the limit. A check I'm adding to min_t() reports that (u16)(v->xs - 1) (etc) discards signiticant bits (because v->xs is promoted to 'int' before the addition). If v->xs is zero (it comes from userspace) it converts -1 to 0xffff. This is then bounded to 'vc->vc_cols - 1' which will be fine. Replace with: v->xs =3D umin(v->xs - 1, vc->vc_cols - 1); which again converts a -1 to unsigned - this time to 0xffffffff, with the same overall effect. Whether zero is meant to mean the 'maximum size' is unknown. I can't find any documentation for the ioctl and it pre-dates git. Detected by an extra check added to min_t(). Signed-off-by: David Laight Reviewed-by: Jiri Slaby --- drivers/tty/vt/selection.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index 07d3b93975d3..13f4e48b4142 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c @@ -348,10 +348,11 @@ static int vc_selection(struct vc_data *vc, struct ti= ocl_selection *v, return 0; } =20 - v->xs =3D min_t(u16, v->xs - 1, vc->vc_cols - 1); - v->ys =3D min_t(u16, v->ys - 1, vc->vc_rows - 1); - v->xe =3D min_t(u16, v->xe - 1, vc->vc_cols - 1); - v->ye =3D min_t(u16, v->ye - 1, vc->vc_rows - 1); + /* Historically 0 =3D> max value */ + v->xs =3D umin(v->xs - 1, vc->vc_cols - 1); + v->ys =3D umin(v->ys - 1, vc->vc_rows - 1); + v->xe =3D umin(v->xe - 1, vc->vc_cols - 1); + v->ye =3D umin(v->ye - 1, vc->vc_rows - 1); =20 if (mouse_reporting() && (v->sel_mode & TIOCL_SELMOUSEREPORT)) { mouse_report(tty, v->sel_mode & TIOCL_SELBUTTONMASK, v->xs, --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 B83E4338581 for ; Wed, 19 Nov 2025 22:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592179; cv=none; b=KD7vT8dyvsCFW50qZOl937fxZg+xvue/xBzRIyoSPa5exJXv/d5aeAomwC/u2GpMbg/D2TMABSZ7ko1/TT9wGp6V7p5ar1MRLGfSJY3WlW5xEg5BOaOlCXWE8ZST3VSGi6Jfd5ucdDJ+DVg1uKEEABUu62QjHYoQQFkdXWQ/NfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592179; c=relaxed/simple; bh=cM5V7HEzzL0U3ww5wmvTfgyAchIHG0E1WvqQwcwtJTw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BeWHEhwcDtTflgzmGgetHjSh4Nbcw3anLoUVUQdi8ISEA/17NA9Me7B5boLwBeBE43i5/fqh3425wJRqP+WF7j8kxuMcBz7fWj6ljoGd5847NNrp6I7ixKyFU1xbBNm5yK64Z/8pl4SGEjvFgqy2A5pPBGdet4mWsfJ80uCcZOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=PlFDAXm9; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="PlFDAXm9" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt4-006kyb-93; Wed, 19 Nov 2025 23:42:54 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=kOefzjf50j/74iGOTPMlZK++sMONcJKR9VFlFhM1mCo=; b=PlFDAXm9RjRdKW/sCB0nmCb5xC /0vBr9aRUWXR7wkH7VP6pe7YSCBrI1gFUHgW+aKWdhhFu46N0oVBmW+IKdpsAen5U4UHRN5XO7qQU wD6Rdx5793894P2OhI47vFTydCvpCtGH7jOWX4W+eWaNNQ67ufAnS2JMVML3m3DmF2DXczjAB79J2 U7msPriRSucJ1O6Ccm1JDjX7u782dGWeidLpKHdSCNMhtNGdAygOuF+LGBVcgpMdCPV0DK8fgPX+M q1GNLTu8pBfCMTdgAfy7VcULMG+AvwRh05l7D1A5pvgke29rkfnuWJm7xM2gxt+7dG2aISlSCXkAI Z3rcJoWQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt3-0000EA-OW; Wed, 19 Nov 2025 23:42:54 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsi-00Fos6-26; Wed, 19 Nov 2025 23:42:32 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net Cc: Alan Stern , Greg Kroah-Hartman , David Laight Subject: [PATCH 28/44] drivers/usb/storage: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:24 +0000 Message-Id: <20251119224140.8616-29-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight Acked-by: Alan Stern --- drivers/usb/storage/protocol.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c index 9033e505db7f..0cff54ad90fa 100644 --- a/drivers/usb/storage/protocol.c +++ b/drivers/usb/storage/protocol.c @@ -139,8 +139,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *bu= ffer, return cnt; =20 while (sg_miter_next(&miter) && cnt < buflen) { - unsigned int len =3D min_t(unsigned int, miter.length, - buflen - cnt); + unsigned int len =3D min(miter.length, buflen - cnt); =20 if (dir =3D=3D FROM_XFER_BUF) memcpy(buffer + cnt, miter.addr, len); --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 E346732B9A6 for ; Wed, 19 Nov 2025 22:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592179; cv=none; b=Y4+XHxpgevESoeXLOTe+RUHN5ag9GRxDZ9Yv57BmLZ3JvTbLxEoLsKKgRpeD9WDYN1WZw4y3Q1uOTS2ep2PJilSAMSsTWYtra3/gjZQeKuYUbCPPPAgcfZwOvnVEC5G7UJ4uQayTdjhn4LGBVM6VEXe725ZeQXmLSe17lf5hMiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592179; c=relaxed/simple; bh=RdN0Sn5XuXcEzPy3B/N2a8aHHOEz7sEBT5aYF+wTatU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fp788Qmq4SUv9F3AuUzDGL81Sr5CaA8W/U6oAx5mTLTxhYPDiEESGFxJ65RLZByTXpeVPMjzCFwRLt17x6Pp01AYYi4FVXrsfXoNTMqDQpd+FMsUluiyp+27fXUcmWqrXku5kdcB+VOs0exrPgcV67g4L1ebFGHPZrCI0ITo9uQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=6trSvTPr; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="6trSvTPr" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt4-006kyq-Kn; Wed, 19 Nov 2025 23:42:54 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=BSz/fMMZWekU3UOYf2YMiRRmSk70/lINvYIBRF8e4UI=; b=6trSvTPrR9TLIYpb3iYBdppyha WGIzq5ysNkFIWYc/BDzOaKfbNyE+F+7jG92/HcjuCGJt4fZbzHsNaPlYlnFvHr9BOff+3/yuXxqWa JS5YJ5xYxo63tZzpZf6vO7gxrdDa9Fo8fd8pV+H9YFWPUlN8crOBkwTZf3AmB+4LL8w+ou28qDqrw VMkbPpdw0yYTAtWv/+mNSzFnZ/bSz40I/nsozbru2igARtDlZE42HkRGrhHZmTQLWqy37jrwF9Rdo 8zNe5WZW356E+6uRZifavZ5/X0qaTMzNZcckp/yxg9gyqAsIT6Hhhs7GyyLTGCTbZ7dTaHpcsFDRq 6W1F7/bg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt4-0000EL-9k; Wed, 19 Nov 2025 23:42:54 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsi-00Fos6-E8; Wed, 19 Nov 2025 23:42:32 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Juergen Gross , Stefano Stabellini , David Laight Subject: [PATCH 29/44] drivers/xen: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:25 +0000 Message-Id: <20251119224140.8616-30-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight Reviewed-by: Juergen Gross --- drivers/xen/grant-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 478d2ad725ac..3e76e33f6e08 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -1204,7 +1204,7 @@ void gnttab_foreach_grant_in_range(struct page *page, unsigned int glen; unsigned long xen_pfn; =20 - len =3D min_t(unsigned int, PAGE_SIZE - offset, len); + len =3D min(PAGE_SIZE - offset, len); goffset =3D xen_offset_in_page(offset); =20 xen_pfn =3D page_to_xen_pfn(page) + XEN_PFN_DOWN(offset); --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 47F0232E12E for ; Wed, 19 Nov 2025 22:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592168; cv=none; b=iaAd46i8UJuK9mSe4vlnuXyLluDKFYhr/uXk/El0oPQ4BpcpkVVwWZLfKR7XPSf8P9MKMe8TxtTItACgZF2AFLld2+wtWdcXQSiWYRal6Jis/85H+j8AwJh7x+gN45EqxQdvaJ2cFlhZT65SJcLTPofrDjF1sFsqJ8vSpqc9UuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592168; c=relaxed/simple; bh=UsSoZiy+1nMHZ0p5txeT4iFPKqhi6guap0+rcMJ/Rb4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pSDgJxmw7ueFIUKt7ozDXzE8bFHJhakE+hGi7XHX1J9wRMrDsYruZ40s7SfDqGO6Dtgxm7U4yjEHJYoWGByYUHXt+4NV++bAfdDlgJnvu4NtEqjHWul/NWWoT8iaOrzniMUdnFDEEsmSbr5YeV7f/tDgqzPahYSU0mZzjC9QH2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=zAjm3AIV; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="zAjm3AIV" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqst-006ku6-Uk; Wed, 19 Nov 2025 23:42:43 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=vO7m5qP2A9vVNTA8gRtFqJvwI1Y/pavLSEelmj0I3GM=; b=zAjm3AIVhb5JXtwqa2DXJ3XcjP NRHRr2fM2TOD1SDfChTuYTNW6Xw2SqIbJFjG/OWGO8y4iW7cKtluhdsFRF0JLpm9xJpD1t05rLP16 dYHKZ9/5NlKar3NX7NN3Aw/Xh902jfi6XdGEWcb+4BSjxJsOGIijJNy/xSHfTuqKkjY4NXgQjW1Mn V8wzx3P8ulJpjvIyvLv1Stl/Lxb0T3Kf+FlOCeMbGvAUwZzaaXwkDel56c/Wl4Ggs1qtmHedINWr8 iXQVLFtPr6RKgEr19snAdxhuDWgV1SFWopndEL7GjrTCQQnEh5nzTPrSU5sxT4Xl4TxR/FE9bIVT1 r49qx26g==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqst-0000Ch-EE; Wed, 19 Nov 2025 23:42:43 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsj-00Fos6-5A; Wed, 19 Nov 2025 23:42:33 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Alexander Viro , Andreas Dilger , Christian Brauner , Kees Cook , Miklos Szeredi , OGAWA Hirofumi , "Theodore Ts'o" , David Laight Subject: [PATCH 30/44] fs: use min() or umin() instead of min_t() Date: Wed, 19 Nov 2025 22:41:26 +0000 Message-Id: <20251119224140.8616-31-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. A couple of places need umin() because of loops like: nfolios =3D DIV_ROUND_UP(ret + start, PAGE_SIZE); for (i =3D 0; i < nfolios; i++) { struct folio *folio =3D page_folio(pages[i]); ... unsigned int len =3D umin(ret, PAGE_SIZE - start); ... ret -=3D len; ... } where the compiler doesn't track things well enough to know that 'ret' is never negative. The alternate loop: for (i =3D 0; ret > 0; i++) { struct folio *folio =3D page_folio(pages[i]); ... unsigned int len =3D min(ret, PAGE_SIZE - start); ... ret -=3D len; ... } would be equivalent and doesn't need 'nfolios'. Most of the 'unsigned long' actually come from PAGE_SIZE. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- fs/buffer.c | 2 +- fs/exec.c | 2 +- fs/ext4/mballoc.c | 3 +-- fs/ext4/resize.c | 2 +- fs/ext4/super.c | 2 +- fs/fat/dir.c | 4 ++-- fs/fat/file.c | 3 +-- fs/fuse/dev.c | 2 +- fs/fuse/file.c | 8 +++----- fs/splice.c | 2 +- 10 files changed, 13 insertions(+), 17 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 6a8752f7bbed..26c4c760b6c6 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2354,7 +2354,7 @@ bool block_is_partially_uptodate(struct folio *folio,= size_t from, size_t count) if (!head) return false; blocksize =3D head->b_size; - to =3D min_t(unsigned, folio_size(folio) - from, count); + to =3D min(folio_size(folio) - from, count); to =3D from + to; if (from < blocksize && to > folio_size(folio) - blocksize) return false; diff --git a/fs/exec.c b/fs/exec.c index 4298e7e08d5d..6d699e48df82 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -555,7 +555,7 @@ int copy_string_kernel(const char *arg, struct linux_bi= nprm *bprm) return -E2BIG; =20 while (len > 0) { - unsigned int bytes_to_copy =3D min_t(unsigned int, len, + unsigned int bytes_to_copy =3D min(len, min_not_zero(offset_in_page(pos), PAGE_SIZE)); struct page *page; =20 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 9087183602e4..cb68ea974de6 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -4254,8 +4254,7 @@ void ext4_mb_mark_bb(struct super_block *sb, ext4_fsb= lk_t block, * get the corresponding group metadata to work with. * For this we have goto again loop. */ - thisgrp_len =3D min_t(unsigned int, (unsigned int)len, - EXT4_BLOCKS_PER_GROUP(sb) - EXT4_C2B(sbi, blkoff)); + thisgrp_len =3D min(len, EXT4_BLOCKS_PER_GROUP(sb) - EXT4_C2B(sbi, blkof= f)); clen =3D EXT4_NUM_B2C(sbi, thisgrp_len); =20 if (!ext4_sb_block_valid(sb, NULL, block, thisgrp_len)) { diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 050f26168d97..76842f0957b5 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -1479,7 +1479,7 @@ static void ext4_update_super(struct super_block *sb, =20 /* Update the global fs size fields */ sbi->s_groups_count +=3D flex_gd->count; - sbi->s_blockfile_groups =3D min_t(ext4_group_t, sbi->s_groups_count, + sbi->s_blockfile_groups =3D min(sbi->s_groups_count, (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); =20 /* Update the reserved block counts only once the new group is diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 33e7c08c9529..e116fe48ff43 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4830,7 +4830,7 @@ static int ext4_check_geometry(struct super_block *sb, return -EINVAL; } sbi->s_groups_count =3D blocks_count; - sbi->s_blockfile_groups =3D min_t(ext4_group_t, sbi->s_groups_count, + sbi->s_blockfile_groups =3D min(sbi->s_groups_count, (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); if (((u64)sbi->s_groups_count * sbi->s_inodes_per_group) !=3D le32_to_cpu(es->s_inodes_count)) { diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 92b091783966..8375e7fbc1a5 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -1353,7 +1353,7 @@ int fat_add_entries(struct inode *dir, void *slots, i= nt nr_slots, =20 /* Fill the long name slots. */ for (i =3D 0; i < long_bhs; i++) { - int copy =3D min_t(int, sb->s_blocksize - offset, size); + int copy =3D umin(sb->s_blocksize - offset, size); memcpy(bhs[i]->b_data + offset, slots, copy); mark_buffer_dirty_inode(bhs[i], dir); offset =3D 0; @@ -1364,7 +1364,7 @@ int fat_add_entries(struct inode *dir, void *slots, i= nt nr_slots, err =3D fat_sync_bhs(bhs, long_bhs); if (!err && i < nr_bhs) { /* Fill the short name slot. */ - int copy =3D min_t(int, sb->s_blocksize - offset, size); + int copy =3D umin(sb->s_blocksize - offset, size); memcpy(bhs[i]->b_data + offset, slots, copy); mark_buffer_dirty_inode(bhs[i], dir); if (IS_DIRSYNC(dir)) diff --git a/fs/fat/file.c b/fs/fat/file.c index 4fc49a614fb8..f48435e586c7 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -140,8 +140,7 @@ static int fat_ioctl_fitrim(struct inode *inode, unsign= ed long arg) if (copy_from_user(&range, user_range, sizeof(range))) return -EFAULT; =20 - range.minlen =3D max_t(unsigned int, range.minlen, - bdev_discard_granularity(sb->s_bdev)); + range.minlen =3D max(range.minlen, bdev_discard_granularity(sb->s_bdev)); =20 err =3D fat_trim_fs(inode, &range); if (err < 0) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 132f38619d70..0c9fb0db1de1 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1813,7 +1813,7 @@ static int fuse_notify_store(struct fuse_conn *fc, un= signed int size, goto out_iput; =20 folio_offset =3D ((index - folio->index) << PAGE_SHIFT) + offset; - nr_bytes =3D min_t(unsigned, num, folio_size(folio) - folio_offset); + nr_bytes =3D min(num, folio_size(folio) - folio_offset); nr_pages =3D (offset + nr_bytes + PAGE_SIZE - 1) >> PAGE_SHIFT; =20 err =3D fuse_copy_folio(cs, &folio, folio_offset, nr_bytes, 0); diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f1ef77a0be05..f4ffa559ad26 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1252,10 +1252,8 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_= args *ia, static inline unsigned int fuse_wr_pages(loff_t pos, size_t len, unsigned int max_pages) { - return min_t(unsigned int, - ((pos + len - 1) >> PAGE_SHIFT) - - (pos >> PAGE_SHIFT) + 1, - max_pages); + return min(((pos + len - 1) >> PAGE_SHIFT) - (pos >> PAGE_SHIFT) + 1, + max_pages); } =20 static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) @@ -1550,7 +1548,7 @@ static int fuse_get_user_pages(struct fuse_args_pages= *ap, struct iov_iter *ii, struct folio *folio =3D page_folio(pages[i]); unsigned int offset =3D start + (folio_page_idx(folio, pages[i]) << PAGE_SHIFT); - unsigned int len =3D min_t(unsigned int, ret, PAGE_SIZE - start); + unsigned int len =3D umin(ret, PAGE_SIZE - start); =20 ap->descs[ap->num_folios].offset =3D offset; ap->descs[ap->num_folios].length =3D len; diff --git a/fs/splice.c b/fs/splice.c index f5094b6d00a0..41ce3a4ef74f 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1467,7 +1467,7 @@ static ssize_t iter_to_pipe(struct iov_iter *from, =20 n =3D DIV_ROUND_UP(left + start, PAGE_SIZE); for (i =3D 0; i < n; i++) { - int size =3D min_t(int, left, PAGE_SIZE - start); + int size =3D umin(left, PAGE_SIZE - start); =20 buf.page =3D pages[i]; buf.offset =3D start; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 5CBB430149E for ; Wed, 19 Nov 2025 22:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592167; cv=none; b=P2eE4HsJWYTq1+DHXl+N0sEYd6PTNZczTAaGmhTK+pzXxNzHJ51kdtMIvw8E/tOhNAmTv2ut5D3OxXg1R8VJ5U16ijJkzhfJmZEHTTujgjg8NR4UkPx7xvu8VZv5tPjiWk5LH9X3nPsW+Oj4EhgxZvmghc0Tlz3tISRo1nokpBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592167; c=relaxed/simple; bh=g60Rg3Blvfh9qgL8PXDaIT0h46xfSnzee+mP4szbxzQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bMlk+iEyYMsax5VqLfJCN2VVeD9G2rIlEdnF3hsUzQTs6vESxMh16mDkLIPiNJTi7rzw5skIKUmatW+tMgeEF8QHAIW/gbjilIfbRYku4d44uatgGrLBeopz1MJJ4Xqb7YLSvzM/6x7vLeil21pZNhkiQcViXOY5vxfsL3fjnxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=E6+dxLu3; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="E6+dxLu3" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqst-006ktv-84; Wed, 19 Nov 2025 23:42:43 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=ysDW8qwXmRgKHZdg4L2eLNx73N6/MPjiQ+A1E28GvOk=; b=E6+dxLu3s+fU7AN6k9d5NzmFtR ItJMW/F8K+4swgS28GPYyUL8Ps4j3X9tbN/f0Pq+13TmwifX8+ooezHy3UlQ5qu/ZlzLycJ8G8l69 zaP9m/3UcfkiP28nG9bibQxYFqmSqS6zV9DOQvf/EEOy5LRUbIE2RccTRrgUNFx6FM37v0/Kuadp/ GUPCBL70XZASgyc3PEBW8BAIBmcHoYZP+eO3RUyezY8x0vWuYV8U86G1kX626/EIFTRjHC37zDR2T VaR/VDhKJg7tFw2vDMtwNNQ2RyckK2bNqwSEVTWosL2ze9Y7h8wpAg6JDPNGyTbWqhR6Rdkmlryfn t9h7B3dQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqss-00085Z-UH; Wed, 19 Nov 2025 23:42:43 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsj-00Fos6-Ea; Wed, 19 Nov 2025 23:42:33 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: David Laight Subject: [PATCH 31/44] block: bvec.h: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:27 +0000 Message-Id: <20251119224140.8616-32-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- include/linux/bvec.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 3fc0efa0825b..dbef99624bd5 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -219,8 +219,7 @@ static inline void bvec_advance(const struct bio_vec *b= vec, bv->bv_page =3D bvec->bv_page + (bvec->bv_offset >> PAGE_SHIFT); bv->bv_offset =3D bvec->bv_offset & ~PAGE_MASK; } - bv->bv_len =3D min_t(unsigned int, PAGE_SIZE - bv->bv_offset, - bvec->bv_len - iter_all->done); + bv->bv_len =3D min(PAGE_SIZE - bv->bv_offset, bvec->bv_len - iter_all->do= ne); iter_all->done +=3D bv->bv_len; =20 if (iter_all->done =3D=3D bvec->bv_len) { --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 89D3B32F757 for ; Wed, 19 Nov 2025 22:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592170; cv=none; b=Tjst+LwXp7XasBgpxCiWXpKwKrq2+eSznKy67bgcLQwpgJbzx0Zd2XCaMDdhEC5BZth41DxRUdN3wK9j82K7FeeGhMtM9OFzWe3GOSVHMS+iVlOVX7kKf2Lcz8SiFOe3IRfvMOmibm0XzdoIjblhcj4v44OMpawkAulJNWDZ5/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592170; c=relaxed/simple; bh=RMIqtmN/4RtL6p2LVa4RE3s9P+G0q/VqczqUzreyLgk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rE7BbMPUv3+s80GuaW7pJWDzR/QXk4bHp8e6RwUYiXsoR56pBl/8zT+lF33dOfJIGqCrFKalMgXCJP3vhf3noZC4JYfJVhPHtpRVX1tk9T4IPQN7JfiB5YrYsrTQkMODlxDx3kxeqUJh7CTWI+ECqM3ilR6T4ZfU7qrHGF3Z5V8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=Q5dkjt+f; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="Q5dkjt+f" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsu-006yqv-Uk; Wed, 19 Nov 2025 23:42:44 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=sV4oS4H81Abb8E2Fnwq0jTIcGfJEaFUdtU0rGla/620=; b=Q5dkjt+fZOi7S4O0fj+VAf0h41 SOnGf+oNFSb35KGyPZ4czF2mWQxkrtckQX8hbn9bvD1vth6dV2SmS69FLyWEePH20TzlSMrDeQ/qD ziTJO/07EJh+YE0H5X7Lqht+Okn8IYJJSLam4DTu8TLtO3mk2+AO/zk7nGb8pWQrpxl3gy13l+h1K nXu2Jii4ZxojlEc/8TJc1ZJJl/zYlmje1HIz8KgH8SVLu4kZ5DMCgxoheqS8x0cwgXEG5M4xRIEyU L4R2TlzuqN2kpgrOZtW1fRYEVbUOim7DYyxy4tKodJEyExfWrEDUX+K1YjIg5zMbCyMYaBMnXMKwm MXgd5LPw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsu-0000Cn-0e; Wed, 19 Nov 2025 23:42:44 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsj-00Fos6-PO; Wed, 19 Nov 2025 23:42:33 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Yury Norov , David Laight Subject: [PATCH 32/44] nodemask: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:28 +0000 Message-Id: <20251119224140.8616-33-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- include/linux/nodemask.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 7ad1f5c7407e..bd38648c998d 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -245,18 +245,18 @@ static __always_inline int __nodes_weight(const nodem= ask_t *srcp, unsigned int n } =20 /* FIXME: better would be to fix all architectures to never return - > MAX_NUMNODES, then the silly min_ts could be dropped. */ + > MAX_NUMNODES, then the silly min()s could be dropped. */ =20 #define first_node(src) __first_node(&(src)) static __always_inline unsigned int __first_node(const nodemask_t *srcp) { - return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_N= UMNODES)); + return min(MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES)); } =20 #define next_node(n, src) __next_node((n), &(src)) static __always_inline unsigned int __next_node(int n, const nodemask_t *s= rcp) { - return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NU= MNODES, n+1)); + return min(MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1)); } =20 /* @@ -293,8 +293,7 @@ static __always_inline void init_nodemask_of_node(nodem= ask_t *mask, int node) #define first_unset_node(mask) __first_unset_node(&(mask)) static __always_inline unsigned int __first_unset_node(const nodemask_t *m= askp) { - return min_t(unsigned int, MAX_NUMNODES, - find_first_zero_bit(maskp->bits, MAX_NUMNODES)); + return min(MAX_NUMNODES, find_first_zero_bit(maskp->bits, MAX_NUMNODES)); } =20 #define NODE_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES) --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 31ECC336EFE for ; Wed, 19 Nov 2025 22:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; cv=none; b=Wa7DARpMHs93n/qpWvZqZpLOZ7/9jLc6qMuFJqUlrG7tYz0mtt/cRzt+XFVcFwcroGj3Y5zG0U5uHI9K6oYYq23UuADOjSpyz6TOHy6nDsqJwrspNgLZroRQC6CXqcgL+5SEqPQcj8erJW1HADf27dF4RR7Ywve2/U22fZcABdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; c=relaxed/simple; bh=WUjnT82624Zwb8w0p72N3iPJSTbGrnMixK+bCaEsFgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=soebFnp6WtJAt0o6+PrGUCejr5htbvhd99/FHgK/Vp46F5SkmxxwqVPzGjhdp7X+mx47w78vJUSQ3t3yAhXECw0GHnWNBPi/r79XBfrRYuadTjhGmXua7LOUh1K958l2aZftfdu62M9MPBYKivkJ/iZWK0BKYH4WPVfZUO9t4ZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=pKUZV73v; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="pKUZV73v" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt2-006kxx-GN for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=T6H140WlxK80H7srwWZByYIW1P5L3lVvTAZfRz2mH6I=; b=pKUZV73vj4uviqRkfStiZuC8Qj un66Pk6jjjpcM15zBemO/HrioR4OBW5s/2dKVoXhzXUqHUWfIEtoi87O39cIHjDxVm3deEozpBVEt BdgdTTRPP/usaTx5Lq2ZlOzTnVlb0Tl9vkehiAOsxNaJ3Qef03B1NIigMLkYnyinrYJFcS5UK9kjC G/TbDRWNC8DaMrUZ/rJy01hZvYIbqzxjXO8TsTcQ0f/uDaJp14I1N4k6TNjypd7VvDzmxo5rjoFLp O1LLyE/Ow6fWKEO06tx42pSYRW5qP/L5KFWTjOjIVzEOFCE93eMXYv2SIrOeP4KlZhYQIIcw5jgTo XEfRr/Wg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt2-0000E2-6s; Wed, 19 Nov 2025 23:42:52 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsk-00Fos6-2h; Wed, 19 Nov 2025 23:42:34 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: David Laight Subject: [PATCH 33/44] ipc: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:29 +0000 Message-Id: <20251119224140.8616-34-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- ipc/mqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 093551fe66a7..9384eb444b83 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -363,7 +363,7 @@ static struct inode *mqueue_get_inode(struct super_bloc= k *sb, if (info->attr.mq_msgsize > ULONG_MAX/info->attr.mq_maxmsg) goto out_inode; mq_treesize =3D info->attr.mq_maxmsg * sizeof(struct msg_msg) + - min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) * + min(info->attr.mq_maxmsg, MQ_PRIO_MAX) * sizeof(struct posix_msg_tree_node); mq_bytes =3D info->attr.mq_maxmsg * info->attr.mq_msgsize; if (mq_bytes + mq_treesize < mq_bytes) @@ -540,7 +540,7 @@ static void mqueue_evict_inode(struct inode *inode) =20 /* Total amount of bytes accounted for the mqueue */ mq_treesize =3D info->attr.mq_maxmsg * sizeof(struct msg_msg) + - min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) * + min(info->attr.mq_maxmsg, MQ_PRIO_MAX) * sizeof(struct posix_msg_tree_node); =20 mq_bytes =3D mq_treesize + (info->attr.mq_maxmsg * --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 4DDCE3358DB for ; Wed, 19 Nov 2025 22:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; cv=none; b=qcjbCCM0vIILoWom0nKZD1CB0PwtAdrUyjSgD/G4LGrU0MbqWPRpAKvqYFd3dUqwwXT+w77VLq5kQ2niJM/LX0k86X4IbZdHKqgk7Hs383L20z/jzS+WTkkmuLu+3wo7jUb7S9aHih9azeufVCzCzglA2k+dKEY/onHOugkt4bE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; c=relaxed/simple; bh=gAsQ1BSMJqiVR8shfZtZyu7x2+PjqZJQokKQtFZDbhs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F/LWMzYeqO3GPf54BmH4lBVbuBpma1X+5Rs9kgXsiecK8WLbr83l6iE7an2luPBFnKkZhMsDDI1Vpn/KsErlkk7CEexZlLcnUSwNHEHE4a+0CUduE9dmGliMlUpp2gu0dOe2h95c/zKyX7CfsH30ziLZpV0jquSb5VTSq7VRQBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=YJTQK6bP; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="YJTQK6bP" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt2-006kxq-4O for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=lcMHhp25wy5nbuDPLhTDVdMWQ5rl0c1LdhaGtzxA1uQ=; b=YJTQK6bPVL5ryK/U8U+yc5/0S7 X2CDQZgd2Bl2hh7/DQY1DYXJ87uCIBxyP1QRtS2cpgwfmAjGQ6hMpMccxcUZAiHiAP96Kk5ogAcEM OJ3uRc9DCQEZhb9aAvZY8hHJ0s9C/1tkkiL6JFWPSOA8OeNhrK/rMAPlHBouHj0rePAnaJLyNtcHs 5CicLzrQSL1kdLnhVCuPSPlyvbYGJ4WrwPuFzHE2IdmLkd6PJsyMTcv8wOAdMWcZwmkRFviTaP6jC lIYEZRBAdWWYfUrjqJ+WT0QrJSQB97sj8ieuLRllDiyxDGklAEI6Qnp+YEyEY8k72wtR7bFPvQ0Dy q1sS0gkA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt1-0000Dw-QT; Wed, 19 Nov 2025 23:42:51 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsk-00Fos6-Hk; Wed, 19 Nov 2025 23:42:34 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , David Laight Subject: [PATCH 34/44] bpf: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:30 +0000 Message-Id: <20251119224140.8616-35-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- kernel/bpf/core.c | 4 ++-- kernel/bpf/log.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index d595fe512498..4f9808ea51fb 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -1081,7 +1081,7 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image= _ptr, bpf_fill_ill_insns(hdr, size); =20 hdr->size =3D size; - hole =3D min_t(unsigned int, size - (proglen + sizeof(*hdr)), + hole =3D min(size - (proglen + sizeof(*hdr)), PAGE_SIZE - sizeof(*hdr)); start =3D get_random_u32_below(hole) & ~(alignment - 1); =20 @@ -1142,7 +1142,7 @@ bpf_jit_binary_pack_alloc(unsigned int proglen, u8 **= image_ptr, bpf_fill_ill_insns(*rw_header, size); (*rw_header)->size =3D size; =20 - hole =3D min_t(unsigned int, size - (proglen + sizeof(*ro_header)), + hole =3D min(size - (proglen + sizeof(*ro_header)), BPF_PROG_CHUNK_SIZE - sizeof(*ro_header)); start =3D get_random_u32_below(hole) & ~(alignment - 1); =20 diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c index f50533169cc3..01dc13aaa785 100644 --- a/kernel/bpf/log.c +++ b/kernel/bpf/log.c @@ -79,7 +79,7 @@ void bpf_verifier_vlog(struct bpf_verifier_log *log, cons= t char *fmt, /* check if we have at least something to put into user buf */ new_n =3D 0; if (log->end_pos < log->len_total) { - new_n =3D min_t(u32, log->len_total - log->end_pos, n); + new_n =3D min(log->len_total - log->end_pos, n); log->kbuf[new_n - 1] =3D '\0'; } =20 --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 62B4A2C178E; Wed, 19 Nov 2025 22:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592172; cv=none; b=JQZNnMRi8a6TeuxFjFdA+KKPk8t+wHyf60sh0c0MW9NbtU61oNegn8pt4k56u8G3yQ5pTPNEmIhJf7blnvpyxtpkxWii9c2N+cIKGCJ0j+iH8NL/LL75/Re+/gRUvWBC4281Z3SmsCkcP2490GMeOdH2xTcp8MEZPvBqq2poez0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592172; c=relaxed/simple; bh=WL0PXhXU9WzA14alwt1F7pd1ySSZ0ovhU3GxmPY01xU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sZOco4V/Sempa+kwlqbkppoarznoGqURYCbohfEmxP+F9AWpK7kE7vUmU3s7wRSZQI36eezov2ETTht7yT4eBV4iTbQkjePKqRkxBln47VnhZw0l3cZwXF1z5U5obl2fX6jwjLV3eYo7mz6Znnc0d7YjKZSUl8kOlZKZTIdPkXc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=mJmOyflN; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="mJmOyflN" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsy-006kwn-JE; Wed, 19 Nov 2025 23:42:48 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=9HRmK+hbwURnGQuKYeIXbIO2jWPVVl5U3dF50i9W/9w=; b=mJmOyflNz4dWxZBUr5CLXi9xsa ydk558tWK0Ta32NGSHQdEft+yG/07JG0lWYF5dC4xQcNxG6aE3YSXXBr0B2akA+lbRf3+exZ9ciKf T2XY/zj9UphkAnFOCsGUWXe3qY9EDj601OAb6N2B5UZt/PFAySrQ4LdPTcPMZhktu1/N09O+gOJSY oqozgGS9mVGOT/tuvbVRH+lec4Fgagb7TKt2yg0fQF2zuiu3hmYTWc6t2oBUjIkekTJJPX4/lH3vD eZYBG9IbtLYU8LdvKH71/O3zSAeRDjGEZOKfexDF2XtQ8U4UErCU5XPSpEKSHEfyzDqIQ/DgQPAEZ nkfmpJdw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsx-0000DV-W4; Wed, 19 Nov 2025 23:42:48 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsl-00Fos6-8x; Wed, 19 Nov 2025 23:42:35 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , KP Singh , Masami Hiramatsu , Matt Bobrowski , Song Liu , Steven Rostedt , David Laight Subject: [PATCH 35/44] bpf: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:31 +0000 Message-Id: <20251119224140.8616-36-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- kernel/trace/bpf_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 4f87c16d915a..ee3152df767c 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -1515,7 +1515,7 @@ BPF_CALL_4(bpf_read_branch_records, struct bpf_perf_e= vent_data_kern *, ctx, if (!buf || (size % br_entry_size !=3D 0)) return -EINVAL; =20 - to_copy =3D min_t(u32, br_stack->nr * br_entry_size, size); + to_copy =3D min(br_stack->nr * br_entry_size, size); memcpy(buf, br_stack->entries, to_copy); =20 return to_copy; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 E85B13321C2 for ; Wed, 19 Nov 2025 22:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592173; cv=none; b=QQLUGQ2UJ6UGqRiK20030kSPwmJUtrhL8hpiQIh+reEls4G1jcNZfS6xSELHPL821BnrUEn1WKeb0n4SWFwEsnpJ39F7Uvjpzcy/QTcSxorsqsQf5X0b0iMAiRVTjdybsDMzAcS7B12jmIBTADuvjzf3v/rGgY9e+WfKPWVjmvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592173; c=relaxed/simple; bh=FymJZ5+v7P8+4p8PtMyelf8jZqtTo+9TVYZJVGvw6Fg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Li1238Ap0zzG8gyT+J3cp05vFqxEz0YRyvCtX/OTN347eF50RELz0OkPftFgZoEztmg0JndBcLa76obSzydEEF1BqMRLgU59aaM+2bYoEsJYD7NdqMUFZovrh/2tDsAujT8IfFC3cALAA3eWd860NNzHXJYt7126UQJ8Wxv0ack= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=xpi6Vhrh; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="xpi6Vhrh" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsz-006kwz-1T for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=KkEK9Y0pxeOlQTzI407LdutVRUa9UxuhbhibczYgQpE=; b=xpi6VhrhMwu1p6NyvHH8Sx4IJN 3A8cfOPPI1rjsN9/LPgZxz6eHRI3TEzGP9pRRfEgtTpkYRfqrQiSA4vhR2zPanYsOPKZ5tWUzR8nE hcvCfdveW2UIrlClMANItdb3fAc2Jhljf5+V3P8mKZT4je4GvWp51JDODAIpOI6yDSct2N26WyTdU jBma6pnrji9nhVvTz6HuqVx+ODl4mIXogH5cmBdP/eJBp69Gj66/jWLhUzLd7n5XidoeVczHJHTM4 e8NDYvSCspeOuJtPWR4BOXsEjZyEsnNF71z95kyeDJx2Rd0ZZYct7YuHTe/rjsOZU5/Zfx1lTz8FO 1NWnYSMg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsy-0000Db-Mi; Wed, 19 Nov 2025 23:42:48 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsl-00Fos6-K1; Wed, 19 Nov 2025 23:42:35 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Laight Subject: [PATCH 36/44] lib/bucket_locks: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:32 +0000 Message-Id: <20251119224140.8616-37-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- lib/bucket_locks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bucket_locks.c b/lib/bucket_locks.c index 64b92e1dbace..6bad65501f2d 100644 --- a/lib/bucket_locks.c +++ b/lib/bucket_locks.c @@ -25,7 +25,7 @@ int __alloc_bucket_spinlocks(spinlock_t **locks, unsigned= int *locks_mask, =20 if (cpu_mult) { nr_pcpus =3D min_t(unsigned int, nr_pcpus, 64UL); - size =3D min_t(unsigned int, nr_pcpus * cpu_mult, max_size); + size =3D min(nr_pcpus * cpu_mult, max_size); } else { size =3D max_size; } --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 D5065335577; Wed, 19 Nov 2025 22:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592176; cv=none; b=VgEj+fO5FL4MQeL1yZPQuPa9peLDg9T6xD/LoVOxWJFlj0vesYJeCzj+2lqBnXs6E7aDUn5S8YX7aUfhokqdcKLka7kycjJYzjo9kTmH0Wh7PxBLrkOO1wQxgKEIjaNSbAWkoT/3J6x9MNKwVuBs3PL9uG2ysqAM8QCBJvxGvN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592176; c=relaxed/simple; bh=qdE4Kv1xsIq6Zkr4stkOXuGHAdW3NyrDUH5efjxvnWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ns+SkTW/oYyPHyZFmwhhK4AjzAuAzxJsjSNcZt2pwBHuM/XhaivqyaIpfmdplSD+51Xa5Gy96hN1mXgDgJPXSRRR+ryS8usseQbefwgZhQ0FpKzQIaANmoIkpQBgcGwgCWYAZJuxSycNfiNTt8yUgmXCzx5Do1T/hZX3Y3Py1SI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=pSqPraMe; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="pSqPraMe" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt1-006ywW-C7; Wed, 19 Nov 2025 23:42:51 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=pvh9Gkxe+eLMwgU/T06ROMFGxeBFanNKRkJDglfuPVs=; b=pSqPraMesu4cfWonbmnqMRYu1M BnbK3PvYVPh1Lyx3evnv4JpQSpgbZmorMtsOZjnYlr6AZ+kVBnZWubmL2XjnCSARwC1Aqr3E+skLH FF270+cNxDonTy4ECoWrJBXY2s+jV33XhDWB6xVPrNLzphpiEQYxHA7SlC3s839UbFJE/jIT8xQiB CdxKSjgsKEI9eFCIsKjqcOvD8/jO/QNjuGT8I3bs+O8wmT+e00d35RD2tsVbbF91IdtjSwFgZsxuO 5jZuE7X2QCY5W0le2kZ6V/kI15wd5R6aFxTSBABMOX3xCS+LvHeNjkluPoH6lFYnHswSqyN2/kqO5 XHHYKqXA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt1-00086S-1i; Wed, 19 Nov 2025 23:42:51 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsm-00Fos6-3u; Wed, 19 Nov 2025 23:42:36 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , Eric Biggers , "Jason A. Donenfeld" , David Laight Subject: [PATCH 37/44] lib/crypto/mpi: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:33 +0000 Message-Id: <20251119224140.8616-38-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- lib/crypto/mpi/mpicoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/crypto/mpi/mpicoder.c b/lib/crypto/mpi/mpicoder.c index 47f6939599b3..bf716a03c704 100644 --- a/lib/crypto/mpi/mpicoder.c +++ b/lib/crypto/mpi/mpicoder.c @@ -398,7 +398,7 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsi= gned int nbytes) =20 while (sg_miter_next(&miter)) { buff =3D miter.addr; - len =3D min_t(unsigned, miter.length, nbytes); + len =3D min(miter.length, nbytes); nbytes -=3D len; =20 for (x =3D 0; x < len; x++) { --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 4DCFF3358D8 for ; Wed, 19 Nov 2025 22:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; cv=none; b=kWhFuwtbXiISRdWvOMlubWBRl2T5cC3xO8PS3kwmwLiwCiW5WjUeRUNjGpHaOin2lFA0xglJMq6Rij8dKL3pArYceT2A05MEKjK2nnEN6yivr5Cw8fAwhivxlSMhgTf0/W1h4uSYjXOSQVVUQge/9T+FOdmKdohX4rWY4HgQjmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; c=relaxed/simple; bh=G7/CT7tkV3C/dWWNww5Y0SXeIUmI+zVc73c8Vrd2Ubk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pY/GvPdgjynp79bMybfPwCp+4pZDtO6ILfndg03sbnMGIznRVmz/HqoboanNXrJVXwG/uMVviGMDtizPCRk4P+jNnlB3KSStTzmmy9uceOhDNYa2OaO5bkp8q/5funLpDiUS+fMdUtlglpNZU4g9A/iMIj0Tqh0aMPPpuTdpCi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=UUw9VVkv; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="UUw9VVkv" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt1-006kxk-Mh; Wed, 19 Nov 2025 23:42:51 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=Z/NFLW53+pK0aIm6OeWkkopG1z/DUW+LdmtKXo+mrj0=; b=UUw9VVkvZP2SPMfkI04CX7NXsC RZYHI5N5x4qsMN/kXwOBxjrqxbzGzyPLOwN7zcOeynCaObNwjbsBMFmBVS74JLDDc8HBY2Mi+E6e1 dNXaFSRmIINXEYzgtf0GOz1DZTNB9Z/sOksVzOfjg4ZhXC3c1HGviwCNn2He9wrMvRni/gSo+N57/ bK/JksO3AICmyz9sYfb3clm8nu/mWaBRjh4PDa1hnlTxledtZihUKH2jJmh2e9IfZ2UZ3Fs5wM55o 6vbnVvHzv18FWx94TVUvs+b32v84V8VtSOs8yt/pPYW1eO2y8nwLHwd4GxF633ZgSfaEgrrTn+ZgR 0HQhFHHQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt1-00086Y-ED; Wed, 19 Nov 2025 23:42:51 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsm-00Fos6-Ej; Wed, 19 Nov 2025 23:42:36 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Laight Subject: [PATCH 38/44] lib/dynamic_queue_limits: use max() instead of max_t() Date: Wed, 19 Nov 2025 22:41:34 +0000 Message-Id: <20251119224140.8616-39-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight max_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use max(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to max_t(). Signed-off-by: David Laight --- lib/dynamic_queue_limits.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_queue_limits.c b/lib/dynamic_queue_limits.c index f97a752e900a..8b9730b1d751 100644 --- a/lib/dynamic_queue_limits.c +++ b/lib/dynamic_queue_limits.c @@ -69,7 +69,7 @@ static void dql_check_stall(struct dql *dql, unsigned sho= rt stall_thrs) goto dqs_again; =20 dql->stall_cnt++; - dql->stall_max =3D max_t(unsigned short, dql->stall_max, now - t); + dql->stall_max =3D max(dql->stall_max, now - t); =20 trace_dql_stall_detected(dql->stall_thrs, now - t, dql->last_reap, dql->history_head, --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 D5E393254BB; Wed, 19 Nov 2025 22:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592181; cv=none; b=QMgfjXfxux7IMdLq9SvUO5xJaOze/+H6k858crzqMcEqwBYI8oeXT95XJNwxDVnV15NhxJJ56sUCjz7t6QChxTYKxbTKKwa3FXv6WwdPXN6N6Vq080Qf0vze/tTbshP4Z1sS+ojHUql+IPOdp80he1iO+Fk43NX9Ivl/UfyP7Yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592181; c=relaxed/simple; bh=S1JWZWHps5oB2+XqOWFcKuBPtA2Qc3WxgVUUxNnDDsI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HlzPZb7X7S/6RrOud97NNxHtL3hg0scgeHPpu+CRu/wkTaVSnUWI4pmpeAlhVlvjOEca5194lUZ7tr0xOrglklHA9uLjMr2WZfdpD0JW5t8RFn3zfmlYJ9xdfntLvpahwQ55aU5vDWUyE9JT5YC1J81KP+TYu0ef9Oo1Viqeqz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=2MSEAwWs; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="2MSEAwWs" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt5-006yxs-80; Wed, 19 Nov 2025 23:42:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=o+Rdz9XE+xMk74y5kxcFhHgKXAV3hOzijtaYCtjqLa8=; b=2MSEAwWsRWnpmx2KozxLIc3TCp fQz+D+xxRjulKigGVoT2f8G/zFfb8Be2OpUl4PIgJjI2gG4p1DAgJabwb2ZJYDjx9uvyuWwAazeuC TihdwSi9vFZrMsO5atbzEaAVyo++vo4dyC+FxBToKwAafGMwgpD8StbcMCD5qv1sto7K0bPYYROdR 2F3iF2wuR3QoPzWzzQh1YEu7Qhbj1+Ce44VCYVWJYvNycekAymvoTihGlp0lsBlG4c4iGH6GYZ9Bs fLqCcLMvnOd64VC0SWpdJIgzKyUa7C32ql6Chy6o06dF+6r0HL3jzWp9bqt/T92uQXcSwilM5CYbJ oX5wb5dw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt4-0000EV-IL; Wed, 19 Nov 2025 23:42:54 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsn-00Fos6-8l; Wed, 19 Nov 2025 23:42:37 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Axel Rasmussen , Christoph Lameter , David Hildenbrand , Dennis Zhou , Johannes Weiner , "Matthew Wilcox (Oracle)" , Mike Rapoport , Tejun Heo , Yuanchu Xie , David Laight Subject: [PATCH 39/44] mm: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:35 +0000 Message-Id: <20251119224140.8616-40-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' values are small enough that the result is ok. (Similarly for clamp_t().) Detected by an extra check added to min_t(). Signed-off-by: David Laight Reviewed-by: Lorenzo Stoakes --- mm/gup.c | 4 ++-- mm/memblock.c | 2 +- mm/memory.c | 2 +- mm/percpu.c | 2 +- mm/truncate.c | 3 +-- mm/vmscan.c | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a8ba5112e4d0..55435b90dcc3 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -237,8 +237,8 @@ static inline struct folio *gup_folio_range_next(struct= page *start, unsigned int nr =3D 1; =20 if (folio_test_large(folio)) - nr =3D min_t(unsigned int, npages - i, - folio_nr_pages(folio) - folio_page_idx(folio, next)); + nr =3D min(npages - i, + folio_nr_pages(folio) - folio_page_idx(folio, next)); =20 *ntails =3D nr; return folio; diff --git a/mm/memblock.c b/mm/memblock.c index e23e16618e9b..19b491d39002 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2208,7 +2208,7 @@ static void __init __free_pages_memory(unsigned long = start, unsigned long end) * the case. */ if (start) - order =3D min_t(int, MAX_PAGE_ORDER, __ffs(start)); + order =3D min(MAX_PAGE_ORDER, __ffs(start)); else order =3D MAX_PAGE_ORDER; =20 diff --git a/mm/memory.c b/mm/memory.c index 74b45e258323..72f7bd71d65f 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2375,7 +2375,7 @@ static int insert_pages(struct vm_area_struct *vma, u= nsigned long addr, =20 while (pages_to_write_in_pmd) { int pte_idx =3D 0; - const int batch_size =3D min_t(int, pages_to_write_in_pmd, 8); + const int batch_size =3D min(pages_to_write_in_pmd, 8); =20 start_pte =3D pte_offset_map_lock(mm, pmd, addr, &pte_lock); if (!start_pte) { diff --git a/mm/percpu.c b/mm/percpu.c index 81462ce5866e..cad59221d298 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1228,7 +1228,7 @@ static int pcpu_alloc_area(struct pcpu_chunk *chunk, = int alloc_bits, /* * Search to find a fit. */ - end =3D min_t(int, start + alloc_bits + PCPU_BITMAP_BLOCK_BITS, + end =3D umin(start + alloc_bits + PCPU_BITMAP_BLOCK_BITS, pcpu_chunk_map_bits(chunk)); bit_off =3D pcpu_find_zero_area(chunk->alloc_map, end, start, alloc_bits, align_mask, &area_off, &area_bits); diff --git a/mm/truncate.c b/mm/truncate.c index 91eb92a5ce4f..7a56372d39a3 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -849,8 +849,7 @@ void pagecache_isize_extended(struct inode *inode, loff= _t from, loff_t to) unsigned int offset, end; =20 offset =3D from - folio_pos(folio); - end =3D min_t(unsigned int, to - folio_pos(folio), - folio_size(folio)); + end =3D umin(to - folio_pos(folio), folio_size(folio)); folio_zero_segment(folio, offset, end); } =20 diff --git a/mm/vmscan.c b/mm/vmscan.c index b2fc8b626d3d..82cd99a5d843 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3489,7 +3489,7 @@ static struct folio *get_pfn_folio(unsigned long pfn,= struct mem_cgroup *memcg, =20 static bool suitable_to_scan(int total, int young) { - int n =3D clamp_t(int, cache_line_size() / sizeof(pte_t), 2, 8); + int n =3D clamp(cache_line_size() / sizeof(pte_t), 2, 8); =20 /* suitable if the average number of young PTEs per cacheline is >=3D1 */ return young * n >=3D total; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 D723033890C; Wed, 19 Nov 2025 22:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592181; cv=none; b=iTUJduYiGrdimy9GHzZ70bPQZA2ZWTzhFKxDZnDXrvyHKqzy752DY15uU+GwlEWlGApF2ajSnrmI6IHxqUgQPIsFSvibO1OrKO5hOBKA1CbD94C/1XdKLTsVnFaxKwlEdhpQ/rq1bBjqmBgTQko2/j8MEPwTAVECW5xNrxdeXNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592181; c=relaxed/simple; bh=m6MBYBFHJ8sJrrv4025LfRQ7bm/ehbJmyyxjIjoiqqM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k3oaYv1Qr/SHw/HiV/abdMszdkCwEShD8uzTmrCMLCluXyul9TazbXnQwtULILsbBGfFLfvmNw7m73KQ1OPhYYKEHbfPV+Ws9RRUIiBX+7GlIE+ZMGqx/nWohMKT3W21FuctSpcFCXfcyKSpaOmNOZtnsMdDxdvMyiQyd5lYx4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=HcyQQ0jV; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="HcyQQ0jV" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt5-006kzB-F7; Wed, 19 Nov 2025 23:42:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=ONae3XWIWHE3stdMVC07AAUzysrfml8K7utuoa9UFWU=; b=HcyQQ0jVv5i235V1eqYpHH0NO0 O3eD6uqkFqShD7Wx7YHmQBi4p5FVy6E51ohmZP1D2zgr0An9epW3LVAcqEj3ibxeQTH+udM9lOP1a AX47R/wRlwYlQANJ5KOwdKLX7NApkBn06KEEFVwWmHjcc5rcG2q7unHXIs6oP2g2VVcLVfqPuTlDW LLTw2de0VSmZH27xN3Ej13VdKMiv65kYSq/K2p2wvrBHql7pN2IYYqJvCTPVToPwh5A4vE+PgOK/3 Wn1UDWDDlyDedq7XF2NezL5TY/N+nSQ/kjnVsScm/P2u/dSvwSaU4OKjB7Z5Dbd1HKNIr+wDrVo0l JkOZaeAg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt5-000871-40; Wed, 19 Nov 2025 23:42:55 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsn-00Fos6-PX; Wed, 19 Nov 2025 23:42:37 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Laight Subject: [PATCH 40/44] net: Don't pass bitfields to max_t() Date: Wed, 19 Nov 2025 22:41:36 +0000 Message-Id: <20251119224140.8616-41-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight It is invalid to use sizeof() or typeof() in bitfields which stops them being passed to max(). This has been fixed by using max_t(). I want to add some checks to max_t() to detect cases where the cast discards non-zero high bits - which uses sizeof(). So add 0 to the bitfield (converting it to int) then use max(). Signed-off-by: David Laight --- include/net/tcp_ecn.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h index f13e5cd2b1ac..14c00404a95f 100644 --- a/include/net/tcp_ecn.h +++ b/include/net/tcp_ecn.h @@ -196,7 +196,7 @@ static inline void tcp_accecn_opt_demand_min(struct soc= k *sk, struct tcp_sock *tp =3D tcp_sk(sk); u8 opt_demand; =20 - opt_demand =3D max_t(u8, opt_demand_min, tp->accecn_opt_demand); + opt_demand =3D max(opt_demand_min, tp->accecn_opt_demand + 0); tp->accecn_opt_demand =3D opt_demand; } =20 @@ -303,8 +303,7 @@ static inline void tcp_ecn_received_counters(struct soc= k *sk, u32 bytes_mask =3D GENMASK_U32(31, 22); =20 tp->received_ecn_bytes[ecnfield - 1] +=3D len; - tp->accecn_minlen =3D max_t(u8, tp->accecn_minlen, - minlen); + tp->accecn_minlen =3D max(tp->accecn_minlen + 0, minlen); =20 /* Send AccECN option at least once per 2^22-byte * increase in any ECN byte counter. --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 B831A322547; Wed, 19 Nov 2025 22:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; cv=none; b=dAIyxEwxcL87Tb78++Pmi/tMN6NsqzQQFUE755EdpszLCb7BjgYjNiwkt7WNyVYTyvP9B6myTkCtKIb+4o0YUhYkGj8GsRwoXzvarawobmkTdkyCO5Lp0/Df5FLlPLB6mdxjBhjNI5b2Hs2Z5JjCQPFh2pvjdvMCEB2zG1T+q6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; c=relaxed/simple; bh=XFrfwVCvPCtb0hiydszl3RIWBMsxeFfaRQl+89Butuk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qxala0pxsZ+ljQUql0P//lxy0e+3u8GA+fxnFMiWiXhDpcuTQcYk2eoETcdO67NxObJyqb1AxhjYipxWLNcpYlo4rh083o03UTABIvCZ449140YFSt5QjZjjbkxn3/QVm8RcSgGIGH3EXkknIGTR+TkPoETslvoNk4Pl4kw3VpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=mH3mu7CU; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="mH3mu7CU" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt4-006kya-5z; Wed, 19 Nov 2025 23:42:54 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=gcWmtAAfsAw9kpNlGTgaWUDkrcywIVK3kKVtDQyu4MQ=; b=mH3mu7CUOLOgvZQQz4iSHYl8md bDHLoV5jQJ8+4QdanQY9jEszDaCJGnYBPdN/4BkP6xA9uFDgkIQlZ7zgNuiie8/ZY6pBzFla7+hXS 9r8objOy4Ex6It0D6XXEOl/Ymqhq8c9jrgoXsT3A2gKVHlNDl/K8WSP+dYsluD8oldGHLBid67cdC 5wh75wheE42DC29E923kuHXpZ2xLnaVZZzR380BbZO6/MLyooYHxkfo0oix0AeASsGKtT2Tm6ErWp Cz7stmPzBciBUC+4KoVhXmQ+C9WaxPETYMv1feWdSi4IHH4NcmDS5XzkRdZQCyyyJ7+x7csJw6sfP L3rM3iwg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt3-0000E8-Mq; Wed, 19 Nov 2025 23:42:53 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqso-00Fos6-ED; Wed, 19 Nov 2025 23:42:38 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jakub Sitnicki , John Fastabend , Paolo Abeni , David Laight Subject: [PATCH 41/44] net/core: Change loop conditions so min() can be used Date: Wed, 19 Nov 2025 22:41:37 +0000 Message-Id: <20251119224140.8616-42-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Loops like: int copied =3D ...; ... while (copied) { use =3D min_t(type, copied, PAGE_SIZE - offset); ... copied -=3D 0; } can be converted to a plain min() if the comparison is changed to: while (copied > 0) { This removes any chance of high bits being discded by min_t(). (In the case above PAGE_SIZE is 64bits so the 'int' cast is safe, but there are plenty of cases where the check shows up bugs.) Signed-off-by: David Laight --- net/core/datagram.c | 6 +++--- net/core/skmsg.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/net/core/datagram.c b/net/core/datagram.c index c285c6465923..555f38b89729 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -664,8 +664,8 @@ int zerocopy_fill_skb_from_iter(struct sk_buff *skb, head =3D compound_head(pages[n]); order =3D compound_order(head); =20 - for (refs =3D 0; copied !=3D 0; start =3D 0) { - int size =3D min_t(int, copied, PAGE_SIZE - start); + for (refs =3D 0; copied > 0; start =3D 0) { + int size =3D min(copied, PAGE_SIZE - start); =20 if (pages[n] - head > (1UL << order) - 1) { head =3D compound_head(pages[n]); @@ -783,7 +783,7 @@ EXPORT_SYMBOL(__zerocopy_sg_from_iter); */ int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *from) { - int copy =3D min_t(int, skb_headlen(skb), iov_iter_count(from)); + int copy =3D min(skb_headlen(skb), iov_iter_count(from)); =20 /* copy up to skb headlen */ if (skb_copy_datagram_from_iter(skb, 0, from, copy)) diff --git a/net/core/skmsg.c b/net/core/skmsg.c index 2ac7731e1e0a..b58e319f4e2e 100644 --- a/net/core/skmsg.c +++ b/net/core/skmsg.c @@ -335,8 +335,8 @@ int sk_msg_zerocopy_from_iter(struct sock *sk, struct i= ov_iter *from, bytes -=3D copied; msg->sg.size +=3D copied; =20 - while (copied) { - use =3D min_t(int, copied, PAGE_SIZE - offset); + while (copied > 0) { + use =3D min(copied, PAGE_SIZE - offset); sg_set_page(&msg->sg.data[msg->sg.end], pages[i], use, offset); sg_unmark_end(&msg->sg.data[msg->sg.end]); --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 60FEF322547 for ; Wed, 19 Nov 2025 22:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; cv=none; b=qZfVMtDWtyUTm3KWfepNV1u064qP5iDF3ukZMEnj7w8dfoEKPONYpK50w+4+NABTmprxcearpvxcAjpxIdjLaTaX4iYE3PTSI9lL0W0nkdglhGhyouizZGppTc4/q1PMBa1QGmVT/prQfxAiUnPApJ+QCnx7+elo2ow2SgO/iiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; c=relaxed/simple; bh=GGIYofSpJetz0G/DijcVeZfshF99ebnoJhj3c2n6FnA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=msl8610WMaUOizYJNVKnQ1h+w1xioJOHBSlqsjTAcIyA1+2kjLAYR6cqD7ABvbqmWFaUANlMSyv25Zm6YPdpB20u94PE+cw4Eo27+OiFQ98X0yOU+Bki5Y3+f1pK07Jkuka1mEBymyqRp+QzxNfRKVDTBzxUBWFyrKBjxqxNm1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=ECG1ya7r; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="ECG1ya7r" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsr-006ktc-C2; Wed, 19 Nov 2025 23:42:41 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=KQSx02HfqdXV3FVS/PIgGpzRzBe8PakhMgRiOJybjb4=; b=ECG1ya7rAkE2AU1b7MJ4tGMs0d NzA58Xj6Jm3TdE6A4Sy2Oz6zxBe1gEz7bEmIA1WSi/lP1+aVI0cQm392zRWGk17k1cWQqP03s+v6H RBIecCOZYZMgNuNoXXx8d/6txCveyFoNuUIAB+QVaytdgZLVV9RW1MK6AXcv7FQPGyEZBvocLbG// pzh+19ln/rv7FgqLLH9V2vSt1tMEMPnWT59LGf99Yw9E2+JYU+c+l+OIVwEY5BegdODJWTvlSnqU6 qT0EI91c3XpbK5PwUiB4D5QELSK3AdWcrD5RPqf8w/hREC7lec0BSDs0yGKhTsueIe2jRHN+Ig1Yb zB0IuVFw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsq-0000Az-LE; Wed, 19 Nov 2025 23:42:40 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsp-00Fos6-45; Wed, 19 Nov 2025 23:42:39 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: David Ahern , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Kuniyuki Iwashima , Neal Cardwell , Paolo Abeni , Willem de Bruijn , David Laight Subject: [PATCH 42/44] net: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:38 +0000 Message-Id: <20251119224140.8616-43-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- net/core/net-sysfs.c | 3 +-- net/ipv4/fib_trie.c | 2 +- net/ipv4/tcp_input.c | 4 ++-- net/ipv4/tcp_output.c | 5 ++--- net/ipv4/tcp_timer.c | 4 ++-- net/ipv6/addrconf.c | 8 ++++---- net/ipv6/ndisc.c | 5 ++--- net/packet/af_packet.c | 2 +- net/unix/af_unix.c | 4 ++-- 9 files changed, 17 insertions(+), 20 deletions(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index ca878525ad7c..8aaeed38be0b 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -985,8 +985,7 @@ static int netdev_rx_queue_set_rps_mask(struct netdev_r= x_queue *queue, struct rps_map *old_map, *map; int cpu, i; =20 - map =3D kzalloc(max_t(unsigned int, - RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES), + map =3D kzalloc(max(RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES), GFP_KERNEL); if (!map) return -ENOMEM; diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 59a6f0a9638f..e85441717222 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -710,7 +710,7 @@ static unsigned char update_suffix(struct key_vector *t= n) * tn->pos + tn->bits, the second highest node will have a suffix * length at most of tn->pos + tn->bits - 1 */ - slen_max =3D min_t(unsigned char, tn->pos + tn->bits - 1, tn->slen); + slen_max =3D min(tn->pos + tn->bits - 1, tn->slen); =20 /* search though the list of children looking for nodes that might * have a suffix greater than the one we currently have. This is diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index e4a979b75cc6..8c9eb91190ae 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2870,7 +2870,7 @@ static void tcp_mtup_probe_success(struct sock *sk) val =3D (u64)tcp_snd_cwnd(tp) * tcp_mss_to_mtu(sk, tp->mss_cache); do_div(val, icsk->icsk_mtup.probe_size); DEBUG_NET_WARN_ON_ONCE((u32)val !=3D val); - tcp_snd_cwnd_set(tp, max_t(u32, 1U, val)); + tcp_snd_cwnd_set(tp, max(1, val)); =20 tp->snd_cwnd_cnt =3D 0; tp->snd_cwnd_stamp =3D tcp_jiffies32; @@ -3323,7 +3323,7 @@ void tcp_rearm_rto(struct sock *sk) /* delta_us may not be positive if the socket is locked * when the retrans timer fires and is rescheduled. */ - rto =3D usecs_to_jiffies(max_t(int, delta_us, 1)); + rto =3D usecs_to_jiffies(max(delta_us, 1)); } tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto, true); } diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index b94efb3050d2..516ea138993d 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3076,7 +3076,7 @@ bool tcp_schedule_loss_probe(struct sock *sk, bool ad= vancing_rto) jiffies_to_usecs(inet_csk(sk)->icsk_rto) : tcp_rto_delta_us(sk); /* How far in future is RTO? */ if (rto_delta_us > 0) - timeout =3D min_t(u32, timeout, usecs_to_jiffies(rto_delta_us)); + timeout =3D min(timeout, usecs_to_jiffies(rto_delta_us)); =20 tcp_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout, true); return true; @@ -4382,8 +4382,7 @@ void tcp_send_delayed_ack(struct sock *sk) * directly. */ if (tp->srtt_us) { - int rtt =3D max_t(int, usecs_to_jiffies(tp->srtt_us >> 3), - TCP_DELACK_MIN); + int rtt =3D max(usecs_to_jiffies(tp->srtt_us >> 3), TCP_DELACK_MIN); =20 if (rtt < max_ato) max_ato =3D rtt; diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 2dd73a4e8e51..9d5fc405e76a 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -43,7 +43,7 @@ static u32 tcp_clamp_rto_to_user_timeout(const struct soc= k *sk) if (remaining <=3D 0) return 1; /* user timeout has passed; fire ASAP */ =20 - return min_t(u32, icsk->icsk_rto, msecs_to_jiffies(remaining)); + return min(icsk->icsk_rto, msecs_to_jiffies(remaining)); } =20 u32 tcp_clamp_probe0_to_user_timeout(const struct sock *sk, u32 when) @@ -504,7 +504,7 @@ static bool tcp_rtx_probe0_timed_out(const struct sock = *sk, */ if (rtx_delta > user_timeout) return true; - timeout =3D min_t(u32, timeout, msecs_to_jiffies(user_timeout)); + timeout =3D umin(timeout, msecs_to_jiffies(user_timeout)); } /* Note: timer interrupt might have been delayed by at least one jiffy, * and tp->rcv_tstamp might very well have been written recently. diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 40e9c336f6c5..930e34af4331 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1422,11 +1422,11 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr= *ifp, bool block) if_public_preferred_lft =3D ifp->prefered_lft; =20 memset(&cfg, 0, sizeof(cfg)); - cfg.valid_lft =3D min_t(__u32, ifp->valid_lft, - READ_ONCE(idev->cnf.temp_valid_lft) + age); + cfg.valid_lft =3D min(ifp->valid_lft, + READ_ONCE(idev->cnf.temp_valid_lft) + age); cfg.preferred_lft =3D cnf_temp_preferred_lft + age - idev->desync_factor; - cfg.preferred_lft =3D min_t(__u32, if_public_preferred_lft, cfg.preferred= _lft); - cfg.preferred_lft =3D min_t(__u32, cfg.valid_lft, cfg.preferred_lft); + cfg.preferred_lft =3D min(if_public_preferred_lft, cfg.preferred_lft); + cfg.preferred_lft =3D min(cfg.valid_lft, cfg.preferred_lft); =20 cfg.plen =3D ifp->prefix_len; tmp_tstamp =3D ifp->tstamp; diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index f427e41e9c49..b3bcbf0d864b 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1731,9 +1731,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const s= truct in6_addr *target) neigh_release(neigh); } =20 - rd_len =3D min_t(unsigned int, - IPV6_MIN_MTU - sizeof(struct ipv6hdr) - sizeof(*msg) - optlen, - skb->len + 8); + rd_len =3D min(IPV6_MIN_MTU - sizeof(struct ipv6hdr) - sizeof(*msg) - opt= len, + skb->len + 8); rd_len &=3D ~0x7; optlen +=3D rd_len; =20 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 173e6edda08f..af0c74f7b4d4 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -3015,7 +3015,7 @@ static int packet_snd(struct socket *sock, struct msg= hdr *msg, size_t len) hlen =3D LL_RESERVED_SPACE(dev); tlen =3D dev->needed_tailroom; linear =3D __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len); - linear =3D max(linear, min_t(int, len, dev->hard_header_len)); + linear =3D max(linear, min(len, dev->hard_header_len)); skb =3D packet_alloc_skb(sk, hlen + tlen, hlen, len, linear, msg->msg_flags & MSG_DONTWAIT, &err); if (skb =3D=3D NULL) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 768098dec231..e573fcb21a01 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2448,7 +2448,7 @@ static int unix_stream_sendmsg(struct socket *sock, s= truct msghdr *msg, /* allow fallback to order-0 allocations */ size =3D min_t(int, size, SKB_MAX_HEAD(0) + UNIX_SKB_FRAGS_SZ); =20 - data_len =3D max_t(int, 0, size - SKB_MAX_HEAD(0)); + data_len =3D max(0, size - (int)SKB_MAX_HEAD(0)); =20 data_len =3D min_t(size_t, size, PAGE_ALIGN(data_len)); =20 @@ -3054,7 +3054,7 @@ static int unix_stream_read_generic(struct unix_strea= m_read_state *state, sunaddr =3D NULL; } =20 - chunk =3D min_t(unsigned int, unix_skb_len(skb) - skip, size); + chunk =3D min(unix_skb_len(skb) - skip, size); chunk =3D state->recv_actor(skb, skip, chunk, state); if (chunk < 0) { if (copied =3D=3D 0) --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 79B7432AADF for ; Wed, 19 Nov 2025 22:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592165; cv=none; b=DtiIbU30QZdjKARJAL0RI1kqed2Exe98eNI1d8QHZOILU6MpKowtUSNmulFQMe3sY5G53S/z6ejMVEYpDK7znwCHuWH+i19sMK+bX5Oa9W3S2kn1KnYXS+1TZnlf4meglIYe7vw8V/OCBuqRRQgxQZhOFACiMXf/u/Bvxjgh1Gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592165; c=relaxed/simple; bh=izK0+0Bvo7U03sOK72Sga8hjWpAnntIi6bkLeGzufBg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EMzoMZA2pwiRcglVSyiS8mDABqclLP9jtZJj7JTtl2JG/Q+pKh6pwIF3jr2XWpVBOXR1BQdU5GM2iAKyAO9kibq7JcRV985tAgeLtUQTkN+VsiAg4nKf9Y2hQ0uWycYJiJQ0Cja+ECAxEUP2GpYNU2KewxdT4Fx5i/NCKC+x4Q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=DFFComOf; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="DFFComOf" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsq-006ypf-Hi; Wed, 19 Nov 2025 23:42:40 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=DGOZgi3gU5xJrVyv22nL1ESaeH+Ut8t81Bc/Drezg5c=; b=DFFComOf/D7HwUPctBHpq9x4UT B7pDg/Yl8ToerSVWw3PB7Lizsh9QgVg8vaYekEfVIgXX7vt6tfBJPSUCUUHxSB4A1AC3m6v2tq5Jm FpZKxL3p3K4oQ7/ECDc4C/rHnmzcfVaZS7WwAndCxW7pMLkEm/Ohrh+do18rY0H4nvBotwxcpQibU 48+VM8TZOXkKGqeercQmNI04pdlRMyerh58luDxTpkYaO5kgNnih7j7RatNQxziDpZASk19nun8El 7lMK2hSkW8B5BvGvTPhtyZB5oe0aKg9LoMCk0uYkEVL8s2XjI8z9fPKBwQwIsKfDPQ2LMNkvFs85S aQwqJG4A==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsq-00085N-7q; Wed, 19 Nov 2025 23:42:40 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsp-00Fos6-L8; Wed, 19 Nov 2025 23:42:39 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Laight Subject: [PATCH 43/44] net/netlink: Use umin() to avoid min_t(int, ...) discarding high bits Date: Wed, 19 Nov 2025 22:41:39 +0000 Message-Id: <20251119224140.8616-44-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The scan limit in genl_allocate_reserve_groups() is: min_t(int, id + n_groups, mc_groups_longs * BITS_PER_LONG); While 'id' and 'n_groups' are both 'int', 'mc_groups_longs' is 'unsigned long' (BITS_PER_LONG is 'int'). These inconsistent types (all the values are small and non-negative) means that a simple min() fails. When checks for masking high bits are added to min_t() that also fails. Instead use umin() so safely convert all the values to unsigned. Move the limit calculation outside the loop for efficiency and readability. Signed-off-by: David Laight --- net/netlink/genetlink.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 978c129c6095..a802dd8ead2d 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -395,10 +395,11 @@ static unsigned int genl_op_iter_idx(struct genl_op_i= ter *iter) return iter->cmd_idx; } =20 -static int genl_allocate_reserve_groups(int n_groups, int *first_id) +static noinline_for_stack int genl_allocate_reserve_groups(int n_groups, i= nt *first_id) { unsigned long *new_groups; int start =3D 0; + int limit; int i; int id; bool fits; @@ -414,10 +415,8 @@ static int genl_allocate_reserve_groups(int n_groups, = int *first_id) start); =20 fits =3D true; - for (i =3D id; - i < min_t(int, id + n_groups, - mc_groups_longs * BITS_PER_LONG); - i++) { + limit =3D umin(id + n_groups, mc_groups_longs * BITS_PER_LONG); + for (i =3D id; i < limit; i++) { if (test_bit(i, mc_groups)) { start =3D i; fits =3D false; --=20 2.39.5 From nobody Tue Dec 2 02:20:30 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 6E43A3396E1; Wed, 19 Nov 2025 22:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; cv=none; b=KzPnW7PxoNhXCVm7tZCTmwY+KOjIDgsH3tpVim8sjdGlyJNRQkqkTBQxS0OZz0DKvUl7L8ljFmEmiqmXQ8F5/DrEMobNM20oKFu4XjKUaQcwHwhwpg7EArVAoHwpgrZ6xN0e/vUFbAQWhN1jut7PykBAoDpnBw0safjiEWm+mjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592180; c=relaxed/simple; bh=kDTQhJIiq4Kp004XdWpSKDD3BQKOQI9MO/ePej/Dds0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qIHl1RAbHo6SSqQQZj1Ej98M60KXP3fQ2ibjDSjA0SzQ0NJtTH82WWs9ylO0Q94Rcqmvnnm9QGXlLS0Hs3OuIIT7gxt9SjodnRmclFx5sr18NMBRd+6HcgSC1nBRIBUuskmd5Mh2kI2b/09jKEeuS2DDJTysKkiF22n8lykewTM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=KfDfAGR/; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="KfDfAGR/" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt5-006kz2-5Y; Wed, 19 Nov 2025 23:42:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=CvT81+/OMdXIo3A/snFu6tlNvkl886+eK8dSY3ZBXJ0=; b=KfDfAGR/6CG5etf7USf9VWenKL GREPJJdM1fDVS+mr5G1/mFmzwIs8sIek6Ezji9nPizCgYA3zQbCEx85uWeazAhzWjNPEgst3cJtNm gFh0Y9hfgdBAvg6qOp2Wg379crmK7hyC6o3ZmNc4zVAcsXDLYZCRqHWYQyOeFWZ1sPJB0Fij6Ipfi FNhePtiZoRKDcTDA2Y/ITBjrGMceGZWABKg39B49b0tfZFl4GEem31IGkglz4723RRGb6RZQrDRq5 8DjaFtdAk7tQlpgVBCl+qkbcK39pi0yTNsFCqaJr5/iKifpYsVTPt0lLHVzqNijtEtBHBHE1kKSvZ 42tPschg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt4-0000EX-NM; Wed, 19 Nov 2025 23:42:54 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsq-00Fos6-9P; Wed, 19 Nov 2025 23:42:40 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, mptcp@lists.linux.dev, netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Mat Martineau , Matthieu Baerts , Paolo Abeni , David Laight Subject: [PATCH 44/44] net/mptcp: Change some dubious min_t(int, ...) to min() Date: Wed, 19 Nov 2025 22:41:40 +0000 Message-Id: <20251119224140.8616-45-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(). Signed-off-by: David Laight --- net/mptcp/protocol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2d6b8de35c44..d57c3659462f 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1123,8 +1123,8 @@ struct mptcp_sendmsg_info { bool data_lock_held; }; =20 -static int mptcp_check_allowed_size(const struct mptcp_sock *msk, struct s= ock *ssk, - u64 data_seq, int avail_size) +static size_t mptcp_check_allowed_size(const struct mptcp_sock *msk, struc= t sock *ssk, + u64 data_seq, size_t avail_size) { u64 window_end =3D mptcp_wnd_end(msk); u64 mptcp_snd_wnd; @@ -1133,7 +1133,7 @@ static int mptcp_check_allowed_size(const struct mptc= p_sock *msk, struct sock *s return avail_size; =20 mptcp_snd_wnd =3D window_end - data_seq; - avail_size =3D min_t(unsigned int, mptcp_snd_wnd, avail_size); + avail_size =3D min(mptcp_snd_wnd, avail_size); =20 if (unlikely(tcp_sk(ssk)->snd_wnd < mptcp_snd_wnd)) { tcp_sk(ssk)->snd_wnd =3D min_t(u64, U32_MAX, mptcp_snd_wnd); @@ -1477,7 +1477,7 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock= *msk) if (!ssk || !sk_stream_memory_free(ssk)) return NULL; =20 - burst =3D min_t(int, MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd= _nxt); + burst =3D min(MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt); wmem =3D READ_ONCE(ssk->sk_wmem_queued); if (!burst) return ssk; --=20 2.39.5