From nobody Thu Feb 16 11:55:49 2023 X-Original-To: dev-commits-src-branches@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 4PHYLG0t3hz3q5JC; Thu, 16 Feb 2023 11:55:50 +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 4PHYLF6t6Lz48Zj; Thu, 16 Feb 2023 11:55:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548550; 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=f0TdMCR+LoL5LvpUicqO7kU+VwanA9/xwdDvhDxf28g=; b=WzpUY2D1wlldf65mg2kEgBKlLZgD91mth9fsV+XLG5SygAQal2QzElp2rOnDNC2MDUZstc Y0ekLKwR14joq34e6f+KjkkRwaNtZFcBIUd7ne28eekWUhQwzp5stLqBIOAxEOw73jpe0y R1bEOnq5qGcPVW3uh9d6s9xDbzxFdsAstJEJM40AlFIZLKhX9dmtlKCjTA7ciwaaE1B5px rGwKw7Oqr7InFMfHN65tPyY+y+fj5WgJxNxdVDVbvIaX2EsE/4l7uxi2OrPrd9exIloxtR n2dEeCKmlfaEj8vw6NQuoAKFctDFuMeKkmGdvRmPAw7Jyb9RHY+u/ZOy5LlizA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548550; 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=f0TdMCR+LoL5LvpUicqO7kU+VwanA9/xwdDvhDxf28g=; b=d5+4/JLbkO0x2s9b7h8AwQ7l8DmBHXDuPMS0Vo9LVu5BLn/2C34q/ln2i3IpARfaF31Dr0 d0SQ3gX30UF/ebRCoMyIyloTq4G5lVU+qxMCI77Z7FZHkbsuBtvTsNJO9OH8zi0va6+mQ+ w8ZjbG5IxhbY4104SD8CkGZmvm2duyB9GObh24vEEQyyJt4Pq2B4YiaKs2HyiBQlbcjwJT qnkvrA+jbiZ/D+qQPCz3mfnbT5ea0q0c5drUHMbSnwtxP/MQ7WDj6JQFekb69vOjokdpcT XMAfIkeIHCDy3TVD8JCAufLXAp3OZZ+GSuoERoCBIqEw0Ap8tGu7om2KFJkXJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676548550; a=rsa-sha256; cv=none; b=J3qoShXSuJm+evaUm7uht6w1r6a/svEp6MWbnTJ6zIcmcBBIhgd2cSrQ6nrhRBW0+/7ef5 ug3D46f/wOHzrqrLlwdf4KV1GJoY05AD4agLKFgPHVwlgKniv2F4r9IRXxue1HW+spsvat hvyKn6hT6f85ZkP50EYkcFPzK4m74snVpnRUuc1W5/kvJCm6FDr9Iot+o1gqdKCqW1U9jy exMfoUdwF1Ipv6jPWTppmP3ejmSvs/3Ik4lawpmd/bXOw6Cjv0O6wCpjaypxsnpur4h+vA cozsnRZLb7gFPhn4t++eMPJF/9qYNHJKn8VJXViZU0WEfcJoEruPqrRVNgGUOg== 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 4PHYLF5hq6z137b; Thu, 16 Feb 2023 11:55:49 +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 31GBtnSw055154; Thu, 16 Feb 2023 11:55:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GBtnLs055153; Thu, 16 Feb 2023 11:55:49 GMT (envelope-from git) Date: Thu, 16 Feb 2023 11:55:49 GMT Message-Id: <202302161155.31GBtnLs055153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: b2bea8bf56a8 - stable/13 - linuxkpi: Fix `atomic_long_sub()` overflow List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: b2bea8bf56a8f8de612b6fdb0d14fdebe4414af6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=b2bea8bf56a8f8de612b6fdb0d14fdebe4414af6 commit b2bea8bf56a8f8de612b6fdb0d14fdebe4414af6 Author: Jean-Sébastien Pédron AuthorDate: 2023-01-15 14:56:48 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-02-16 11:55:13 +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 (cherry picked from commit 9491ea7c68221ca7bc5e369ebb57660886ef1b13) --- 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) {