Merge parser: send key as integer on the dfa of sysv mqueue

The key of SYSV message queues is an integer and the kernel uses an
integer to store the key. In order to improve performance when
travelling the DFA in the kernel, we should use an integer instead of
the string.

This [patch](5501f45f40) contains a rough implementation of what that would look like on the kernel side

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/968
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
John Johansen 2023-01-24 21:36:39 +00:00
commit 0ac3878207

View file

@ -244,13 +244,19 @@ int mqueue_rule::gen_policy_re(Profile &prof)
if (qtype != mqueue_posix) { if (qtype != mqueue_posix) {
std::ostringstream buffer; std::ostringstream buffer;
buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << AA_CLASS_SYSV_MQUEUE; buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << AA_CLASS_SYSV_MQUEUE;
buf.assign(buffer.str());
if (qname) { if (qname) {
if (!convert_entry(buf, qname)) int key;
goto fail; sscanf(qname, "%d", &key);
u32 tmp = htobe32((u32) key);
u8 *byte = (u8 *) &tmp;
for (int i = 0; i < 4; i++){
buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned int>(byte[i]);
}
} else { } else {
buf += default_match_pattern; buffer << "....";
} }
buf.assign(buffer.str());
vec[0] = buf.c_str(); vec[0] = buf.c_str();
if (label) { if (label) {