{'fraction_non_alphanumeric': 0.023399014778325122, 'fraction_numerical': 0.0012315270935960591, 'mean_word_length': 5.274131274131274, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Detecting Kernel Refcount Bugs with Two-Dimensional Consistency Checking

In the Linux kernel, reference counting (refcount) has be-come a default mechanism that manages resource objects. A refcount of a tracked object is incremented when a new reference is assigned and decremented when a reference becomes invalid. Since the kernel manages a large number of shared resources, refcount is prevalent. Due to the inherent complexity of the kernel and resource sharing, developers often fail to properly update refcounts, leading to refcount bugs. Researchers have shown that refcount bugs can cause critical security impacts like privilege escalation; however, the detection of refcount bugs remains an open problem. In this paper, we propose CID , a new mechanism that employs two-dimensional consistency checking to automatically detect refcount bugs. By checking if callers consistently use a refcount function, CID detects deviating cases as potential bugs, and by checking how a caller uses a refcount function, CID infers the condition-aware rules for the function to corre-spondingly operate the refcount, and thus a violating case is a potential bug. More importantly, CID ’s consistency checking does not require complicated semantic understanding, inter-procedural data-ﬂow tracing, or refcount-operation reasoning. CID also features an automated mechanism that systematically identiﬁes refcount ﬁelds and functions in the whole kernel. We implement CID and apply it to the Linux kernel. The tool found 44 new refcount bugs that may cause severe security issues, most of which have been conﬁrmed by the maintainers.