diff options
author | Hitendra Prajapati <hprajapati@mvista.com> | 2022-08-26 17:40:02 +0530 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-09-03 13:10:37 +0100 |
commit | 1a1eceee49adf1b90b4ecdbabbfdb70373526f9c (patch) | |
tree | fe3f26d99a81c1eabcb356d659a6361a5b8cbb76 /meta/recipes-devtools/go | |
parent | 7d67a61029c49b3459b65da4da2c5022f3826713 (diff) | |
download | poky-1a1eceee49adf1b90b4ecdbabbfdb70373526f9c.tar.gz |
golang: fix CVE-2022-30635 and CVE-2022-32148
Source: https://github.com/golang/go
MR: 120628, 120631
Type: Security Fix
Disposition: Backport from https://github.com/golang/go/commit/ed2f33e1a7e0d18f61bd56f7ee067331d612c27e && https://github.com/golang/go/commit/ed2f33e1a7e0d18f61bd56f7ee067331d612c27e
ChangeID: fbd8d61bdc2e9cb0cdbe9879e02aed218ee93dbe
Description:
Fixed CVE:
1. CVE-2022-30635
2. CVE-2022-32148
(From OE-Core rev: 2c4fb77f417464d9cd40f0ebd8cc52e6e6ca689e)
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/go')
-rw-r--r-- | meta/recipes-devtools/go/go-1.14.inc | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/go/go-1.14/CVE-2022-30635.patch | 120 | ||||
-rw-r--r-- | meta/recipes-devtools/go/go-1.14/CVE-2022-32148.patch | 49 |
3 files changed, 171 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.14.inc b/meta/recipes-devtools/go/go-1.14.inc index 84babc38cb..7c32246012 100644 --- a/meta/recipes-devtools/go/go-1.14.inc +++ b/meta/recipes-devtools/go/go-1.14.inc | |||
@@ -29,6 +29,8 @@ SRC_URI += "\ | |||
29 | file://CVE-2022-30631.patch \ | 29 | file://CVE-2022-30631.patch \ |
30 | file://CVE-2022-30632.patch \ | 30 | file://CVE-2022-30632.patch \ |
31 | file://CVE-2022-30633.patch \ | 31 | file://CVE-2022-30633.patch \ |
32 | file://CVE-2022-30635.patch \ | ||
33 | file://CVE-2022-32148.patch \ | ||
32 | " | 34 | " |
33 | 35 | ||
34 | SRC_URI_append_libc-musl = " file://0009-ld-replace-glibc-dynamic-linker-with-musl.patch" | 36 | SRC_URI_append_libc-musl = " file://0009-ld-replace-glibc-dynamic-linker-with-musl.patch" |
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2022-30635.patch b/meta/recipes-devtools/go/go-1.14/CVE-2022-30635.patch new file mode 100644 index 0000000000..73959f70fa --- /dev/null +++ b/meta/recipes-devtools/go/go-1.14/CVE-2022-30635.patch | |||
@@ -0,0 +1,120 @@ | |||
1 | From fdd4316737ed5681689a1f40802ffa0805e5b11c Mon Sep 17 00:00:00 2001 | ||
2 | From: Hitendra Prajapati <hprajapati@mvista.com> | ||
3 | Date: Fri, 26 Aug 2022 12:17:05 +0530 | ||
4 | Subject: [PATCH] CVE-2022-30635 | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/golang/go/commit/cd54600b866db0ad068ab8df06c7f5f6cb55c9b3] | ||
7 | CVE-2022-30635 | ||
8 | Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> | ||
9 | --- | ||
10 | src/encoding/gob/decode.go | 19 ++++++++++++------- | ||
11 | src/encoding/gob/gobencdec_test.go | 24 ++++++++++++++++++++++++ | ||
12 | 2 files changed, 36 insertions(+), 7 deletions(-) | ||
13 | |||
14 | diff --git a/src/encoding/gob/decode.go b/src/encoding/gob/decode.go | ||
15 | index d2f6c74..0e0ec75 100644 | ||
16 | --- a/src/encoding/gob/decode.go | ||
17 | +++ b/src/encoding/gob/decode.go | ||
18 | @@ -871,8 +871,13 @@ func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string, inProg | ||
19 | return &op | ||
20 | } | ||
21 | |||
22 | +var maxIgnoreNestingDepth = 10000 | ||
23 | + | ||
24 | // decIgnoreOpFor returns the decoding op for a field that has no destination. | ||
25 | -func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) *decOp { | ||
26 | +func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp, depth int) *decOp { | ||
27 | + if depth > maxIgnoreNestingDepth { | ||
28 | + error_(errors.New("invalid nesting depth")) | ||
29 | + } | ||
30 | // If this type is already in progress, it's a recursive type (e.g. map[string]*T). | ||
31 | // Return the pointer to the op we're already building. | ||
32 | if opPtr := inProgress[wireId]; opPtr != nil { | ||
33 | @@ -896,7 +901,7 @@ func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) | ||
34 | errorf("bad data: undefined type %s", wireId.string()) | ||
35 | case wire.ArrayT != nil: | ||
36 | elemId := wire.ArrayT.Elem | ||
37 | - elemOp := dec.decIgnoreOpFor(elemId, inProgress) | ||
38 | + elemOp := dec.decIgnoreOpFor(elemId, inProgress, depth+1) | ||
39 | op = func(i *decInstr, state *decoderState, value reflect.Value) { | ||
40 | state.dec.ignoreArray(state, *elemOp, wire.ArrayT.Len) | ||
41 | } | ||
42 | @@ -904,15 +909,15 @@ func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) | ||
43 | case wire.MapT != nil: | ||
44 | keyId := dec.wireType[wireId].MapT.Key | ||
45 | elemId := dec.wireType[wireId].MapT.Elem | ||
46 | - keyOp := dec.decIgnoreOpFor(keyId, inProgress) | ||
47 | - elemOp := dec.decIgnoreOpFor(elemId, inProgress) | ||
48 | + keyOp := dec.decIgnoreOpFor(keyId, inProgress, depth+1) | ||
49 | + elemOp := dec.decIgnoreOpFor(elemId, inProgress, depth+1) | ||
50 | op = func(i *decInstr, state *decoderState, value reflect.Value) { | ||
51 | state.dec.ignoreMap(state, *keyOp, *elemOp) | ||
52 | } | ||
53 | |||
54 | case wire.SliceT != nil: | ||
55 | elemId := wire.SliceT.Elem | ||
56 | - elemOp := dec.decIgnoreOpFor(elemId, inProgress) | ||
57 | + elemOp := dec.decIgnoreOpFor(elemId, inProgress, depth+1) | ||
58 | op = func(i *decInstr, state *decoderState, value reflect.Value) { | ||
59 | state.dec.ignoreSlice(state, *elemOp) | ||
60 | } | ||
61 | @@ -1073,7 +1078,7 @@ func (dec *Decoder) compileSingle(remoteId typeId, ut *userTypeInfo) (engine *de | ||
62 | func (dec *Decoder) compileIgnoreSingle(remoteId typeId) *decEngine { | ||
63 | engine := new(decEngine) | ||
64 | engine.instr = make([]decInstr, 1) // one item | ||
65 | - op := dec.decIgnoreOpFor(remoteId, make(map[typeId]*decOp)) | ||
66 | + op := dec.decIgnoreOpFor(remoteId, make(map[typeId]*decOp), 0) | ||
67 | ovfl := overflow(dec.typeString(remoteId)) | ||
68 | engine.instr[0] = decInstr{*op, 0, nil, ovfl} | ||
69 | engine.numInstr = 1 | ||
70 | @@ -1118,7 +1123,7 @@ func (dec *Decoder) compileDec(remoteId typeId, ut *userTypeInfo) (engine *decEn | ||
71 | localField, present := srt.FieldByName(wireField.Name) | ||
72 | // TODO(r): anonymous names | ||
73 | if !present || !isExported(wireField.Name) { | ||
74 | - op := dec.decIgnoreOpFor(wireField.Id, make(map[typeId]*decOp)) | ||
75 | + op := dec.decIgnoreOpFor(wireField.Id, make(map[typeId]*decOp), 0) | ||
76 | engine.instr[fieldnum] = decInstr{*op, fieldnum, nil, ovfl} | ||
77 | continue | ||
78 | } | ||
79 | diff --git a/src/encoding/gob/gobencdec_test.go b/src/encoding/gob/gobencdec_test.go | ||
80 | index 6d2c8db..1b52ecc 100644 | ||
81 | --- a/src/encoding/gob/gobencdec_test.go | ||
82 | +++ b/src/encoding/gob/gobencdec_test.go | ||
83 | @@ -12,6 +12,7 @@ import ( | ||
84 | "fmt" | ||
85 | "io" | ||
86 | "net" | ||
87 | + "reflect" | ||
88 | "strings" | ||
89 | "testing" | ||
90 | "time" | ||
91 | @@ -796,3 +797,26 @@ func TestNetIP(t *testing.T) { | ||
92 | t.Errorf("decoded to %v, want 1.2.3.4", ip.String()) | ||
93 | } | ||
94 | } | ||
95 | + | ||
96 | +func TestIngoreDepthLimit(t *testing.T) { | ||
97 | + // We don't test the actual depth limit because it requires building an | ||
98 | + // extremely large message, which takes quite a while. | ||
99 | + oldNestingDepth := maxIgnoreNestingDepth | ||
100 | + maxIgnoreNestingDepth = 100 | ||
101 | + defer func() { maxIgnoreNestingDepth = oldNestingDepth }() | ||
102 | + b := new(bytes.Buffer) | ||
103 | + enc := NewEncoder(b) | ||
104 | + typ := reflect.TypeOf(int(0)) | ||
105 | + nested := reflect.ArrayOf(1, typ) | ||
106 | + for i := 0; i < 100; i++ { | ||
107 | + nested = reflect.ArrayOf(1, nested) | ||
108 | + } | ||
109 | + badStruct := reflect.New(reflect.StructOf([]reflect.StructField{{Name: "F", Type: nested}})) | ||
110 | + enc.Encode(badStruct.Interface()) | ||
111 | + dec := NewDecoder(b) | ||
112 | + var output struct{ Hello int } | ||
113 | + expectedErr := "invalid nesting depth" | ||
114 | + if err := dec.Decode(&output); err == nil || err.Error() != expectedErr { | ||
115 | + t.Errorf("Decode didn't fail with depth limit of 100: want %q, got %q", expectedErr, err) | ||
116 | + } | ||
117 | +} | ||
118 | -- | ||
119 | 2.25.1 | ||
120 | |||
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2022-32148.patch b/meta/recipes-devtools/go/go-1.14/CVE-2022-32148.patch new file mode 100644 index 0000000000..aab98e99fd --- /dev/null +++ b/meta/recipes-devtools/go/go-1.14/CVE-2022-32148.patch | |||
@@ -0,0 +1,49 @@ | |||
1 | From 0fe3adec199e8cd2c101933f75d8cd617de70350 Mon Sep 17 00:00:00 2001 | ||
2 | From: Hitendra Prajapati <hprajapati@mvista.com> | ||
3 | Date: Fri, 26 Aug 2022 12:48:13 +0530 | ||
4 | Subject: [PATCH] CVE-2022-32148 | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/golang/go/commit/ed2f33e1a7e0d18f61bd56f7ee067331d612c27e] | ||
7 | CVE: CVE-2022-32148 | ||
8 | Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> | ||
9 | --- | ||
10 | src/net/http/header.go | 6 ++++++ | ||
11 | src/net/http/header_test.go | 5 +++++ | ||
12 | 2 files changed, 11 insertions(+) | ||
13 | |||
14 | diff --git a/src/net/http/header.go b/src/net/http/header.go | ||
15 | index b9b5391..221f613 100644 | ||
16 | --- a/src/net/http/header.go | ||
17 | +++ b/src/net/http/header.go | ||
18 | @@ -100,6 +100,12 @@ func (h Header) Clone() Header { | ||
19 | sv := make([]string, nv) // shared backing array for headers' values | ||
20 | h2 := make(Header, len(h)) | ||
21 | for k, vv := range h { | ||
22 | + if vv == nil { | ||
23 | + // Preserve nil values. ReverseProxy distinguishes | ||
24 | + // between nil and zero-length header values. | ||
25 | + h2[k] = nil | ||
26 | + continue | ||
27 | + } | ||
28 | n := copy(sv, vv) | ||
29 | h2[k] = sv[:n:n] | ||
30 | sv = sv[n:] | ||
31 | diff --git a/src/net/http/header_test.go b/src/net/http/header_test.go | ||
32 | index 4789362..80c0035 100644 | ||
33 | --- a/src/net/http/header_test.go | ||
34 | +++ b/src/net/http/header_test.go | ||
35 | @@ -235,6 +235,11 @@ func TestCloneOrMakeHeader(t *testing.T) { | ||
36 | in: Header{"foo": {"bar"}}, | ||
37 | want: Header{"foo": {"bar"}}, | ||
38 | }, | ||
39 | + { | ||
40 | + name: "nil value", | ||
41 | + in: Header{"foo": nil}, | ||
42 | + want: Header{"foo": nil}, | ||
43 | + }, | ||
44 | } | ||
45 | |||
46 | for _, tt := range tests { | ||
47 | -- | ||
48 | 2.25.1 | ||
49 | |||