Re: [PATCH] inet: frags: Convert timers to use timer_setup()

2017-10-16 Thread Stefan Schmidt
Hello.

On 05.10.2017 02:52, Kees Cook wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly.
> 
> Cc: Alexander Aring 
> Cc: Stefan Schmidt 
> Cc: "David S. Miller" 
> Cc: Alexey Kuznetsov 
> Cc: Hideaki YOSHIFUJI 
> Cc: Pablo Neira Ayuso 
> Cc: Jozsef Kadlecsik 
> Cc: Florian Westphal 
> Cc: linux-w...@vger.kernel.org
> Cc: net...@vger.kernel.org
> Cc: netfilter-de...@vger.kernel.org
> Cc: coret...@netfilter.org
> Cc: Thomas Gleixner 
> Signed-off-by: Kees Cook 
> ---
> This requires commit 686fef928bba ("timer: Prepare to change timer
> callback argument type") in v4.14-rc3, but should be otherwise
> stand-alone.
> ---
>  include/net/inet_frag.h | 2 +-
>  net/ieee802154/6lowpan/reassembly.c | 5 +++--
>  net/ipv4/inet_fragment.c| 4 ++--
>  net/ipv4/ip_fragment.c  | 5 +++--
>  net/ipv6/netfilter/nf_conntrack_reasm.c | 5 +++--
>  net/ipv6/reassembly.c   | 5 +++--
>  6 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
> index fc59e0775e00..c695807ca707 100644
> --- a/include/net/inet_frag.h
> +++ b/include/net/inet_frag.h
> @@ -95,7 +95,7 @@ struct inet_frags {
>   void(*constructor)(struct inet_frag_queue *q,
>  const void *arg);
>   void(*destructor)(struct inet_frag_queue *);
> - void(*frag_expire)(unsigned long data);
> + void(*frag_expire)(struct timer_list *t);
>   struct kmem_cache   *frags_cachep;
>   const char  *frags_cache_name;
>  };
> diff --git a/net/ieee802154/6lowpan/reassembly.c 
> b/net/ieee802154/6lowpan/reassembly.c
> index f85b08baff16..85bf86ad6b18 100644
> --- a/net/ieee802154/6lowpan/reassembly.c
> +++ b/net/ieee802154/6lowpan/reassembly.c
> @@ -80,12 +80,13 @@ static void lowpan_frag_init(struct inet_frag_queue *q, 
> const void *a)
>   fq->daddr = *arg->dst;
>  }
>  
> -static void lowpan_frag_expire(unsigned long data)
> +static void lowpan_frag_expire(struct timer_list *t)
>  {
> + struct inet_frag_queue *frag = from_timer(frag, t, timer);
>   struct frag_queue *fq;
>   struct net *net;
>  
> - fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
> + fq = container_of(frag, struct frag_queue, q);
>   net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
>  
>   spin_lock(>q.lock);
> diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
> index af74d0433453..7f3ef5c287a1 100644
> --- a/net/ipv4/inet_fragment.c
> +++ b/net/ipv4/inet_fragment.c
> @@ -147,7 +147,7 @@ inet_evict_bucket(struct inet_frags *f, struct 
> inet_frag_bucket *hb)
>   spin_unlock(>chain_lock);
>  
>   hlist_for_each_entry_safe(fq, n, , list_evictor)
> - f->frag_expire((unsigned long) fq);
> + f->frag_expire(>timer);
>  
>   return evicted;
>  }
> @@ -366,7 +366,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct 
> netns_frags *nf,
>   f->constructor(q, arg);
>   add_frag_mem_limit(nf, f->qsize);
>  
> - setup_timer(>timer, f->frag_expire, (unsigned long)q);
> + timer_setup(>timer, f->frag_expire, 0);
>   spin_lock_init(>lock);
>   refcount_set(>refcnt, 1);
>  
> diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
> index 46408c220d9d..9215654a401f 100644
> --- a/net/ipv4/ip_fragment.c
> +++ b/net/ipv4/ip_fragment.c
> @@ -190,12 +190,13 @@ static bool frag_expire_skip_icmp(u32 user)
>  /*
>   * Oops, a fragment queue timed out.  Kill it and send an ICMP reply.
>   */
> -static void ip_expire(unsigned long arg)
> +static void ip_expire(struct timer_list *t)
>  {
> + struct inet_frag_queue *frag = from_timer(frag, t, timer);
>   struct ipq *qp;
>   struct net *net;
>  
> - qp = container_of((struct inet_frag_queue *) arg, struct ipq, q);
> + qp = container_of(frag, struct ipq, q);
>   net = container_of(qp->q.net, struct net, ipv4.frags);
>  
>   rcu_read_lock();
> diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c 
> b/net/ipv6/netfilter/nf_conntrack_reasm.c
> index b263bf3a19f7..977d8900cfd1 100644
> --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
> +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
> @@ -169,12 +169,13 @@ static unsigned int nf_hashfn(const struct 
> inet_frag_queue *q)
>   return nf_hash_frag(nq->id, >saddr, >daddr);
>  }
>  
> -static void nf_ct_frag6_expire(unsigned long data)
> +static void nf_ct_frag6_expire(struct timer_list *t)
>  {
> + struct 

Re: [PATCH] inet: frags: Convert timers to use timer_setup()

2017-10-16 Thread Stefan Schmidt
Hello.

On 05.10.2017 02:52, Kees Cook wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly.
> 
> Cc: Alexander Aring 
> Cc: Stefan Schmidt 
> Cc: "David S. Miller" 
> Cc: Alexey Kuznetsov 
> Cc: Hideaki YOSHIFUJI 
> Cc: Pablo Neira Ayuso 
> Cc: Jozsef Kadlecsik 
> Cc: Florian Westphal 
> Cc: linux-w...@vger.kernel.org
> Cc: net...@vger.kernel.org
> Cc: netfilter-de...@vger.kernel.org
> Cc: coret...@netfilter.org
> Cc: Thomas Gleixner 
> Signed-off-by: Kees Cook 
> ---
> This requires commit 686fef928bba ("timer: Prepare to change timer
> callback argument type") in v4.14-rc3, but should be otherwise
> stand-alone.
> ---
>  include/net/inet_frag.h | 2 +-
>  net/ieee802154/6lowpan/reassembly.c | 5 +++--
>  net/ipv4/inet_fragment.c| 4 ++--
>  net/ipv4/ip_fragment.c  | 5 +++--
>  net/ipv6/netfilter/nf_conntrack_reasm.c | 5 +++--
>  net/ipv6/reassembly.c   | 5 +++--
>  6 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
> index fc59e0775e00..c695807ca707 100644
> --- a/include/net/inet_frag.h
> +++ b/include/net/inet_frag.h
> @@ -95,7 +95,7 @@ struct inet_frags {
>   void(*constructor)(struct inet_frag_queue *q,
>  const void *arg);
>   void(*destructor)(struct inet_frag_queue *);
> - void(*frag_expire)(unsigned long data);
> + void(*frag_expire)(struct timer_list *t);
>   struct kmem_cache   *frags_cachep;
>   const char  *frags_cache_name;
>  };
> diff --git a/net/ieee802154/6lowpan/reassembly.c 
> b/net/ieee802154/6lowpan/reassembly.c
> index f85b08baff16..85bf86ad6b18 100644
> --- a/net/ieee802154/6lowpan/reassembly.c
> +++ b/net/ieee802154/6lowpan/reassembly.c
> @@ -80,12 +80,13 @@ static void lowpan_frag_init(struct inet_frag_queue *q, 
> const void *a)
>   fq->daddr = *arg->dst;
>  }
>  
> -static void lowpan_frag_expire(unsigned long data)
> +static void lowpan_frag_expire(struct timer_list *t)
>  {
> + struct inet_frag_queue *frag = from_timer(frag, t, timer);
>   struct frag_queue *fq;
>   struct net *net;
>  
> - fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
> + fq = container_of(frag, struct frag_queue, q);
>   net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
>  
>   spin_lock(>q.lock);
> diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
> index af74d0433453..7f3ef5c287a1 100644
> --- a/net/ipv4/inet_fragment.c
> +++ b/net/ipv4/inet_fragment.c
> @@ -147,7 +147,7 @@ inet_evict_bucket(struct inet_frags *f, struct 
> inet_frag_bucket *hb)
>   spin_unlock(>chain_lock);
>  
>   hlist_for_each_entry_safe(fq, n, , list_evictor)
> - f->frag_expire((unsigned long) fq);
> + f->frag_expire(>timer);
>  
>   return evicted;
>  }
> @@ -366,7 +366,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct 
> netns_frags *nf,
>   f->constructor(q, arg);
>   add_frag_mem_limit(nf, f->qsize);
>  
> - setup_timer(>timer, f->frag_expire, (unsigned long)q);
> + timer_setup(>timer, f->frag_expire, 0);
>   spin_lock_init(>lock);
>   refcount_set(>refcnt, 1);
>  
> diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
> index 46408c220d9d..9215654a401f 100644
> --- a/net/ipv4/ip_fragment.c
> +++ b/net/ipv4/ip_fragment.c
> @@ -190,12 +190,13 @@ static bool frag_expire_skip_icmp(u32 user)
>  /*
>   * Oops, a fragment queue timed out.  Kill it and send an ICMP reply.
>   */
> -static void ip_expire(unsigned long arg)
> +static void ip_expire(struct timer_list *t)
>  {
> + struct inet_frag_queue *frag = from_timer(frag, t, timer);
>   struct ipq *qp;
>   struct net *net;
>  
> - qp = container_of((struct inet_frag_queue *) arg, struct ipq, q);
> + qp = container_of(frag, struct ipq, q);
>   net = container_of(qp->q.net, struct net, ipv4.frags);
>  
>   rcu_read_lock();
> diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c 
> b/net/ipv6/netfilter/nf_conntrack_reasm.c
> index b263bf3a19f7..977d8900cfd1 100644
> --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
> +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
> @@ -169,12 +169,13 @@ static unsigned int nf_hashfn(const struct 
> inet_frag_queue *q)
>   return nf_hash_frag(nq->id, >saddr, >daddr);
>  }
>  
> -static void nf_ct_frag6_expire(unsigned long data)
> +static void nf_ct_frag6_expire(struct timer_list *t)
>  {
> + struct inet_frag_queue *frag = from_timer(frag, t, timer);
>   struct frag_queue *fq;
>   struct net *net;
>  
> - fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
> + fq = container_of(frag, 

[PATCH] inet: frags: Convert timers to use timer_setup()

2017-10-04 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Alexander Aring 
Cc: Stefan Schmidt 
Cc: "David S. Miller" 
Cc: Alexey Kuznetsov 
Cc: Hideaki YOSHIFUJI 
Cc: Pablo Neira Ayuso 
Cc: Jozsef Kadlecsik 
Cc: Florian Westphal 
Cc: linux-w...@vger.kernel.org
Cc: net...@vger.kernel.org
Cc: netfilter-de...@vger.kernel.org
Cc: coret...@netfilter.org
Cc: Thomas Gleixner 
Signed-off-by: Kees Cook 
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
 include/net/inet_frag.h | 2 +-
 net/ieee802154/6lowpan/reassembly.c | 5 +++--
 net/ipv4/inet_fragment.c| 4 ++--
 net/ipv4/ip_fragment.c  | 5 +++--
 net/ipv6/netfilter/nf_conntrack_reasm.c | 5 +++--
 net/ipv6/reassembly.c   | 5 +++--
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index fc59e0775e00..c695807ca707 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -95,7 +95,7 @@ struct inet_frags {
void(*constructor)(struct inet_frag_queue *q,
   const void *arg);
void(*destructor)(struct inet_frag_queue *);
-   void(*frag_expire)(unsigned long data);
+   void(*frag_expire)(struct timer_list *t);
struct kmem_cache   *frags_cachep;
const char  *frags_cache_name;
 };
diff --git a/net/ieee802154/6lowpan/reassembly.c 
b/net/ieee802154/6lowpan/reassembly.c
index f85b08baff16..85bf86ad6b18 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -80,12 +80,13 @@ static void lowpan_frag_init(struct inet_frag_queue *q, 
const void *a)
fq->daddr = *arg->dst;
 }
 
-static void lowpan_frag_expire(unsigned long data)
+static void lowpan_frag_expire(struct timer_list *t)
 {
+   struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct frag_queue *fq;
struct net *net;
 
-   fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
+   fq = container_of(frag, struct frag_queue, q);
net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
 
spin_lock(>q.lock);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index af74d0433453..7f3ef5c287a1 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -147,7 +147,7 @@ inet_evict_bucket(struct inet_frags *f, struct 
inet_frag_bucket *hb)
spin_unlock(>chain_lock);
 
hlist_for_each_entry_safe(fq, n, , list_evictor)
-   f->frag_expire((unsigned long) fq);
+   f->frag_expire(>timer);
 
return evicted;
 }
@@ -366,7 +366,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct 
netns_frags *nf,
f->constructor(q, arg);
add_frag_mem_limit(nf, f->qsize);
 
-   setup_timer(>timer, f->frag_expire, (unsigned long)q);
+   timer_setup(>timer, f->frag_expire, 0);
spin_lock_init(>lock);
refcount_set(>refcnt, 1);
 
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 46408c220d9d..9215654a401f 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -190,12 +190,13 @@ static bool frag_expire_skip_icmp(u32 user)
 /*
  * Oops, a fragment queue timed out.  Kill it and send an ICMP reply.
  */
-static void ip_expire(unsigned long arg)
+static void ip_expire(struct timer_list *t)
 {
+   struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct ipq *qp;
struct net *net;
 
-   qp = container_of((struct inet_frag_queue *) arg, struct ipq, q);
+   qp = container_of(frag, struct ipq, q);
net = container_of(qp->q.net, struct net, ipv4.frags);
 
rcu_read_lock();
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c 
b/net/ipv6/netfilter/nf_conntrack_reasm.c
index b263bf3a19f7..977d8900cfd1 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -169,12 +169,13 @@ static unsigned int nf_hashfn(const struct 
inet_frag_queue *q)
return nf_hash_frag(nq->id, >saddr, >daddr);
 }
 
-static void nf_ct_frag6_expire(unsigned long data)
+static void nf_ct_frag6_expire(struct timer_list *t)
 {
+   struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct frag_queue *fq;
struct net *net;
 
-   fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
+   fq = container_of(frag, struct 

[PATCH] inet: frags: Convert timers to use timer_setup()

2017-10-04 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Alexander Aring 
Cc: Stefan Schmidt 
Cc: "David S. Miller" 
Cc: Alexey Kuznetsov 
Cc: Hideaki YOSHIFUJI 
Cc: Pablo Neira Ayuso 
Cc: Jozsef Kadlecsik 
Cc: Florian Westphal 
Cc: linux-w...@vger.kernel.org
Cc: net...@vger.kernel.org
Cc: netfilter-de...@vger.kernel.org
Cc: coret...@netfilter.org
Cc: Thomas Gleixner 
Signed-off-by: Kees Cook 
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
 include/net/inet_frag.h | 2 +-
 net/ieee802154/6lowpan/reassembly.c | 5 +++--
 net/ipv4/inet_fragment.c| 4 ++--
 net/ipv4/ip_fragment.c  | 5 +++--
 net/ipv6/netfilter/nf_conntrack_reasm.c | 5 +++--
 net/ipv6/reassembly.c   | 5 +++--
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index fc59e0775e00..c695807ca707 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -95,7 +95,7 @@ struct inet_frags {
void(*constructor)(struct inet_frag_queue *q,
   const void *arg);
void(*destructor)(struct inet_frag_queue *);
-   void(*frag_expire)(unsigned long data);
+   void(*frag_expire)(struct timer_list *t);
struct kmem_cache   *frags_cachep;
const char  *frags_cache_name;
 };
diff --git a/net/ieee802154/6lowpan/reassembly.c 
b/net/ieee802154/6lowpan/reassembly.c
index f85b08baff16..85bf86ad6b18 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -80,12 +80,13 @@ static void lowpan_frag_init(struct inet_frag_queue *q, 
const void *a)
fq->daddr = *arg->dst;
 }
 
-static void lowpan_frag_expire(unsigned long data)
+static void lowpan_frag_expire(struct timer_list *t)
 {
+   struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct frag_queue *fq;
struct net *net;
 
-   fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
+   fq = container_of(frag, struct frag_queue, q);
net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
 
spin_lock(>q.lock);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index af74d0433453..7f3ef5c287a1 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -147,7 +147,7 @@ inet_evict_bucket(struct inet_frags *f, struct 
inet_frag_bucket *hb)
spin_unlock(>chain_lock);
 
hlist_for_each_entry_safe(fq, n, , list_evictor)
-   f->frag_expire((unsigned long) fq);
+   f->frag_expire(>timer);
 
return evicted;
 }
@@ -366,7 +366,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct 
netns_frags *nf,
f->constructor(q, arg);
add_frag_mem_limit(nf, f->qsize);
 
-   setup_timer(>timer, f->frag_expire, (unsigned long)q);
+   timer_setup(>timer, f->frag_expire, 0);
spin_lock_init(>lock);
refcount_set(>refcnt, 1);
 
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 46408c220d9d..9215654a401f 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -190,12 +190,13 @@ static bool frag_expire_skip_icmp(u32 user)
 /*
  * Oops, a fragment queue timed out.  Kill it and send an ICMP reply.
  */
-static void ip_expire(unsigned long arg)
+static void ip_expire(struct timer_list *t)
 {
+   struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct ipq *qp;
struct net *net;
 
-   qp = container_of((struct inet_frag_queue *) arg, struct ipq, q);
+   qp = container_of(frag, struct ipq, q);
net = container_of(qp->q.net, struct net, ipv4.frags);
 
rcu_read_lock();
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c 
b/net/ipv6/netfilter/nf_conntrack_reasm.c
index b263bf3a19f7..977d8900cfd1 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -169,12 +169,13 @@ static unsigned int nf_hashfn(const struct 
inet_frag_queue *q)
return nf_hash_frag(nq->id, >saddr, >daddr);
 }
 
-static void nf_ct_frag6_expire(unsigned long data)
+static void nf_ct_frag6_expire(struct timer_list *t)
 {
+   struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct frag_queue *fq;
struct net *net;
 
-   fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
+   fq = container_of(frag, struct frag_queue, q);
net = container_of(fq->q.net, struct net, nf_frag.frags);
 
ip6_expire_frag_queue(net, fq, _frags);
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index