⬢ DragonFlyBSD Kernel Audit
DF-3489 / fix.diff
← back to finding ↓ download raw
--- a/sys/netgraph7/pppoe/ng_pppoe.c
+++ b/sys/netgraph7/pppoe/ng_pppoe.c
@@ -228,6 +228,7 @@
  * Session information that is needed after connection.
  */
 struct sess_con {
+	u_int64_t	sc_uniqcookie;	/* random HOST_UNIQ value (never a pointer) */
 	hook_p  		hook;
 	uint16_t		Session_ID;
 	enum state		state;
@@ -588,7 +589,8 @@
 		/* Skip any nonsession hook. */
 		if (NG_HOOK_PRIVATE(hook) == NULL)
 			continue;
-		if (uniq.pointer == NG_HOOK_PRIVATE(hook))
+		if (uniq.pointer ==
+		    (void *)((sessp)NG_HOOK_PRIVATE(hook))->sc_uniqcookie)
 			break;
 	}
 	CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer);
@@ -662,6 +664,7 @@
 		 * so just allocate it and hook it in.
 		 */
 		sp = kmalloc(sizeof(*sp), M_NETGRAPH_PPPOE, M_WAITOK | M_NULLOK | M_ZERO);
+		sp->sc_uniqcookie = karc4random64();
 		if (sp == NULL)
 			return (ENOMEM);
 
@@ -1068,7 +1071,7 @@
 	neg->pkt->pkt_header.ph.code = PADI_CODE;
 	uniqtag.hdr.tag_type = PTT_HOST_UNIQ;
 	uniqtag.hdr.tag_len = htons((u_int16_t)sizeof(uniqtag.data));
-	uniqtag.data.pointer = sp;
+	uniqtag.data.pointer = (void *)sp->sc_uniqcookie;
 	init_tags(sp);
 	insert_tag(sp, &uniqtag.hdr);
 	insert_tag(sp, &neg->service.hdr);
@@ -1225,7 +1228,7 @@
 		 */
 		uniqtag.hdr.tag_type = PTT_AC_COOKIE;
 		uniqtag.hdr.tag_len = htons((u_int16_t)sizeof(sp));
-		uniqtag.data.pointer = sp;
+		uniqtag.data.pointer = (void *)sp->sc_uniqcookie;
 		init_tags(sp);
 		insert_tag(sp, &neg->ac_name.hdr); /* AC_NAME */
 		if ((tag = get_tag(ph, PTT_SRV_NAME)))