Skip to content

Commit 6a716c4

Browse files
committed
mbox: do not copy Content-Type into exported mbox
Daniel reports a patch + comment combination that breaks in git am. The patch reports a Content-Type of US-ASCII, while the comment adds a Ack with UTF-8 characters. The exported mbox contains both the original Content-Type, and a UTF-8 Content-Type that we set. However, because the US-ASCII one occurs later, git am honours it instead of ours, and chokes on the UTF-8 characters. Strip out any subsequent Content-Type:s. We normalise things to UTF-8 and should not allow it to be overridden. Add a test for this, based on the original report. Reported-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Daniel Axtens <dja@axtens.net>
1 parent b4592c9 commit 6a716c4

File tree

3 files changed

+185
-2
lines changed

3 files changed

+185
-2
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
From mboxrd@z Thu Jan 1 00:00:00 1970
2+
Return-Path: <SRS0=vqEd=WQ=vger.kernel.org=netdev-owner@kernel.org>
3+
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
4+
aws-us-west-2-korg-lkml-1.web.codeaurora.org
5+
X-Spam-Level:
6+
X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,
7+
INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,
8+
URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no
9+
version=3.4.0
10+
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
11+
by smtp.lore.kernel.org (Postfix) with ESMTP id A702DC3A5A2
12+
for <netdev@archiver.kernel.org>; Tue, 20 Aug 2019 01:33:12 +0000 (UTC)
13+
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
14+
by mail.kernel.org (Postfix) with ESMTP id 8717B22DA7
15+
for <netdev@archiver.kernel.org>; Tue, 20 Aug 2019 01:33:12 +0000 (UTC)
16+
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
17+
id S1728887AbfHTBdL (ORCPT <rfc822;netdev@archiver.kernel.org>);
18+
Mon, 19 Aug 2019 21:33:11 -0400
19+
Received: from szxga05-in.huawei.com ([45.249.212.191]:4731 "EHLO huawei.com"
20+
rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP
21+
id S1728627AbfHTBdL (ORCPT <rfc822;netdev@vger.kernel.org>);
22+
Mon, 19 Aug 2019 21:33:11 -0400
23+
Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59])
24+
by Forcepoint Email with ESMTP id EF227A58CA1FC4ADCFA3;
25+
Tue, 20 Aug 2019 09:33:03 +0800 (CST)
26+
Received: from localhost.localdomain.localdomain (10.175.113.25) by
27+
DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id
28+
14.3.439.0; Tue, 20 Aug 2019 09:32:56 +0800
29+
From: YueHaibing <yuehaibing@huawei.com>
30+
To: <bjorn.topel@intel.com>, <magnus.karlsson@intel.com>,
31+
<jonathan.lemon@gmail.com>, <ast@kernel.org>,
32+
<daniel@iogearbox.net>, <kafai@fb.com>, <songliubraving@fb.com>,
33+
<yhs@fb.com>, <john.fastabend@gmail.com>
34+
CC: YueHaibing <yuehaibing@huawei.com>, <netdev@vger.kernel.org>,
35+
<bpf@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
36+
Subject: [PATCH -next] bpf: Use PTR_ERR_OR_ZERO in xsk_map_inc()
37+
Date: Tue, 20 Aug 2019 01:36:52 +0000
38+
Message-ID: <20190820013652.147041-1-yuehaibing@huawei.com>
39+
X-Mailer: git-send-email 2.20.1
40+
MIME-Version: 1.0
41+
Content-Type: text/plain; charset=US-ASCII
42+
Content-Transfer-Encoding: 7BIT
43+
X-Originating-IP: [10.175.113.25]
44+
X-CFilter-Loop: Reflected
45+
Sender: netdev-owner@vger.kernel.org
46+
Precedence: bulk
47+
List-ID: <netdev.vger.kernel.org>
48+
X-Mailing-List: netdev@vger.kernel.org
49+
Archived-At: <https://lore.kernel.org/netdev/20190820013652.147041-1-yuehaibing@huawei.com/>
50+
List-Archive: <https://lore.kernel.org/netdev/>
51+
List-Post: <mailto:netdev@vger.kernel.org>
52+
53+
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
54+
55+
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
56+
---
57+
kernel/bpf/xskmap.c | 2 +-
58+
1 file changed, 1 insertion(+), 1 deletion(-)
59+
60+
diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
61+
index 4cc28e226398..942c662e2eed 100644
62+
--- a/kernel/bpf/xskmap.c
63+
+++ b/kernel/bpf/xskmap.c
64+
@@ -21,7 +21,7 @@ int xsk_map_inc(struct xsk_map *map)
65+
struct bpf_map *m = &map->map;
66+
67+
m = bpf_map_inc(m, false);
68+
- return IS_ERR(m) ? PTR_ERR(m) : 0;
69+
+ return PTR_ERR_OR_ZERO(m);
70+
}
71+
72+
void xsk_map_put(struct xsk_map *map)
73+
74+
75+
From mboxrd@z Thu Jan 1 00:00:00 1970
76+
Return-Path: <SRS0=vqEd=WQ=vger.kernel.org=netdev-owner@kernel.org>
77+
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
78+
aws-us-west-2-korg-lkml-1.web.codeaurora.org
79+
X-Spam-Level:
80+
X-Spam-Status: No, score=-8.2 required=3.0 tests=FROM_EXCESS_BASE64,
81+
HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,
82+
SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable
83+
autolearn_force=no version=3.4.0
84+
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
85+
by smtp.lore.kernel.org (Postfix) with ESMTP id 02AB1C3A59E
86+
for <netdev@archiver.kernel.org>; Tue, 20 Aug 2019 07:28:35 +0000 (UTC)
87+
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
88+
by mail.kernel.org (Postfix) with ESMTP id CC7942082F
89+
for <netdev@archiver.kernel.org>; Tue, 20 Aug 2019 07:28:34 +0000 (UTC)
90+
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
91+
id S1729348AbfHTH2e (ORCPT <rfc822;netdev@archiver.kernel.org>);
92+
Tue, 20 Aug 2019 03:28:34 -0400
93+
Received: from mga18.intel.com ([134.134.136.126]:58020 "EHLO mga18.intel.com"
94+
rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
95+
id S1729047AbfHTH2e (ORCPT <rfc822;netdev@vger.kernel.org>);
96+
Tue, 20 Aug 2019 03:28:34 -0400
97+
X-Amp-Result: SKIPPED(no attachment in message)
98+
X-Amp-File-Uploaded: False
99+
Received: from orsmga007.jf.intel.com ([10.7.209.58])
100+
by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 00:28:33 -0700
101+
X-ExtLoop1: 1
102+
X-IronPort-AV: E=Sophos;i="5.64,408,1559545200";
103+
d="scan'208";a="169001452"
104+
Received: from arappl-mobl2.ger.corp.intel.com (HELO btopel-mobl.ger.intel.com) ([10.252.53.140])
105+
by orsmga007.jf.intel.com with ESMTP; 20 Aug 2019 00:28:27 -0700
106+
Subject: Re: [PATCH -next] bpf: Use PTR_ERR_OR_ZERO in xsk_map_inc()
107+
To: YueHaibing <yuehaibing@huawei.com>, magnus.karlsson@intel.com,
108+
jonathan.lemon@gmail.com, ast@kernel.org, daniel@iogearbox.net,
109+
kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
110+
john.fastabend@gmail.com
111+
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
112+
kernel-janitors@vger.kernel.org
113+
References: <20190820013652.147041-1-yuehaibing@huawei.com>
114+
From: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= <bjorn.topel@intel.com>
115+
Message-ID: <93fafdab-8fb3-0f2b-8f36-0cf297db3cd9@intel.com>
116+
Date: Tue, 20 Aug 2019 09:28:26 +0200
117+
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
118+
Thunderbird/60.8.0
119+
MIME-Version: 1.0
120+
In-Reply-To: <20190820013652.147041-1-yuehaibing@huawei.com>
121+
Content-Type: text/plain; charset=utf-8; format=flowed
122+
Content-Language: en-US
123+
Content-Transfer-Encoding: 8bit
124+
Sender: netdev-owner@vger.kernel.org
125+
Precedence: bulk
126+
List-ID: <netdev.vger.kernel.org>
127+
X-Mailing-List: netdev@vger.kernel.org
128+
Archived-At: <https://lore.kernel.org/netdev/93fafdab-8fb3-0f2b-8f36-0cf297db3cd9@intel.com/>
129+
List-Archive: <https://lore.kernel.org/netdev/>
130+
List-Post: <mailto:netdev@vger.kernel.org>
131+
132+
On 2019-08-20 03:36, YueHaibing wrote:
133+
> Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
134+
>
135+
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
136+
> ---
137+
> kernel/bpf/xskmap.c | 2 +-
138+
> 1 file changed, 1 insertion(+), 1 deletion(-)
139+
>
140+
> diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
141+
> index 4cc28e226398..942c662e2eed 100644
142+
> --- a/kernel/bpf/xskmap.c
143+
> +++ b/kernel/bpf/xskmap.c
144+
> @@ -21,7 +21,7 @@ int xsk_map_inc(struct xsk_map *map)
145+
> struct bpf_map *m = &map->map;
146+
>
147+
> m = bpf_map_inc(m, false);
148+
> - return IS_ERR(m) ? PTR_ERR(m) : 0;
149+
> + return PTR_ERR_OR_ZERO(m);
150+
> }
151+
>
152+
> void xsk_map_put(struct xsk_map *map)
153+
>
154+
155+
Acked-by: Björn Töpel <bjorn.topel@intel.com>
156+
157+
Thanks for the patch!
158+
159+
For future patches: Prefix AF_XDP socket work with "xsk:" and use "PATCH
160+
bpf-next" to let the developers know what tree you're aiming for.
161+
162+
163+
164+
Cheers!
165+
Björn
166+
167+
168+
>
169+
>
170+
171+
172+

patchwork/tests/test_series.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from patchwork import models
2626
from patchwork import parser
2727
from patchwork.tests import utils
28+
from patchwork.views.utils import patch_to_mbox
2829

2930

3031
TEST_SERIES_DIR = os.path.join(os.path.dirname(__file__), 'series')
@@ -273,6 +274,16 @@ def test_no_references_no_cover(self):
273274
self.assertSerialized(patches, [2])
274275
self.assertSerialized(covers, [1])
275276

277+
def test_multiple_content_types(self):
278+
"""Test what happens when a patch and comment have different
279+
Content-Type headers."""
280+
281+
_, patches, _ = self._parse_mbox(
282+
'bugs-multiple-content-types.mbox', [0, 1, 1])
283+
284+
patch = patches[0]
285+
self.assertEqual(patch_to_mbox(patch).count('Content-Type:'), 1)
286+
276287

277288
class RevisedSeriesTest(_BaseTestCase):
278289
"""Tests for a series plus a single revision.

patchwork/views/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def _submission_to_mbox(submission):
9999

100100
orig_headers = HeaderParser().parsestr(str(submission.headers))
101101
for key, val in orig_headers.items():
102-
# we set this ourselves
103-
if key == 'Content-Transfer-Encoding':
102+
# we set these ourselves
103+
if key in ['Content-Type', 'Content-Transfer-Encoding']:
104104
continue
105105
# we don't save GPG signatures described in RFC1847 [1] so this
106106
# Content-Type value is invalid

0 commit comments

Comments
 (0)