[AUDIT]: Increase skb->truesize in audit_expand

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, February 1, 2008 - 4:00 am

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=406a1d...
Commit:     406a1d868001423c85a3165288e566e65f424fe6
Parent:     29ffe1a5c52dae13b6efead97aab9b058f38fce4
Author:     Herbert Xu <herbert@gondor.apana.org.au>
AuthorDate: Mon Jan 28 20:47:09 2008 -0800
Committer:  David S. Miller <davem@davemloft.net>
CommitDate: Thu Jan 31 19:27:08 2008 -0800

    [AUDIT]: Increase skb->truesize in audit_expand
    
    The recent UDP patch exposed this bug in the audit code.  It
    was calling pskb_expand_head without increasing skb->truesize.
    The caller of pskb_expand_head needs to do so because that function
    is designed to be called in places where truesize is already fixed
    and therefore it doesn't update its value.
    
    Because the audit system is using it in a place where the truesize
    has not yet been fixed, it needs to update its value manually.
    
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Acked-by: James Morris <jmorris@namei.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
---
 kernel/audit.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index f93c271..801c946 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1200,13 +1200,17 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
 static inline int audit_expand(struct audit_buffer *ab, int extra)
 {
 	struct sk_buff *skb = ab->skb;
-	int ret = pskb_expand_head(skb, skb_headroom(skb), extra,
-				   ab->gfp_mask);
+	int oldtail = skb_tailroom(skb);
+	int ret = pskb_expand_head(skb, 0, extra, ab->gfp_mask);
+	int newtail = skb_tailroom(skb);
+
 	if (ret < 0) {
 		audit_log_lost("out of memory in audit_expand");
 		return 0;
 	}
-	return skb_tailroom(skb);
+
+	skb->truesize += newtail - oldtail;
+	return newtail;
 }
 
 /*
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[AUDIT]: Increase skb->truesize in audit_expand, Linux Kernel Mailing ..., (Fri Feb 1, 4:00 am)