Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102087769
D46684.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D46684.diff
View Options
diff --git a/sys/sys/kassert.h b/sys/sys/kassert.h
--- a/sys/sys/kassert.h
+++ b/sys/sys/kassert.h
@@ -144,9 +144,12 @@
if (__predict_false(!(exp))) \
kassert_panic msg; \
} while (0)
+#define KASSERTE(exp, msg) \
+ ((__predict_false(!(exp))) ? (kassert_panic msg) : (void)0)
#else /* !(KERNEL && INVARIANTS) && !_STANDALONE */
#define KASSERT(exp,msg) do { \
} while (0)
+#define KASSERTE(exp, msg) ((void)0)
#endif /* (_KERNEL && INVARIANTS) || _STANDALONE */
#ifdef _KERNEL
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -105,8 +105,22 @@
* mtod(m, t) -- Convert mbuf pointer to data pointer of correct type.
* mtodo(m, o) -- Same as above but with offset 'o' into data.
*/
-#define mtod(m, t) ((t)((m)->m_data))
-#define mtodo(m, o) ((void *)(((m)->m_data) + (o)))
+#define mtod(m, t) ( \
+ KASSERTE((m)->m_len >= sizeof(*((t)((m)->m_data))), \
+ ("%s: mtod_(): m_len=%d < %zu of expected data len @ %s:%d",\
+ __func__, (m)->m_len, sizeof(*((t)((m)->m_data))), \
+ __FILE__, __LINE__)) \
+ , \
+ ((t)((m)->m_data)) \
+)
+#define mtodo(m, o) ( \
+ KASSERTE((m)->m_len >= (o) + 1, \
+ ("%s: mtodo_(): m_len=%d < %zu of expected data len @ %s:%d",\
+ __func__, (m)->m_len, (size_t)((o) + 1), \
+ __FILE__, __LINE__)) \
+ , \
+ ((void *)(((m)->m_data) + (o))) \
+)
/*
* Argument structure passed to UMA routines during mbuf and packet
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 11:25 AM (21 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14534105
Default Alt Text
D46684.diff (1 KB)
Attached To
Mode
D46684: mbuf: Add m_len assertion to mtod() and mtodo()
Attached
Detach File
Event Timeline
Log In to Comment