]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
netfilter: replace skb_make_writable with skb_ensure_writable
authorFlorian Westphal <fw@strlen.de>
Thu, 23 May 2019 13:44:12 +0000 (15:44 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 31 May 2019 16:02:48 +0000 (18:02 +0200)
This converts all remaining users and then removes skb_make_writable.

Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter.h
net/netfilter/core.c
net/netfilter/nf_synproxy_core.c
net/netfilter/nfnetlink_queue.c
net/netfilter/xt_DSCP.c

index 996bc247ef6e5ed20722f6e41cd52988a5c10240..049aeb40fa35cce11397902ef9859f76a5c1e857 100644 (file)
@@ -336,11 +336,6 @@ int compat_nf_getsockopt(struct sock *sk, u_int8_t pf, int optval,
                char __user *opt, int *len);
 #endif
 
-/* Call this before modifying an existing packet: ensures it is
-   modifiable and linear to the point you care about (writable_len).
-   Returns true or false. */
-int skb_make_writable(struct sk_buff *skb, unsigned int writable_len);
-
 struct flowi;
 struct nf_queue_entry;
 
index b96fd3f5470582c28d231438ce0cd5695c308d1b..817a9e5d16e47accb2074d63c3ad52b2f2436b41 100644 (file)
@@ -536,28 +536,6 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
 }
 EXPORT_SYMBOL(nf_hook_slow);
 
-
-int skb_make_writable(struct sk_buff *skb, unsigned int writable_len)
-{
-       if (writable_len > skb->len)
-               return 0;
-
-       /* Not exclusive use of packet?  Must copy. */
-       if (!skb_cloned(skb)) {
-               if (writable_len <= skb_headlen(skb))
-                       return 1;
-       } else if (skb_clone_writable(skb, writable_len))
-               return 1;
-
-       if (writable_len <= skb_headlen(skb))
-               writable_len = 0;
-       else
-               writable_len -= skb_headlen(skb);
-
-       return !!__pskb_pull_tail(skb, writable_len);
-}
-EXPORT_SYMBOL(skb_make_writable);
-
 /* This needs to be compiled in any case to avoid dependencies between the
  * nfnetlink_queue code and nf_conntrack.
  */
index 8ff4d22f10b2a14d9486686a7dddcb56204f5d3b..3d58a9e93e5a401265a33b18a2fee7851f2b6b5d 100644 (file)
@@ -196,7 +196,7 @@ unsigned int synproxy_tstamp_adjust(struct sk_buff *skb,
        optoff = protoff + sizeof(struct tcphdr);
        optend = protoff + th->doff * 4;
 
-       if (!skb_make_writable(skb, optend))
+       if (skb_ensure_writable(skb, optend))
                return 0;
 
        while (optoff < optend) {
index 27dac47b29c2964f8db3552555aa4a1e91094c72..831f57008d78ef8808f6232e5870a73e32846251 100644 (file)
@@ -863,7 +863,7 @@ nfqnl_mangle(void *data, int data_len, struct nf_queue_entry *e, int diff)
                }
                skb_put(e->skb, diff);
        }
-       if (!skb_make_writable(e->skb, data_len))
+       if (skb_ensure_writable(e->skb, data_len))
                return -ENOMEM;
        skb_copy_to_linear_data(e->skb, data, data_len);
        e->skb->ip_summed = CHECKSUM_NONE;
index 098ed851b7a782e15caa1c1e7ff52a7c909b340a..30d554d6c213f08404984f9ed7040f385341c33e 100644 (file)
@@ -34,7 +34,7 @@ dscp_tg(struct sk_buff *skb, const struct xt_action_param *par)
        u_int8_t dscp = ipv4_get_dsfield(ip_hdr(skb)) >> XT_DSCP_SHIFT;
 
        if (dscp != dinfo->dscp) {
-               if (!skb_make_writable(skb, sizeof(struct iphdr)))
+               if (skb_ensure_writable(skb, sizeof(struct iphdr)))
                        return NF_DROP;
 
                ipv4_change_dsfield(ip_hdr(skb),
@@ -52,7 +52,7 @@ dscp_tg6(struct sk_buff *skb, const struct xt_action_param *par)
        u_int8_t dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> XT_DSCP_SHIFT;
 
        if (dscp != dinfo->dscp) {
-               if (!skb_make_writable(skb, sizeof(struct ipv6hdr)))
+               if (skb_ensure_writable(skb, sizeof(struct ipv6hdr)))
                        return NF_DROP;
 
                ipv6_change_dsfield(ipv6_hdr(skb),
@@ -82,7 +82,7 @@ tos_tg(struct sk_buff *skb, const struct xt_action_param *par)
        nv   = (orig & ~info->tos_mask) ^ info->tos_value;
 
        if (orig != nv) {
-               if (!skb_make_writable(skb, sizeof(struct iphdr)))
+               if (skb_ensure_writable(skb, sizeof(struct iphdr)))
                        return NF_DROP;
                iph = ip_hdr(skb);
                ipv4_change_dsfield(iph, 0, nv);
@@ -102,7 +102,7 @@ tos_tg6(struct sk_buff *skb, const struct xt_action_param *par)
        nv   = (orig & ~info->tos_mask) ^ info->tos_value;
 
        if (orig != nv) {
-               if (!skb_make_writable(skb, sizeof(struct iphdr)))
+               if (skb_ensure_writable(skb, sizeof(struct iphdr)))
                        return NF_DROP;
                iph = ipv6_hdr(skb);
                ipv6_change_dsfield(iph, 0, nv);