mirror of
https://github.com/opnsense/src.git
synced 2026-06-14 19:20:18 -04:00
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 99efa2c88d)
This commit is contained in:
parent
3e53fec002
commit
aa545f18d3
1 changed files with 13 additions and 2 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Reference in a new issue