Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106226333
D24383.id70499.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D24383.id70499.diff
View Options
Index: sys/kern/kern_jail.c
===================================================================
--- sys/kern/kern_jail.c
+++ sys/kern/kern_jail.c
@@ -2889,6 +2889,15 @@
mtx_unlock(&cred->cr_prison->pr_mtx);
}
+void
+getjailname(struct ucred *cred, char *name, size_t len)
+{
+
+ mtx_lock(&cred->cr_prison->pr_mtx);
+ strlcpy(name, cred->cr_prison->pr_name, len);
+ mtx_unlock(&cred->cr_prison->pr_mtx);
+}
+
#ifdef VIMAGE
/*
* Determine whether the prison represented by cred owns
Index: sys/net/if_bridge.c
===================================================================
--- sys/net/if_bridge.c
+++ sys/net/if_bridge.c
@@ -690,7 +690,7 @@
{
struct bridge_softc *sc, *sc2;
struct ifnet *bifp, *ifp;
- int fb, retry;
+ int retry;
unsigned long hostid;
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
@@ -722,28 +722,16 @@
ifp->if_type = IFT_BRIDGE;
/*
- * Generate an ethernet address with a locally administered address.
+ * Generate an ethernet address.
*
* Since we are using random ethernet addresses for the bridge, it is
* possible that we might have address collisions, so make sure that
* this hardware address isn't already in use on another bridge.
- * The first try uses the hostid and falls back to arc4rand().
*/
- fb = 0;
getcredhostid(curthread->td_ucred, &hostid);
do {
- if (fb || hostid == 0) {
- ether_gen_addr(ifp, &sc->sc_defaddr);
- } else {
- sc->sc_defaddr.octet[0] = 0x2;
- sc->sc_defaddr.octet[1] = (hostid >> 24) & 0xff;
- sc->sc_defaddr.octet[2] = (hostid >> 16) & 0xff;
- sc->sc_defaddr.octet[3] = (hostid >> 8 ) & 0xff;
- sc->sc_defaddr.octet[4] = hostid & 0xff;
- sc->sc_defaddr.octet[5] = ifp->if_dunit & 0xff;
- }
+ ether_gen_addr(ifp, &sc->sc_defaddr);
- fb = 1;
retry = 0;
BRIDGE_LIST_LOCK();
LIST_FOREACH(sc2, &V_bridge_list, sc_list) {
Index: sys/net/if_ethersubr.c
===================================================================
--- sys/net/if_ethersubr.c
+++ sys/net/if_ethersubr.c
@@ -1427,16 +1427,19 @@
void
ether_gen_addr(struct ifnet *ifp, struct ether_addr *hwaddr)
{
-#define ETHER_GEN_ADDR_BUFSIZ HOSTUUIDLEN + IFNAMSIZ + 2
+#define ETHER_GEN_ADDR_BUFSIZ HOSTUUIDLEN + IFNAMSIZ + MAXHOSTNAMELEN + 3
SHA1_CTX ctx;
char buf[ETHER_GEN_ADDR_BUFSIZ];
char uuid[HOSTUUIDLEN + 1];
uint64_t addr;
int i, sz;
char digest[SHA1_RESULTLEN];
+ char name[MAXHOSTNAMELEN];
getcredhostuuid(curthread->td_ucred, uuid, sizeof(uuid));
- sz = snprintf(buf, ETHER_GEN_ADDR_BUFSIZ, "%s-%s", uuid, ifp->if_xname);
+ getjailname(curthread->td_ucred, name, sizeof(name));
+ sz = snprintf(buf, ETHER_GEN_ADDR_BUFSIZ, "%s-%s-%s", uuid,
+ ifp->if_xname, name);
SHA1Init(&ctx);
SHA1Update(&ctx, buf, sz);
SHA1Final(digest, &ctx);
Index: sys/sys/jail.h
===================================================================
--- sys/sys/jail.h
+++ sys/sys/jail.h
@@ -382,6 +382,7 @@
void getcreddomainname(struct ucred *, char *, size_t);
void getcredhostuuid(struct ucred *, char *, size_t);
void getcredhostid(struct ucred *, unsigned long *);
+void getjailname(struct ucred *cred, char *name, size_t len);
void prison0_init(void);
int prison_allow(struct ucred *, unsigned);
int prison_check(struct ucred *cred1, struct ucred *cred2);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 28, 12:33 PM (6 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15622914
Default Alt Text
D24383.id70499.diff (3 KB)
Attached To
Mode
D24383: ethersubr: Make the mac address generation more robust
Attached
Detach File
Event Timeline
Log In to Comment