Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5761116imm; Mon, 23 Jul 2018 05:44:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfG5SQ8rNUUT8ZvjP2RgnX+kav4Fg5HZuPmKxaIoVLjX+G+pdrFIN0QoATxJWLiO/21YyE0 X-Received: by 2002:a62:5cc1:: with SMTP id q184-v6mr13138776pfb.241.1532349884501; Mon, 23 Jul 2018 05:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532349884; cv=none; d=google.com; s=arc-20160816; b=HIU3QQgChGl2Gg/AjWPwOpLqp6MMzHzAgbv5kazQsp0pvRhfrkRrfEWUbAjAzOhdv3 aDZUFZe6BpRPcrclNN03FpR4tg2hSeHDSWbRrDQwdmn2WA9EaemeimzgAesPJBjXH91g GnbziufVLcxDFWuyymRhcEr9mu5Z7dW80jg28sqtmDoguLRxWj3qvdAoIhOfGjfNEnqX N6IK3a86TrJOVlYZobHD+PQCSIbLtm6QAYg1DSn8I9V7j9Qa1z1MVoVFoKxvOUB77nRa aiwwLyhE765eNnu4+728oQ52w37TV6hJ2yX2374gtOwZyYB0t3SO3a6RA9DPiWiz26RR 8XKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wqYiHeElSCyNBYbkyFsVhR3lJi87PjFvEN1FiWZehOU=; b=qLCMZBIneCYJC1/n7ockgggoXE/uMLI7JZ8OE5UFcSdzwJ//4yScaL2pwFL3fGz+iO fSkfBE+Z2LZABh8NW9bfhFmnLTb29GqCnsrlPRDy3l4pSI8+PIndqDux32sxS2iYeksy Xcuj4bNXZb+3xi+EPGnk+UK4T020IcqaNEVbJcRybDlOFVGCZBTbZ1b1XBVq+s1e1CWG NSSGSoAQH8rxOsbSoms+pStjAfqBW8gESYQ8GbxEd+THmF/rhWUTi5wMOqt4cLhZkgxp WRKZanBUqEX3f4mZ+n35g/2ILS9uhDviJLVFh7TAPjnpsumq2OInPhzWk+PAxtweKRps EtCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c192-v6si8515589pfg.347.2018.07.23.05.44.30; Mon, 23 Jul 2018 05:44:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388704AbeGWNoI (ORCPT + 99 others); Mon, 23 Jul 2018 09:44:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47656 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388242AbeGWNoI (ORCPT ); Mon, 23 Jul 2018 09:44:08 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EC36E40B; Mon, 23 Jul 2018 12:43:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrick Talbert , Stefano Brivio , "David S. Miller" Subject: [PATCH 4.4 015/107] net: Dont copy pfmemalloc flag in __copy_skb_header() Date: Mon, 23 Jul 2018 14:41:09 +0200 Message-Id: <20180723122413.558346923@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefano Brivio [ Upstream commit 8b7008620b8452728cadead460a36f64ed78c460 ] The pfmemalloc flag indicates that the skb was allocated from the PFMEMALLOC reserves, and the flag is currently copied on skb copy and clone. However, an skb copied from an skb flagged with pfmemalloc wasn't necessarily allocated from PFMEMALLOC reserves, and on the other hand an skb allocated that way might be copied from an skb that wasn't. So we should not copy the flag on skb copy, and rather decide whether to allow an skb to be associated with sockets unrelated to page reclaim depending only on how it was allocated. Move the pfmemalloc flag before headers_start[0] using an existing 1-bit hole, so that __copy_skb_header() doesn't copy it. When cloning, we'll now take care of this flag explicitly, contravening to the warning comment of __skb_clone(). While at it, restore the newline usage introduced by commit b19372273164 ("net: reorganize sk_buff for faster __copy_skb_header()") to visually separate bytes used in bitfields after headers_start[0], that was gone after commit a9e419dc7be6 ("netfilter: merge ctinfo into nfct pointer storage area"), and describe the pfmemalloc flag in the kernel-doc structure comment. This doesn't change the size of sk_buff or cacheline boundaries, but consolidates the 15 bits hole before tc_index into a 2 bytes hole before csum, that could now be filled more easily. Reported-by: Patrick Talbert Fixes: c93bdd0e03e8 ("netvm: allow skb allocation to use PFMEMALLOC reserves") Signed-off-by: Stefano Brivio Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/skbuff.h | 12 ++++++------ net/core/skbuff.c | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -514,6 +514,7 @@ static inline bool skb_mstamp_after(cons * @hash: the packet hash * @queue_mapping: Queue mapping for multiqueue devices * @xmit_more: More SKBs are pending for this queue + * @pfmemalloc: skbuff was allocated from PFMEMALLOC reserves * @ndisc_nodetype: router type (from link layer) * @ooo_okay: allow the mapping of a socket to a queue to be changed * @l4_hash: indicate hash is a canonical 4-tuple hash over transport @@ -594,8 +595,8 @@ struct sk_buff { fclone:2, peeked:1, head_frag:1, - xmit_more:1; - /* one bit hole */ + xmit_more:1, + pfmemalloc:1; kmemcheck_bitfield_end(flags1); /* fields enclosed in headers_start/headers_end are copied @@ -615,19 +616,18 @@ struct sk_buff { __u8 __pkt_type_offset[0]; __u8 pkt_type:3; - __u8 pfmemalloc:1; __u8 ignore_df:1; __u8 nfctinfo:3; - __u8 nf_trace:1; + __u8 ip_summed:2; __u8 ooo_okay:1; __u8 l4_hash:1; __u8 sw_hash:1; __u8 wifi_acked_valid:1; __u8 wifi_acked:1; - __u8 no_fcs:1; + /* Indicates the inner headers are valid in the skbuff. */ __u8 encapsulation:1; __u8 encap_hdr_csum:1; @@ -635,11 +635,11 @@ struct sk_buff { __u8 csum_complete_sw:1; __u8 csum_level:2; __u8 csum_bad:1; - #ifdef CONFIG_IPV6_NDISC_NODETYPE __u8 ndisc_nodetype:2; #endif __u8 ipvs_property:1; + __u8 inner_protocol_type:1; __u8 remcsum_offload:1; /* 3 or 5 bit hole */ --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -828,6 +828,8 @@ static struct sk_buff *__skb_clone(struc n->cloned = 1; n->nohdr = 0; n->peeked = 0; + if (skb->pfmemalloc) + n->pfmemalloc = 1; n->destructor = NULL; C(tail); C(end);