mirror of
https://github.com/reactos/syzkaller.git
synced 2025-02-15 00:57:35 +00:00
pkg/compiler: tolerate unsupported consts everywhere
Currently unsupported consts in structs and resources break build. However, that can well happen for arch-specific devices (e.g. Android). Make this non-fatal as it used to be.
This commit is contained in:
parent
4074aed7c0
commit
0b652d7278
@ -386,17 +386,12 @@ func (comp *compiler) patchConsts(consts map[string]uint64) {
|
||||
continue
|
||||
}
|
||||
// Produce a warning about unsupported syscall/resource/struct.
|
||||
// Unsupported syscalls are discarded.
|
||||
// Unsupported resource/struct lead to compilation error.
|
||||
// Fixing that would require removing all uses of the resource/struct.
|
||||
// TODO(dvyukov): we should transitively remove everything that
|
||||
// depends on unsupported things.
|
||||
pos, typ, name := decl.Info()
|
||||
fn := comp.error
|
||||
if _, ok := decl.(*ast.Call); ok {
|
||||
fn = comp.warning
|
||||
}
|
||||
if id := typ + " " + name; !comp.unsupported[id] {
|
||||
comp.unsupported[id] = true
|
||||
fn(pos, "unsupported %v: %v due to missing const %v",
|
||||
comp.warning(pos, "unsupported %v: %v due to missing const %v",
|
||||
typ, name, missing)
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ var resourceArray = []*ResourceDesc{
|
||||
&ResourceDesc{Name: "sock_udp", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in", "sock_udp"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}},
|
||||
&ResourceDesc{Name: "sock_udp6", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in6", "sock_udp6"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}},
|
||||
&ResourceDesc{Name: "sock_unix", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_unix"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}},
|
||||
&ResourceDesc{Name: "syz_missing_const_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_missing_const_res"}, Values: []uint64{1075883694}},
|
||||
&ResourceDesc{Name: "syz_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_res"}, Values: []uint64{0xffff}},
|
||||
&ResourceDesc{Name: "tcp_seq_num", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"tcp_seq_num"}, Values: []uint64{0x42424242}},
|
||||
&ResourceDesc{Name: "te_session_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"te_session_id"}, Values: []uint64{0}},
|
||||
@ -681,6 +682,7 @@ var structArray = []Type{
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent2_struct_inner_inner", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent_struct", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_length_vma_struct", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_missing_const_struct", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_0", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_1", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_2", IsOptional: false}},
|
||||
@ -19134,6 +19136,15 @@ var structFields = []struct {
|
||||
&VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "f0", ArgDir: DirOut, IsOptional: false}, RangeBegin: 0, RangeEnd: 0},
|
||||
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "f1", ArgDir: DirOut, IsOptional: false}, TypeSize: 8, BigEndian: false, BitfieldLen: 0}, Buf: "f0", ByteSize: 0},
|
||||
}},
|
||||
{structKey{"syz_missing_const_struct", "", DirIn}, []Type{
|
||||
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirIn, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)},
|
||||
}},
|
||||
{structKey{"syz_missing_const_struct", "", DirInOut}, []Type{
|
||||
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)},
|
||||
}},
|
||||
{structKey{"syz_missing_const_struct", "", DirOut}, []Type{
|
||||
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)},
|
||||
}},
|
||||
{structKey{"syz_recur_0", "", DirIn}, []Type{
|
||||
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", ArgDir: DirIn, IsOptional: true}, Type: getStruct(structKey{"syz_recur_0", "", DirIn})},
|
||||
}},
|
||||
|
@ -85,6 +85,7 @@ var resourceArray = []*ResourceDesc{
|
||||
&ResourceDesc{Name: "sock_udp", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in", "sock_udp"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}},
|
||||
&ResourceDesc{Name: "sock_udp6", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in6", "sock_udp6"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}},
|
||||
&ResourceDesc{Name: "sock_unix", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_unix"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}},
|
||||
&ResourceDesc{Name: "syz_missing_const_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_missing_const_res"}, Values: []uint64{1075883694}},
|
||||
&ResourceDesc{Name: "syz_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_res"}, Values: []uint64{0xffff}},
|
||||
&ResourceDesc{Name: "tcp_seq_num", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"tcp_seq_num"}, Values: []uint64{0x42424242}},
|
||||
&ResourceDesc{Name: "te_session_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"te_session_id"}, Values: []uint64{0}},
|
||||
@ -681,6 +682,7 @@ var structArray = []Type{
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent2_struct_inner_inner", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent_struct", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_length_vma_struct", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_missing_const_struct", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_0", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_1", IsOptional: false}},
|
||||
&StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_2", IsOptional: false}},
|
||||
@ -19134,6 +19136,15 @@ var structFields = []struct {
|
||||
&VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "f0", ArgDir: DirOut, IsOptional: false}, RangeBegin: 0, RangeEnd: 0},
|
||||
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "f1", ArgDir: DirOut, IsOptional: false}, TypeSize: 8, BigEndian: false, BitfieldLen: 0}, Buf: "f0", ByteSize: 0},
|
||||
}},
|
||||
{structKey{"syz_missing_const_struct", "", DirIn}, []Type{
|
||||
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirIn, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)},
|
||||
}},
|
||||
{structKey{"syz_missing_const_struct", "", DirInOut}, []Type{
|
||||
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)},
|
||||
}},
|
||||
{structKey{"syz_missing_const_struct", "", DirOut}, []Type{
|
||||
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)},
|
||||
}},
|
||||
{structKey{"syz_recur_0", "", DirIn}, []Type{
|
||||
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", ArgDir: DirIn, IsOptional: true}, Type: getStruct(structKey{"syz_recur_0", "", DirIn})},
|
||||
}},
|
||||
|
@ -518,3 +518,12 @@ resource syz_res[int32]: 0xffff
|
||||
|
||||
syz_test$res0() syz_res
|
||||
syz_test$res1(a0 syz_res)
|
||||
|
||||
# KVM_ARM_VCPU_INIT const is not present on all arches.
|
||||
# Ensure that it does not break build.
|
||||
|
||||
resource syz_missing_const_res[int32]: KVM_ARM_VCPU_INIT
|
||||
|
||||
syz_missing_const_struct {
|
||||
a0 const[KVM_ARM_VCPU_INIT, int32]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user