From nobody Wed Jan 25 21:39:04 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P2HKP1Gqvz3bW1C; Wed, 25 Jan 2023 21:39:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P2HKP0r0Vz4121; Wed, 25 Jan 2023 21:39:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674682745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AcU9xEw4FRiYyQswD+qEXoHzax3wTQs7clcHeZfbvfE=; b=xTzLTx2ti3jxJFM2/SGgk3dIsSYD5c6EzbFIVWpSTsUEZmqIa4uD9rlv9DmwgGhYa3lf94 pnqlgjT/sZZsn9k3AUg2Dx4L7GGuwpK9puNR1XE7c+t27agQRfHgCJ50J4VuriOouqpDBC rpdbN7kD5EGtUNZUcTwQnqSRxKQhz+Rh28nnJXNoTubuG/ySh5wNhNWjM9uYBikkBwT+sK Zpzvww2oNnSsnV/L0IZ/x5GPzbtBr2bS9r2EBYT/MCVuqfFBZCXkrNdrFQn1rLepuZCgpM 0ngRPs+I1ViMt5+3KwHUSNUNBzfSFI4J56tj2lQirmK+7oxX26c3PM3IQv2v5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674682745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AcU9xEw4FRiYyQswD+qEXoHzax3wTQs7clcHeZfbvfE=; b=ailPH3si4/7yHzKlolPttnEkHWwlfusA3mXMRq5+iOnfwYaWK7k8LaQM1RpBRiPGxOnb9q xwWL6EDC9mK+Lej/ta/LrIoFcJCTwV6dTOtQ/sTYjy5WgBotj2uiBYlLhi4wjDokWaKCPO Q+WJJa0SkuQ3CXiIf8CF8rRTy0J2ApYKvMq2RY8I0xLQic5eJE1gl6GzPqVKl3nm7fPuZB xeahDMleMqZOOFor81oY7cwLkbLKaqCIWpfH/fD1jP+PQks1oprn7kUJx/howHH/vffk6Q oC0yO5gwfa5ot52x0NpOhigjD3Ncxr9AiQg/p2+dKKKrZENq0QixJeZLNeZHGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674682745; a=rsa-sha256; cv=none; b=raBR0MXiYzXhi/U70ib1mETy+ocJ6MZhlVRVNMm7eJHRnfkrOy+JAt5yQpwQ8SZqyOrbn4 Vv78ec+LnJtSMRoRUJDOVx8qCZsdgJ+oSD/rQ2PWBNeCUV01FxhpiEU1A6qPHKRTXzovpI dwrWifqgd0HlJ//xYqF/P89n3p5PfaktDGo8wgD6S9+Qn1EZNW282wzmlxpX2jPO46aAM1 Qs1PzZHZ/UZ+d93z4NapRcu/ck1zlJHcvpHGVZPiHiMTKiipjfIWC9OQYCs5+dHPbfxuj2 G/Jv9C4OzlBdjcP3f3Fi3JV6XzccsEBKu9rOSflQkUdsuHDdTOpHjx2XpNFyMQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P2HKN6vC3z14Wn; Wed, 25 Jan 2023 21:39:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30PLd4Fc007655; Wed, 25 Jan 2023 21:39:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30PLd4e4007654; Wed, 25 Jan 2023 21:39:04 GMT (envelope-from git) Date: Wed, 25 Jan 2023 21:39:04 GMT Message-Id: <202301252139.30PLd4e4007654@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 9491ea7c6822 - main - linuxkpi: Fix `atomic_long_sub()` overflow List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9491ea7c68221ca7bc5e369ebb57660886ef1b13 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=9491ea7c68221ca7bc5e369ebb57660886ef1b13 commit 9491ea7c68221ca7bc5e369ebb57660886ef1b13 Author: Jean-Sébastien Pédron AuthorDate: 2023-01-15 14:56:48 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-01-25 21:26:54 +0000 linuxkpi: Fix `atomic_long_sub()` overflow By (ab)using `atomic_long_add_return()`, `atomic_long_sub()` was making the atomic long overflow. Indeed the underlying FreeBSD atomic is based on an unsigned long. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38090 --- sys/compat/linuxkpi/common/include/asm/atomic-long.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/asm/atomic-long.h b/sys/compat/linuxkpi/common/include/asm/atomic-long.h index f8bd9edfccf9..aeec6edd707d 100644 --- a/sys/compat/linuxkpi/common/include/asm/atomic-long.h +++ b/sys/compat/linuxkpi/common/include/asm/atomic-long.h @@ -41,7 +41,7 @@ typedef struct { } atomic_long_t; #define atomic_long_add(i, v) atomic_long_add_return((i), (v)) -#define atomic_long_sub(i, v) atomic_long_add_return(-(i), (v)) +#define atomic_long_sub(i, v) atomic_long_sub_return((i), (v)) #define atomic_long_inc_return(v) atomic_long_add_return(1, (v)) #define atomic_long_inc_not_zero(v) atomic_long_add_unless((v), 1, 0) @@ -51,6 +51,12 @@ atomic_long_add_return(long i, atomic_long_t *v) return i + atomic_fetchadd_long(&v->counter, i); } +static inline long +atomic_long_sub_return(long i, atomic_long_t *v) +{ + return atomic_fetchadd_long(&v->counter, -i) - i; +} + static inline void atomic_long_set(atomic_long_t *v, long i) {