|
| 1 | +# Dirty Frag class — in-place skcipher decrypt on skb without cow gate. |
| 2 | +# |
| 3 | +# Pattern: skcipher_request_set_crypt(req, sg, sg, ...) followed by |
| 4 | +# crypto_skcipher_decrypt(req) within the same function body, with no |
| 5 | +# dominating cow / unshare / make-writable / pskb_expand_head call. |
| 6 | +# |
| 7 | +# Calibration sites (pre-patch): net/rxrpc/rxkad.c::rxkad_verify_packet_1. |
| 8 | +# Patched by upstream change to add data_len/nonlinear gate (see oss-security |
| 9 | +# advisory 2026-05-07). |
| 10 | +# |
| 11 | +# This is a SYNTACTIC / structural rule — it does not prove the cow gate is |
| 12 | +# unreachable. Path-sensitive analysis (Coccinelle / CodeQL) is required for |
| 13 | +# definitive flagging; see PR body for the deferred-work pointer. |
| 14 | +rules: |
| 15 | + - id: kernel/dirty-frag/skb-inplace-skcipher-no-cow |
| 16 | + # Positive: skcipher_request_set_crypt(req, ?, ?, ...) followed (within |
| 17 | + # the same C function body, bounded by `}`) by crypto_skcipher_decrypt(req). |
| 18 | + # Rust regex has no backreferences, so we cannot require arg2 == arg3 |
| 19 | + # syntactically. Manual triage / Coccinelle confirms the in-place property. |
| 20 | + pattern-regex: '(?ms)^\s*skcipher_request_set_crypt\s*\([^}]*?crypto_skcipher_decrypt\s*\(' |
| 21 | + # Negative: same idiom, but a cow / unshare / make-writable / expand-head |
| 22 | + # call appears BEFORE it within the same function body. Used to suppress |
| 23 | + # the post-patch / safe-fixture variant. |
| 24 | + pattern-not-regex: '(?s)\b(?:skb_cow_data|skb_copy|skb_unshare|skb_make_writable|pskb_expand_head)\s*\([^}]*?skcipher_request_set_crypt\s*\([^}]*?crypto_skcipher_decrypt\s*\(' |
| 25 | + message: | |
| 26 | + In-place skcipher decrypt on skb without a dominating cow/unshare gate |
| 27 | + (Dirty Frag class). Verify skb_cow_data / skb_unshare / skb_make_writable / |
| 28 | + pskb_expand_head is reached on the unsafe path before |
| 29 | + skcipher_request_set_crypt(req, sg, sg, ...) + crypto_skcipher_decrypt(req). |
| 30 | + See oss-security 2026-05-07 advisory and pwnkit issue #263. |
| 31 | + severity: ERROR |
| 32 | + languages: [c] |
| 33 | + metadata: |
| 34 | + cwe: "CWE-787" |
0 commit comments