aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2022-01-13 11:16:43 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2022-01-13 17:03:25 +0100
commit65ab1192dcd0323e1b51e8e2f074fb5d6fcb2a1f (patch)
tree4b73d9308804c3d1f51a5eaf455e04e793bfebca
parent54ec1f8e0ee1d049dcc573169c33812ad860f20f (diff)
tools/syz-check: ignore structs with out_overlay attribute
-rw-r--r--sys/linux/fs_ioctl_autofs.txt.warn1
-rw-r--r--tools/syz-check/check.go14
2 files changed, 14 insertions, 1 deletions
diff --git a/sys/linux/fs_ioctl_autofs.txt.warn b/sys/linux/fs_ioctl_autofs.txt.warn
index 61197f595..d762a1302 100644
--- a/sys/linux/fs_ioctl_autofs.txt.warn
+++ b/sys/linux/fs_ioctl_autofs.txt.warn
@@ -8,6 +8,5 @@ no-such-struct: autofs_args_timeout
no-such-struct: autofs_args_requester
no-such-struct: autofs_args_expire
no-such-struct: autofs_args_askumount
-no-such-struct: autofs_args_ismountpoint
no-such-struct: autofs_dev_ioctl_base
bad-field-size: autofs_dev_ioctl.base/ver_major: syz=24 kernel=4
diff --git a/tools/syz-check/check.go b/tools/syz-check/check.go
index 12b5b431e..c97df4252 100644
--- a/tools/syz-check/check.go
+++ b/tools/syz-check/check.go
@@ -251,6 +251,14 @@ func checkStruct(typ prog.Type, astStruct *ast.Struct, str *dwarf.StructType) ([
if _, ok := typ.(*prog.UnionType); ok || str.Kind == "union" {
return warnings, nil
}
+ // Ignore structs with out_overlay attribute.
+ // They are never described in the kernel as a simple struct.
+ // We could only match and check fields based on some common conventions,
+ // but since we have very few of them it's unclear what are these conventions
+ // and implementing something complex will have low RoI.
+ if typ.(*prog.StructType).OverlayField != 0 {
+ return warnings, nil
+ }
// TODO: we could also check enums (elements match corresponding flags in syzkaller).
// TODO: we could also check values of literal constants (dwarf should have that, right?).
// TODO: handle nested structs/unions, e.g.:
@@ -638,6 +646,12 @@ func minTypeSize(t prog.Type) int {
}
switch typ := t.(type) {
case *prog.StructType:
+ if typ.OverlayField != 0 {
+ // Overlayed structs are not supported here
+ // (and should not be used in netlink).
+ // Make this always produce a warning.
+ return -1
+ }
// Some struct args has trailing arrays, but are only checked for min size.
// Try to get some estimation for min size of this struct.
size := 0