public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Miller <davem@davemloft.net>,
	mb@bu3sch.de, netdev@vger.kernel.org,
	linux-wireless@vger.kernel.org
Subject: Re: mac80211 truesize bugs
Date: Sun, 04 May 2008 00:56:23 +0200	[thread overview]
Message-ID: <1209855383.3649.3.camel@johannes.berg> (raw)
In-Reply-To: <1209830582.3673.8.camel@johannes.berg> (sfid-20080503_180248_421223_067F1B11)

On Sat, 2008-05-03 at 18:03 +0200, Johannes Berg wrote:
> On Sat, 2008-05-03 at 20:59 +0800, Herbert Xu wrote:
> > On Sat, May 03, 2008 at 02:38:01PM +0200, Johannes Berg wrote:
> > >
> > > Why, btw? It's not too hard to check the allocated size, no?
> >=20
> > Yes that would be a meaningful improvement although we'd need to
> > audit/test this to make sure that we don't spam people's logs
> > with it.
>=20
> It does spam the log. A lot. And I don't know why, from this discussi=
on
> I only thought that it shouldn't.

This was a stupid mistake, if you do it correctly it actually works and
so far has only triggered a single warning on my system:

[  217.507048] SKB BUG: Invalid truesize (4294964120) size=3D432, sizeo=
f(sk_buff)=3D176
=EF=BB=BF
that was with my patch though to update skb->truesize during !skb->sk
pskb_expand_head() calls.

johannes

---
 include/linux/skbuff.h |    8 ++++++--
 net/core/skbuff.c      |   10 ++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

--- everything.orig/include/linux/skbuff.h	2008-05-03 15:47:00.00000000=
0 +0200
+++ everything/include/linux/skbuff.h	2008-05-04 00:30:34.000000000 +02=
00
@@ -387,9 +387,13 @@ extern void	      skb_truesize_bug(struc
=20
 static inline void skb_truesize_check(struct sk_buff *skb)
 {
-	int len =3D sizeof(struct sk_buff) + skb->len;
+#ifdef NET_SKBUFF_DATA_USES_OFFSET
+	int len =3D sizeof(struct sk_buff) + skb->end;
+#else
+	int len =3D sizeof(struct sk_buff) + (skb->end - skb->head);
+#endif
=20
-	if (unlikely((int)skb->truesize < len))
+	if (unlikely((int)skb->truesize !=3D len))
 		skb_truesize_bug(skb);
 }
=20
--- everything.orig/net/core/skbuff.c	2008-05-03 16:29:23.000000000 +02=
00
+++ everything/net/core/skbuff.c	2008-05-04 00:31:32.000000000 +0200
@@ -151,9 +151,15 @@ void skb_under_panic(struct sk_buff *skb
=20
 void skb_truesize_bug(struct sk_buff *skb)
 {
+#ifdef NET_SKBUFF_DATA_USES_OFFSET
+	int len =3D sizeof(struct sk_buff) + skb->end;
+#else
+	int len =3D sizeof(struct sk_buff) + (skb->end - skb->head);
+#endif
+
 	printk(KERN_ERR "SKB BUG: Invalid truesize (%u) "
-	       "len=3D%u, sizeof(sk_buff)=3D%Zd\n",
-	       skb->truesize, skb->len, sizeof(struct sk_buff));
+	       "size=3D%u, sizeof(sk_buff)=3D%Zd\n",
+	       skb->truesize, len, sizeof(struct sk_buff));
 }
 EXPORT_SYMBOL(skb_truesize_bug);
=20


--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2008-05-03 22:56 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-01  2:02 mac80211 truesize bugs Johannes Berg
2008-05-01  8:58 ` Michael Buesch
2008-05-01  9:08   ` Johannes Berg
2008-05-01  9:20     ` David Miller
2008-05-01  9:32       ` Johannes Berg
2008-05-01  9:43         ` David Miller
2008-05-01  9:48           ` Johannes Berg
2008-05-01  9:56             ` David Miller
2008-05-01 10:08               ` Johannes Berg
2008-05-01 10:32                 ` David Miller
2008-05-01 10:45                   ` Johannes Berg
2008-05-01 10:36           ` Herbert Xu
2008-05-01 10:49             ` David Miller
2008-05-01 10:53               ` David Miller
2008-05-01 10:58                 ` Johannes Berg
2008-05-01 11:03                   ` Herbert Xu
2008-05-02 20:38                     ` Johannes Berg
2008-05-02 23:33                       ` David Miller
2008-05-03  9:37                         ` Johannes Berg
2008-05-03 14:25                           ` Johannes Berg
2008-05-13  3:17                             ` David Miller
2008-05-13 20:39                               ` John W. Linville
2008-05-13 20:59                                 ` Johannes Berg
2008-05-13 21:12                                   ` Tomas Winkler
2008-05-13 21:37                                     ` Johannes Berg
2008-05-13 22:09                                       ` David Miller
2008-05-03 11:52                         ` Johannes Berg
2008-05-04  1:03                           ` David Miller
2008-05-04  1:42                             ` Johannes Berg
2008-05-04  2:02                               ` Herbert Xu
2008-05-04  2:08                                 ` Johannes Berg
2008-05-04  2:12                                   ` Herbert Xu
2008-05-04  2:22                                     ` Johannes Berg
2008-05-04  3:16                                       ` Herbert Xu
2008-05-04  8:47                                         ` Johannes Berg
2008-05-04  9:14                                           ` Johannes Berg
2008-05-04  9:44                                             ` Herbert Xu
2008-05-04  9:52                                               ` Johannes Berg
2008-05-04 11:25                                                 ` Johannes Berg
2008-05-04 12:28                                                   ` Johannes Berg
2008-05-04 12:45                                                     ` Herbert Xu
2008-05-04 12:48                                                       ` Johannes Berg
2008-05-04 12:52                                                       ` Johannes Berg
2008-05-04 12:56                                                         ` Herbert Xu
2008-05-04 13:00                                                           ` Johannes Berg
2008-05-04 14:06                                                       ` Johannes Berg
2008-05-04 16:03                                                         ` Johannes Berg
2008-05-04 17:47                                                           ` Johannes Berg
2008-05-04 22:45                                                         ` David Miller
2008-05-04 22:48                                                           ` Johannes Berg
2008-05-04 22:38                                         ` David Miller
2008-05-04  2:09                               ` Johannes Berg
2008-05-03 12:38                     ` Johannes Berg
2008-05-03 12:59                       ` Herbert Xu
2008-05-03 16:03                         ` Johannes Berg
2008-05-03 22:56                           ` Johannes Berg [this message]
2008-05-03 23:07                             ` David Miller
2008-05-03 23:15                               ` Johannes Berg
2008-05-01 11:02               ` Herbert Xu
2008-05-01 11:38               ` Johannes Berg
2008-05-03 23:24                 ` Johannes Berg
2008-05-03 23:32                   ` David Miller
2008-05-03 23:43                     ` Johannes Berg
2008-05-01 11:49               ` Johannes Berg
2008-05-01 12:05               ` Johannes Berg
2008-05-01  9:32     ` Michael Buesch
2008-05-01  9:34       ` Johannes Berg
2008-05-04  1:55 ` frame status API? (was: mac80211 truesize bugs) Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1209855383.3649.3.camel@johannes.berg \
    --to=johannes@sipsolutions.net \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox