From 79d737c268efc8ba22a35539127bb2b385aae72c Mon Sep 17 00:00:00 2001 From: Tao Su Date: Fri, 10 Oct 2025 11:43:56 +0000 Subject: [PATCH] Support arrays with multiple element types in SCML --- .../system-call-matching-language.md | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/book/src/kernel/linux-compatibility/limitations-on-system-calls/system-call-matching-language.md b/book/src/kernel/linux-compatibility/limitations-on-system-calls/system-call-matching-language.md index d17d71611..804c91da7 100644 --- a/book/src/kernel/linux-compatibility/limitations-on-system-calls/system-call-matching-language.md +++ b/book/src/kernel/linux-compatibility/limitations-on-system-calls/system-call-matching-language.md @@ -278,6 +278,49 @@ struct msghdr = { recvmsg(socket, message = , flags); ``` +SCML supports arrays with nested structures and heterogeneous element types, +as encountered in system calls like `recvmsg` where netlink message payloads +follow the TLV (Type-Length-Value) format. +Arrays can contain multiple elements of varying types: +inline struct patterns (`{ ... }`), nested arrays (`[ ... ]`), +or references to named rules (``). +This flexibility allows SCML to represent hierarchical data structures +as they appear in strace output. + +For example, when receiving a netlink message about adding a network address: + +```c +struct iovec = { + iov_base = [ + [ + { + nlmsg_type = RTM_NEWADDR, + .. + }, + [ + [ { nla_type = IFA_CACHEINFO, .. } ] + ] + ] + ], + .. +}; + +recvmsg( + sockfd, + msg = { + msg_iov = [ ], + .. + }, + flags +); +``` + +This example demonstrates receiving a netlink message of type +`RTM_NEWADDR` containing nested attributes with cache information +(`IFA_CACHEINFO`). The nested array structure illustrates how SCML +handles heterogeneous arrays where elements can be both structs and +nested arrays, reflecting the hierarchical TLV encoding typical of netlink. + ## Formal Syntax Below is the formal syntax of SCML, @@ -302,8 +345,10 @@ Non‑terminals are in angle brackets, terminals in quotes. ::= | '<' '>' - ::= '[' ']' + ::= '[' { ',' } ']' ::= '<' '>' + | + | ::= 'struct' '=' ::= '{' [ ',' '..' ] '}'