Skip to content

Commit 789834d

Browse files
committed
pkg/subsystem: fix dangling entries in the rules list
There was a mistake in the Linux subsystem generation rules that led to the exclusion of exfat-related syz_mount_image calls from the resulting subsystem descriptions. Verify the rules before applying them. Fix other problems found by the check.
1 parent b47f9e0 commit 789834d

File tree

3 files changed

+61
-25
lines changed

3 files changed

+61
-25
lines changed

pkg/subsystem/linux/rules.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,51 @@ type customRules struct {
2323
var (
2424
linuxSubsystemRules = &customRules{
2525
subsystemCalls: map[string][]string{
26-
"adfs": {"syz_mount_image$adfs"},
27-
"affs": {"syz_mount_image$affs"},
26+
// TODO: we don't have subsystems for the following mount calls:
27+
// - syz_mount_image$affs
28+
// - syz_mount_image$cramfs
29+
// - syz_mount_image$efs
30+
// - syz_mount_image$hpfs
31+
// - syz_mount_image$romfs
32+
// - syz_mount_image$minix
33+
// - syz_mount_image$ufs
34+
// - syz_mount_image$zonefs
35+
// - syz_mount_image$vxfs
36+
// - syz_mount_image$befs
37+
// - syz_mount_image$qnx4
38+
// - syz_mount_image$qnx6
39+
// - syz_mount_image$sysv
40+
// - syz_mount_image$adfs
41+
2842
"bcachefs": {"syz_mount_image$bcachefs"},
29-
"befs": {"syz_mount_image$befs"},
3043
"bfs": {"syz_mount_image$bfs"},
3144
"bluetooth": {"syz_emit_vhci"},
3245
"btrfs": {"syz_mount_image$btrfs"},
33-
"cramfs": {"syz_mount_image$cramfs"},
34-
"efs": {"syz_mount_image$efs"},
3546
"erofs": {"syz_mount_image$erofs"},
3647
"ext4": {"syz_mount_image$ext4"},
3748
"f2fs": {"syz_mount_image$f2fs"},
38-
"fat": {
49+
"exfat": {
3950
"syz_mount_image$msdos",
4051
"syz_mount_image$vfat",
4152
"syz_mount_image$exfat",
4253
},
4354
"fuse": {"syz_fuse_handle_req"},
4455
"gfs2": {"syz_mount_image$gfs2", "syz_mount_image$gfs2meta"},
4556
"hfs": {"syz_mount_image$hfs", "syz_mount_image$hfsplus"},
46-
"hpfs": {"syz_mount_image$hpfs"},
4757
"input": {"syz_usb_connect$hid"},
4858
"io-uring": {"syz_io_uring_setup"},
4959
"isofs": {"syz_mount_image$iso9660"},
5060
"jffs2": {"syz_mount_image$jffs2"},
5161
"jfs": {"syz_mount_image$jfs"},
5262
"kvm": {"syz_kvm_setup_cpu", "syz_kvm_vgic_v3_setup", "syz_kvm_setup_syzos_vm", "syz_kvm_add_vcpu"},
53-
"minix": {"syz_mount_image$minix"},
5463
"nilfs": {"syz_mount_image$nilfs2"},
5564
"ntfs3": {"syz_mount_image$ntfs", "syz_mount_image$ntfs3"},
5665
"ocfs2": {"syz_mount_image$ocfs2"},
57-
"omfs": {"syz_mount_image$omfs"},
58-
"qnx4": {"syz_mount_image$qnx4"},
59-
"qnx6": {"syz_mount_image$qnx6"},
60-
"reiserfs": {"syz_mount_image$reiserfs"},
61-
"romfs": {"syz_mount_image$romfs"},
66+
"karma": {"syz_mount_image$omfs"},
6267
"squashfs": {"syz_mount_image$squashfs"},
63-
"sysv": {"syz_mount_image$sysv"},
64-
"tmpfs": {"syz_mount_image$tmpfs"},
65-
"ubifs": {"syz_mount_image$ubifs"},
68+
"mm": {"syz_mount_image$tmpfs"},
69+
"mtd": {"syz_mount_image$ubifs"},
6670
"udf": {"syz_mount_image$udf"},
67-
"ufs": {"syz_mount_image$ufs"},
6871
"usb": {
6972
"syz_usb_connect",
7073
"syz_usb_connect$hid",
@@ -73,10 +76,8 @@ var (
7376
"syz_usb_connect$cdc_ncm",
7477
"syz_usb_connect$uac1",
7578
},
76-
"vxfs": {"syz_mount_image$vxfs"},
7779
"wireless": {"syz_80211_join_ibss", "syz_80211_inject_frame"},
7880
"xfs": {"syz_mount_image$xfs"},
79-
"zonefs": {"syz_mount_image$zonefs"},
8081
},
8182
notSubsystemEmails: map[string]struct{}{
8283
"linaro-mm-sig@lists.linaro.org": {},

pkg/subsystem/linux/subsystems.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ func (ctx *linuxCtx) applyExtraRules(list []*subsystem.Subsystem) error {
141141
if ctx.extraRules == nil {
142142
return nil
143143
}
144+
if err := noDanglingRules(list, ctx.extraRules.subsystemCalls); err != nil {
145+
return fmt.Errorf("subsystemCalls rules check failed: %w", err)
146+
}
147+
if err := noDanglingRules(list, ctx.extraRules.noReminders); err != nil {
148+
return fmt.Errorf("noReminders rules check failed: %w", err)
149+
}
150+
if err := noDanglingRules(list, ctx.extraRules.noIndirectCc); err != nil {
151+
return fmt.Errorf("noIndirectCc rules check failed: %w", err)
152+
}
144153
perName := map[string]*subsystem.Subsystem{}
145154
for _, entry := range list {
146155
entry.Syscalls = ctx.extraRules.subsystemCalls[entry.Name]
@@ -171,6 +180,28 @@ func (ctx *linuxCtx) applyExtraRules(list []*subsystem.Subsystem) error {
171180
return nil
172181
}
173182

183+
// Check that there are no rules that don't refer to any subsystem from the list.
184+
func noDanglingRules[T any](list []*subsystem.Subsystem, rules map[string]T) error {
185+
usedRule := map[string]struct{}{}
186+
for _, entry := range list {
187+
if _, ok := rules[entry.Name]; !ok {
188+
continue
189+
}
190+
usedRule[entry.Name] = struct{}{}
191+
}
192+
if len(usedRule) == len(rules) {
193+
return nil
194+
}
195+
var dangling []string
196+
for key := range rules {
197+
if _, ok := usedRule[key]; ok {
198+
continue
199+
}
200+
dangling = append(dangling, key)
201+
}
202+
return fmt.Errorf("unused keys: %q", dangling)
203+
}
204+
174205
func mergeRawRecords(records []*maintainersRecord, email string) *subsystem.Subsystem {
175206
var lists []string
176207
subsystem := &subsystem.Subsystem{}

pkg/subsystem/lists/linux.go

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)