netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3] netfilter: Correct calculation using skb->tail and skb-network_header
@ 2013-05-31  2:39 Simon Horman
  2013-05-31 23:38 ` David Miller
  2013-06-03  9:06 ` Chen Gang
  0 siblings, 2 replies; 3+ messages in thread
From: Simon Horman @ 2013-05-31  2:39 UTC (permalink / raw)
  To: Pablo Neira Ayuso, David Miller
  Cc: netdev, netfilter-devel, Chen Gang, Simon Horman

This corrects an regression introduced by "net: Use 16bits for *_headers
fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In
that case skb->tail will be a pointer whereas skb->network_header
will be an offset from head. This is corrected by using wrappers that
ensure that calculations are always made using pointers.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Simon Horman <horms@verge.net.au>

--
v3
* Add net-next to subject prefix

v2
* Use skb_tail_pointer() to ensure the tail portion of the calculation is
  always a pointer - it is not if NET_SKBUFF_DATA_USES_OFFSET is not set.
---
 net/netfilter/nf_nat_helper.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nf_nat_helper.c b/net/netfilter/nf_nat_helper.c
index 5fea563..85e20a9 100644
--- a/net/netfilter/nf_nat_helper.c
+++ b/net/netfilter/nf_nat_helper.c
@@ -104,7 +104,7 @@ static void mangle_contents(struct sk_buff *skb,
 	/* move post-replacement */
 	memmove(data + match_offset + rep_len,
 		data + match_offset + match_len,
-		skb->tail - (skb->network_header + dataoff +
+		skb_tail_pointer(skb) - (skb_network_header(skb) + dataoff +
 			     match_offset + match_len));
 
 	/* insert data from buffer */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v3] netfilter: Correct calculation using skb->tail and skb-network_header
  2013-05-31  2:39 [PATCH net-next v3] netfilter: Correct calculation using skb->tail and skb-network_header Simon Horman
@ 2013-05-31 23:38 ` David Miller
  2013-06-03  9:06 ` Chen Gang
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2013-05-31 23:38 UTC (permalink / raw)
  To: horms; +Cc: pablo, netdev, netfilter-devel, gang.chen

From: Simon Horman <horms@verge.net.au>
Date: Fri, 31 May 2013 11:39:29 +0900

> This corrects an regression introduced by "net: Use 16bits for *_headers
> fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In
> that case skb->tail will be a pointer whereas skb->network_header
> will be an offset from head. This is corrected by using wrappers that
> ensure that calculations are always made using pointers.
> 
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Reported-by: Chen Gang <gang.chen@asianux.com>
> Signed-off-by: Simon Horman <horms@verge.net.au>

I've applied this directly to net-next, thanks Simon.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v3] netfilter: Correct calculation using skb->tail and skb-network_header
  2013-05-31  2:39 [PATCH net-next v3] netfilter: Correct calculation using skb->tail and skb-network_header Simon Horman
  2013-05-31 23:38 ` David Miller
@ 2013-06-03  9:06 ` Chen Gang
  1 sibling, 0 replies; 3+ messages in thread
From: Chen Gang @ 2013-06-03  9:06 UTC (permalink / raw)
  To: Simon Horman; +Cc: Pablo Neira Ayuso, David Miller, netdev, netfilter-devel

On 05/31/2013 10:39 AM, Simon Horman wrote:
> This corrects an regression introduced by "net: Use 16bits for *_headers
> fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In
> that case skb->tail will be a pointer whereas skb->network_header
> will be an offset from head. This is corrected by using wrappers that
> ensure that calculations are always made using pointers.
> 
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Reported-by: Chen Gang <gang.chen@asianux.com>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> 
> --
> v3
> * Add net-next to subject prefix
> 
> v2
> * Use skb_tail_pointer() to ensure the tail portion of the calculation is
>   always a pointer - it is not if NET_SKBUFF_DATA_USES_OFFSET is not set.

Thanks.

-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-03  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-31  2:39 [PATCH net-next v3] netfilter: Correct calculation using skb->tail and skb-network_header Simon Horman
2013-05-31 23:38 ` David Miller
2013-06-03  9:06 ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).