From patchwork Tue Jun 30 22:18:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin KaFai Lau X-Patchwork-Id: 216761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66AC6C433E0 for ; Tue, 30 Jun 2020 22:19:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A57420760 for ; Tue, 30 Jun 2020 22:19:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="STK6u+OC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726228AbgF3WTH (ORCPT ); Tue, 30 Jun 2020 18:19:07 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:41758 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgF3WTG (ORCPT ); Tue, 30 Jun 2020 18:19:06 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05UMJ1GN027166 for ; Tue, 30 Jun 2020 15:19:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=facebook; bh=8AUQoL8VZdPMjrzGs9W0ynOrf4sulTk8NHwCUowyXxk=; b=STK6u+OCujBJfTYwfD1AXXrcDcAPep1ugBBjLcJ4WgrSzTkf4Y4EckaciuH0DwdcNEBE ci1cjxws2t9VHlSh6gaDhqQV+JcmUHizZbqjKpuh8H4evyDrps1e+Oo4gj1VceqF8emv DJmw/22X9xmCaT4ptbU5iHaLEYFIEiu8hJc= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 31xp39cfdt-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 30 Jun 2020 15:19:06 -0700 Received: from intmgw004.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 30 Jun 2020 15:18:37 -0700 Received: by devbig005.ftw2.facebook.com (Postfix, from userid 6611) id 0FAA6294379D; Tue, 30 Jun 2020 15:18:33 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Martin KaFai Lau Smtp-Origin-Hostname: devbig005.ftw2.facebook.com To: CC: David Miller , , Willem de Bruijn Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH net] ipv4: tcp: Fix SO_MARK in RST and ACK packet Date: Tue, 30 Jun 2020 15:18:33 -0700 Message-ID: <20200630221833.740761-1-kafai@fb.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-06-30_06:2020-06-30,2020-06-30 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 adultscore=0 impostorscore=0 phishscore=0 cotscore=-2147483648 malwarescore=0 lowpriorityscore=0 mlxscore=0 suspectscore=1 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 mlxlogscore=853 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300153 X-FB-Internal: deliver Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When testing a recent kernel (5.6 in our case), the skb->mark of the IPv4 TCP RST pkt does not carry the mark from sk->sk_mark. It is discovered by the bpf@tc that depends on skb->mark to work properly. The same bpf prog has been working in the earlier kernel version. After reverting commit c6af0c227a22 ("ip: support SO_MARK cmsg"), the skb->mark is set and seen by bpf@tc properly. We have noticed that in IPv4 TCP RST but it should also happen to the ACK based on tcp_v4_send_ack() is also depending on ip_send_unicast_reply(). This patch tries to fix it by initializing the ipc.sockc.mark to fl4.flowi4_mark. Fixes: c6af0c227a22 ("ip: support SO_MARK cmsg") Cc: Willem de Bruijn Signed-off-by: Martin KaFai Lau --- net/ipv4/ip_output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 090d3097ee15..033512f719ec 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1703,6 +1703,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, sk->sk_bound_dev_if = arg->bound_dev_if; sk->sk_sndbuf = sysctl_wmem_default; sk->sk_mark = fl4.flowi4_mark; + ipc.sockc.mark = fl4.flowi4_mark; err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, len, 0, &ipc, &rt, MSG_DONTWAIT); if (unlikely(err)) {