From nobody Thu Jan 04 13:48:01 2024 X-Original-To: dev-commits-src-all@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 4T5Sb60lnpz56Qsj; Thu, 4 Jan 2024 13:48:02 +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 4T5Sb56tHZz45qG; Thu, 4 Jan 2024 13:48:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704376082; 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=Jf9d2u7bxM4OGKbm7+wW9F3iANpWqYMXfzR7qUUt+Is=; b=O1iQ8lcmNjtbVGA17XzWI8/S7RYohs5utgS0U79USneQjYkHwerU6SvtY5zS2d2SMeZ379 /BoyT+pFTawIR3Uf3twaywhvrUT2LEDTPNh4LsczP0vC0dkQLs6E5SgPNm3mih71svFQHv 0BYQ9VSZgDQkYL2klthp4BoU9I2/A1sL+iLsu+h8BW1803NI+kOOVFCXi0EoXdxwclS1Td zrlky3+bK+8CFEvZU0mNAl3xFHdYxYu3UnGUqlmA6IWI/8R/0UQn8UjGXaYmxvt88NXOf+ 1J6ICoJFS5QXn/ADmrBr9Wxqgw0mi0Cv2Z35b9GxPXGQ90v4rpwGh7SNeYdzvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704376082; 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=Jf9d2u7bxM4OGKbm7+wW9F3iANpWqYMXfzR7qUUt+Is=; b=Ux7UkbyeLZNMbLAeMiMApsrCV2YdX6qBrL76Ta3+kfTc0XkkZGFzq6inxDxHT7lAXpeeko gwjvRO2pUrTh9Sieb9rPjPeDGZvympqnbeeIByIb/c2/18vEb8sUjy2iOZ+UpBXnIYUp3M NIwWzUOPBGp0fCT+wA1rfsiPojTAXGnBPiGC0sYRiwdeHiZ50nVMgdjgby7hDhouLq2eOf 5cMHHcZ3h3Nb50i3WpleCfKzyHA9nmKJPlcNppp6ToVwQ+Lrgb5buO4IZnWJut3IDi4zQE xEjTeQvI/9OAfXcipAHlancmvq9EbhE9PQWEbkIqo/99Fh6LGiVylA7qPQYK/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704376082; a=rsa-sha256; cv=none; b=tmFOKVdqnA6Cubyvdh6Zytwxtj68xphMqdi5nbNLdjFP4to3zyS4wCOvHF+FccxMQxsIvc aAtnLiVug41Z0Rklo14MfpLJne9faCp/fxM5U7c7Jg5yeNe2ztfOY2zNxpGmqLw8jJap6E 0G3i6J1+C6RCLrsAkVbmNoW2BQ50YamVvkfcIUEEyiEfILOKKHngE2zivfab/rHe0Gi69x itxDSuj1OJv75pVPXDL4+2yI67s2I03uQautqEAVmS8HxEZ2m96i53pY2WPeMyLYK5TJ5h L4RzF3v4ehJwWx7UVRKqWV/HFVOn9OXbGxlTEuvxAXB9n8YLr63CMHKV1KIorA== 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 4T5Sb55zNZzGPX; Thu, 4 Jan 2024 13:48:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 404Dm1rQ049688; Thu, 4 Jan 2024 13:48:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 404Dm1Ot049685; Thu, 4 Jan 2024 13:48:01 GMT (envelope-from git) Date: Thu, 4 Jan 2024 13:48:01 GMT Message-Id: <202401041348.404Dm1Ot049685@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: aa545f18d384 - stable/14 - netmap: Ignore errors in CSB_WRITE() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: aa545f18d384d2e925dcc8de8f7ad7fb73e66dc1 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=aa545f18d384d2e925dcc8de8f7ad7fb73e66dc1 commit aa545f18d384d2e925dcc8de8f7ad7fb73e66dc1 Author: Mark Johnston AuthorDate: 2023-12-27 15:13:29 +0000 Commit: Mark Johnston CommitDate: 2024-01-04 13:42:13 +0000 netmap: Ignore errors in CSB_WRITE() The CSB_WRITE() and _READ() macros respectively write to and read from userspace memory and so can in principle fault. However, we do not check for errors and will proceed blindly if they fail. Add assertions to verify that they do not. This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: vmaffione MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43200 (cherry picked from commit 99efa2c88d93c6272a8f54b18d18d0fd9d60f137) --- sys/dev/netmap/netmap_kern.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h index 24f741084a8d..8618aaf82299 100644 --- a/sys/dev/netmap/netmap_kern.h +++ b/sys/dev/netmap/netmap_kern.h @@ -2450,8 +2450,19 @@ void netmap_uninit_bridges(void); #define CSB_READ(csb, field, r) (get_user(r, &csb->field)) #define CSB_WRITE(csb, field, v) (put_user(v, &csb->field)) #else /* ! linux */ -#define CSB_READ(csb, field, r) (r = fuword32(&csb->field)) -#define CSB_WRITE(csb, field, v) (suword32(&csb->field, v)) +#define CSB_READ(csb, field, r) do { \ + int32_t v __diagused; \ + \ + v = fuword32(&csb->field); \ + KASSERT(v != -1, ("%s: fuword32 failed", __func__)); \ + r = v; \ +} while (0) +#define CSB_WRITE(csb, field, v) do { \ + int error __diagused; \ + \ + error = suword32(&csb->field, v); \ + KASSERT(error == 0, ("%s: suword32 failed", __func__)); \ +} while (0) #endif /* ! linux */ /* some macros that may not be defined */