diff mbox

Phonet: Correct header retrieval after pskb_may_pull

Message ID 1285665042-20548-1-git-send-email-kumar.sanghvi@stericsson.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Kumar A Sanghvi Sept. 28, 2010, 9:10 a.m. UTC
From: Kumar Sanghvi <kumar.sanghvi@stericsson.com>

Retrieve the header after doing pskb_may_pull since, pskb_may_pull
could change the buffer structure.

This is based on the comment given by Eric Dumazet on Phonet
Pipe controller patch for a similar problem.

Signed-off-by: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
---
 net/phonet/pep.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Eric Dumazet Sept. 28, 2010, 9:47 a.m. UTC | #1
Le mardi 28 septembre 2010 à 14:40 +0530, Kumar A Sanghvi a écrit :
> From: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
> 
> Retrieve the header after doing pskb_may_pull since, pskb_may_pull
> could change the buffer structure.
> 
> This is based on the comment given by Eric Dumazet on Phonet
> Pipe controller patch for a similar problem.
> 
> Signed-off-by: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
> Acked-by: Linus Walleij <linus.walleij@stericsson.com>
> ---
>  net/phonet/pep.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/net/phonet/pep.c b/net/phonet/pep.c
> index 7bf23cf..9746c6d 100644
> --- a/net/phonet/pep.c
> +++ b/net/phonet/pep.c
> @@ -507,12 +507,13 @@ static void pipe_grant_credits(struct sock *sk)
>  static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb)
>  {
>  	struct pep_sock *pn = pep_sk(sk);
> -	struct pnpipehdr *hdr = pnp_hdr(skb);
> +	struct pnpipehdr *hdr;
>  	int wake = 0;
>  
>  	if (!pskb_may_pull(skb, sizeof(*hdr) + 4))
>  		return -EINVAL;
>  
> +	hdr = pnp_hdr(skb);
>  	if (hdr->data[0] != PN_PEP_TYPE_COMMON) {
>  		LIMIT_NETDEBUG(KERN_DEBUG"Phonet unknown PEP type: %u\n",
>  				(unsigned)hdr->data[0]);

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rémi Denis-Courmont Sept. 28, 2010, 9:23 p.m. UTC | #2
On Tuesday 28 September 2010 12:10:42 ext Kumar A Sanghvi, you wrote:
> From: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
> 
> Retrieve the header after doing pskb_may_pull since, pskb_may_pull
> could change the buffer structure.
> 
> This is based on the comment given by Eric Dumazet on Phonet
> Pipe controller patch for a similar problem.
> 
> Signed-off-by: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
> Acked-by: Linus Walleij <linus.walleij@stericsson.com>
> ---
>  net/phonet/pep.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/net/phonet/pep.c b/net/phonet/pep.c
> index 7bf23cf..9746c6d 100644
> --- a/net/phonet/pep.c
> +++ b/net/phonet/pep.c
> @@ -507,12 +507,13 @@ static void pipe_grant_credits(struct sock *sk)
>  static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb)
>  {
>  	struct pep_sock *pn = pep_sk(sk);
> -	struct pnpipehdr *hdr = pnp_hdr(skb);
> +	struct pnpipehdr *hdr;
>  	int wake = 0;
> 
>  	if (!pskb_may_pull(skb, sizeof(*hdr) + 4))
>  		return -EINVAL;
> 
> +	hdr = pnp_hdr(skb);
>  	if (hdr->data[0] != PN_PEP_TYPE_COMMON) {
>  		LIMIT_NETDEBUG(KERN_DEBUG"Phonet unknown PEP type: %u\n",
>  				(unsigned)hdr->data[0]);

Acked-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>

Thanks!
David Miller Sept. 30, 2010, 2:42 a.m. UTC | #3
From: "Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>
Date: Wed, 29 Sep 2010 00:23:44 +0300

> On Tuesday 28 September 2010 12:10:42 ext Kumar A Sanghvi, you wrote:
>> From: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
>> 
>> Retrieve the header after doing pskb_may_pull since, pskb_may_pull
>> could change the buffer structure.
>> 
>> This is based on the comment given by Eric Dumazet on Phonet
>> Pipe controller patch for a similar problem.
>> 
>> Signed-off-by: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
>> Acked-by: Linus Walleij <linus.walleij@stericsson.com>
 ...
> Acked-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>

Applied, thanks everyone.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/phonet/pep.c b/net/phonet/pep.c
index 7bf23cf..9746c6d 100644
--- a/net/phonet/pep.c
+++ b/net/phonet/pep.c
@@ -507,12 +507,13 @@  static void pipe_grant_credits(struct sock *sk)
 static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb)
 {
 	struct pep_sock *pn = pep_sk(sk);
-	struct pnpipehdr *hdr = pnp_hdr(skb);
+	struct pnpipehdr *hdr;
 	int wake = 0;
 
 	if (!pskb_may_pull(skb, sizeof(*hdr) + 4))
 		return -EINVAL;
 
+	hdr = pnp_hdr(skb);
 	if (hdr->data[0] != PN_PEP_TYPE_COMMON) {
 		LIMIT_NETDEBUG(KERN_DEBUG"Phonet unknown PEP type: %u\n",
 				(unsigned)hdr->data[0]);