Skip to content

Commit 150e188

Browse files
committed
pkg/email/lore: demand patches in patch series emails
On LKML, users sometimes reply to a patch series while keeping the original title. At the same time, sometimes new series are sent as a reply to the previous versions. It all confuses the lore archive parsing logic. When reading the archive, remember if the patch were present. If not, mark the series as corrupted and thus prevent is appearance in syz-cluster.
1 parent 67ef0ea commit 150e188

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

pkg/email/lore/parse.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ func PatchSeries(emails []*Email) []*Series {
9393
// The cover email is not of interest.
9494
continue
9595
}
96+
if !email.HasPatch {
97+
// Sometimes users reply to the series keeping the original subject.
98+
// Ignore such messages.
99+
continue
100+
}
96101
if hasSeq[seq] {
97102
// It's weird if that really happens, but let's skip for now.
98103
continue

pkg/email/lore/parse_test.go

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/google/syzkaller/dashboard/dashapi"
1414
"github.com/google/syzkaller/pkg/email"
1515
"github.com/stretchr/testify/assert"
16+
"github.com/stretchr/testify/require"
1617
)
1718

1819
func TestThreadsCollection(t *testing.T) {
@@ -381,6 +382,17 @@ func TestDiscussionType(t *testing.T) {
381382
}
382383
}
383384

385+
const dummyPatch = `diff --git a/kernel/kcov.c b/kernel/kcov.c
386+
index 85e5546cd791..949ea4574412 100644
387+
--- a/kernel/kcov.c
388+
+++ b/kernel/kcov.c
389+
@@ -127,7 +127,6 @@ void kcov_task_exit(struct task_struct *t)
390+
if (kcov == NULL)
391+
return;
392+
- spin_lock(&kcov->lock);
393+
if (WARN_ON(kcov->t != t)) {
394+
`
395+
384396
func TestParseSeries(t *testing.T) {
385397
messages := []string{
386398
// A simple patch series.
@@ -390,8 +402,7 @@ Message-ID: <First>
390402
From: UserA <a@user.com>
391403
Content-Type: text/plain
392404
393-
394-
Some text`,
405+
` + dummyPatch,
395406
// A series with a cover.
396407
`Date: Sun, 7 May 2017 19:55:00 -0700
397408
Subject: [PATCH net v2 00/02] A longer series
@@ -409,8 +420,7 @@ To: UserA <a@user.com>, UserB <b@user.com>
409420
Content-Type: text/plain
410421
In-Reply-To: <Second>
411422
412-
413-
Patch 1/2`,
423+
` + dummyPatch,
414424
`Date: Sun, 7 May 2017 19:56:00 -0700
415425
Subject: [PATCH net v2 02/02] Second patch
416426
Message-ID: <Second-2>
@@ -419,16 +429,24 @@ To: UserA <a@user.com>, UserB <b@user.com>
419429
Content-Type: text/plain
420430
In-Reply-To: <Second>
421431
422-
423-
Patch 2/2`,
424-
// Missing patches.
432+
` + dummyPatch,
433+
// Some missing patches.
425434
`Date: Sun, 7 May 2017 19:57:00 -0700
426435
Subject: [PATCH 01/03] Series
427436
Message-ID: <Third>
428437
From: Someone <a@b.com>
429438
Content-Type: text/plain
430439
431-
Bug report`,
440+
` + dummyPatch,
441+
// Reply with a patch subject.
442+
`Date: Sun, 7 May 2017 19:57:00 -0700
443+
Subject: [PATCH] Series
444+
Message-ID: <Fourth>
445+
From: Someone <a@b.com>
446+
Content-Type: text/plain
447+
In-Reply-To: <Something>
448+
449+
No patch, just text`,
432450
}
433451

434452
var emails []*Email
@@ -441,7 +459,7 @@ Bug report`,
441459
}
442460

443461
series := PatchSeries(emails)
444-
assert.Len(t, series, 3)
462+
assert.Len(t, series, 4)
445463

446464
expectPerID := map[string]*Series{
447465
"<First>": {
@@ -480,6 +498,12 @@ Bug report`,
480498
},
481499
},
482500
},
501+
"<Fourth>": {
502+
Subject: "Series",
503+
Version: 1,
504+
Corrupted: "the subject mentions 1 patches, 0 are found",
505+
Patches: nil,
506+
},
483507
}
484508
for _, s := range series {
485509
expect := expectPerID[s.MessageID]
@@ -491,7 +515,7 @@ Bug report`,
491515
assert.Equal(t, expect.Corrupted, s.Corrupted, "corrupted differs")
492516
assert.Equal(t, expect.Subject, s.Subject, "subject differs")
493517
assert.Equal(t, expect.Version, s.Version, "version differs")
494-
assert.Len(t, s.Patches, len(expect.Patches), "patch count differs")
518+
require.Len(t, s.Patches, len(expect.Patches), "patch count differs")
495519
for i, expectPatch := range expect.Patches {
496520
got := s.Patches[i]
497521
assert.Equal(t, expectPatch.Seq, got.Seq, "seq differs")

pkg/email/lore/read.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func emailFromRaw(body []byte, emails, domains []string) (*Email, error) {
5454
if err != nil {
5555
return nil, err
5656
}
57-
ret := &Email{Email: msg}
57+
ret := &Email{Email: msg, HasPatch: msg.Patch != ""}
5858
// Keep memory consumption low.
5959
ret.Body = ""
6060
ret.Patch = ""

0 commit comments

Comments
 (0)