diff --git a/native/src/sepolicy/sepolicy.cpp b/native/src/sepolicy/sepolicy.cpp index 59d4aa077..48dd69ac1 100644 --- a/native/src/sepolicy/sepolicy.cpp +++ b/native/src/sepolicy/sepolicy.cpp @@ -272,6 +272,10 @@ void sepol_impl::add_xperm_rule(type_datum_t *src, type_datum_t *tgt, xperms.driver = ioctl_driver(low); } + datum = &get_avtab_node(&key, &xperms)->datum; + if (datum->xperms != nullptr) + memcpy(xperms.perms, datum->xperms->perms, sizeof(xperms.perms)); + if (xperms.specified == AVTAB_XPERMS_IOCTLDRIVER) { for (int i = ioctl_driver(low); i <= ioctl_driver(high); ++i) { if (invert) @@ -288,8 +292,6 @@ void sepol_impl::add_xperm_rule(type_datum_t *src, type_datum_t *tgt, } } - datum = &get_avtab_node(&key, &xperms)->datum; - if (datum->xperms == nullptr) datum->xperms = auto_cast(malloc(sizeof(xperms)));