mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Mazur <krzysiek@podlesie.net>
To: David Woodhouse <dwmw2@infradead.org>
Cc: chas williams - CONTRACTOR <chas@cmf.nrl.navy.mil>,
	davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] atm: introduce vcc_pop_skb()
Date: Mon, 3 Dec 2012 21:11:18 +0100	[thread overview]
Message-ID: <20121203201118.GB19460@shrek.podlesie.net> (raw)
In-Reply-To: <1354540961.24281.82.camel@shinybook.infradead.org>

On Mon, Dec 03, 2012 at 01:22:41PM +0000, David Woodhouse wrote:
> On Wed, 2012-11-28 at 23:33 +0100, Krzysztof Mazur wrote:
> > 
> > Many ATM drivers store vcc in ATM_SKB(skb)->vcc and use it for
> > freeing skbs. Now they can just use atm_pop_skb() to free such
> > buffers.
> > 
> > Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
> 
> Note that this one didn't make it into the tree that Dave just pulled.
> 
> Not that I didn't think it was a good idea, but it was just separate
> from the other "real" fixes ??? and the tree had already grown into a big
> enough pile from your original single patch!

That patch is a preparation of separate series. The current version
(far from final version) is available at:

git://git.podlesie.net/km/linux.git atm-pop

and

http://git.podlesie.net/gitweb.cgi?p=km/linux.git;a=shortlog;h=refs/heads/atm-pop

Patch 3 and especially patch 4 are far from being ready. They are also ugly
because many ATM drivers use strange coding style and I tried to use that
style because using different style for new code would be probably be even worse.

Currently there are 4 patches:
      atm: introduce vcc_pop()
      atm: introduce vcc_pop_skb()
      atm: convert drivers to use vcc_pop*()
      atm: add missing vcc_pop*() calls in drivers

The first two introduce two helpers vcc_pop() and vcc_pop_skb(). The third
should be 1:1 conversion of vcc->pop() users to vcc_pop*() interface.
The forth patch fixes some problems I've found. In all cases the bugs
occurs in error handling code, in most cases dev_kfree_skb() is used
instead of vcc_pop(), in some cases driver just returns some error
code and skb is never freed, in two cases I removed the vcc->pop()
call in code like:

static int eni_send(struct atm_vcc *vcc,struct sk_buff *skb)
{
	[...]
	if (!skb) {
		printk(KERN_CRIT "!skb in eni_send ?\n");
		if (vcc->pop) vcc->pop(vcc,skb);
		return -EINVAL;
	}

I don't think that we should check for !skb and even if skb == NULL
it's not a good idea to call vcc->pop() because it will crash.

Current diffstat:
 drivers/atm/adummy.c     |  5 +---
 drivers/atm/ambassador.c | 34 ++++++++++++++--------------
 drivers/atm/atmtcp.c     | 15 ++++--------
 drivers/atm/eni.c        | 11 ++++-----
 drivers/atm/firestream.c | 19 ++--------------
 drivers/atm/fore200e.c   | 23 ++++---------------
 drivers/atm/he.c         | 33 ++++++---------------------
 drivers/atm/horizon.c    | 31 +++++++++----------------
 drivers/atm/idt77252.c   | 32 +++++++-------------------
 drivers/atm/iphase.c     | 59 +++++++++++++-----------------------------------
 drivers/atm/lanai.c      | 18 ++++-----------
 drivers/atm/nicstar.c    | 31 ++++++++-----------------
 drivers/atm/solos-pci.c  |  5 +---
 drivers/atm/zatm.c       | 13 ++++-------
 drivers/usb/atm/usbatm.c | 17 ++++----------
 include/linux/atmdev.h   | 16 +++++++++++++
 net/atm/common.c         | 15 ++++++++++++
 17 files changed, 128 insertions(+), 249 deletions(-)

> 
> In <20121006154606.GA25588@shrek.podlesie.net> you posted another patch:
> > I think there is another problem here. The pppoatm gets a reference
> > to atmvcc, but I don't see anything that protects against removal
> > of that vcc.
> > 
> > The vcc uses vcc->sk socket for reference counting, so sock_hold()
> > and sock_put() should be used by pppoatm.
> 
> That one I think *isn't* needed, because we have properly fixed the
> races with vcc_destroy_socket(). I just wanted to check you agree...?
> 

It was never really needed, I removed it from v3.

Thanks,

Krzysiek

  reply	other threads:[~2012-12-03 20:11 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 17:14 [PATCH v2 1/3] pppoatm: don't send frames to destroyed vcc Krzysztof Mazur
2012-10-22 17:14 ` [PATCH v2 2/3] pppoatm: fix race condition with destroying of vcc Krzysztof Mazur
2012-10-30  9:37   ` David Woodhouse
2012-10-30 19:07     ` Krzysztof Mazur
2012-10-30 19:52       ` Krzysztof Mazur
2012-10-31 10:16         ` David Woodhouse
2012-10-31 11:30           ` Krzysztof Mazur
2012-10-31 11:52             ` David Woodhouse
2012-10-30 14:26   ` Chas Williams (CONTRACTOR)
2012-10-30 18:20     ` Krzysztof Mazur
2012-10-31  9:41       ` Krzysztof Mazur
2012-10-31 10:22         ` Krzysztof Mazur
2012-10-31 20:03         ` chas williams - CONTRACTOR
2012-10-31 22:04           ` Krzysztof Mazur
2012-11-01 14:26             ` chas williams - CONTRACTOR
2012-11-02  9:40               ` Krzysztof Mazur
2012-11-02 10:54                 ` Krzysztof Mazur
2012-10-22 17:14 ` [PATCH v2 3/3] pppoatm: protect against freeing " Krzysztof Mazur
2012-10-30  9:39   ` David Woodhouse
2012-10-30 19:26     ` Krzysztof Mazur
2012-11-27 17:16   ` David Woodhouse
2012-11-27 17:39     ` Krzysztof Mazur
2012-11-27 18:02       ` David Woodhouse
2012-11-27 18:28         ` Krzysztof Mazur
2012-11-28 20:18           ` Krzysztof Mazur
2012-11-28 20:44             ` David Woodhouse
2012-11-28 21:24               ` Krzysztof Mazur
2012-11-28 21:20             ` chas williams - CONTRACTOR
2012-11-28 21:45               ` [PATCH] atm: introduce vcc_pop() Krzysztof Mazur
2012-11-28 21:59                 ` chas williams - CONTRACTOR
2012-11-28 22:10                   ` Krzysztof Mazur
2012-11-28 22:33                     ` [PATCH] atm: introduce vcc_pop_skb() Krzysztof Mazur
2012-12-03 13:22                       ` David Woodhouse
2012-12-03 20:11                         ` Krzysztof Mazur [this message]
2012-11-27 18:39         ` [PATCH v2 3/3] pppoatm: protect against freeing of vcc Krzysztof Mazur
2012-11-27 18:54         ` chas williams - CONTRACTOR
2012-11-27 22:36           ` [PATCH] solos-pci: Wait for pending TX to complete when releasing vcc David Woodhouse
2012-11-27 23:28             ` [PATCH] br2684: don't send frames on not-ready vcc David Woodhouse
2012-11-27 23:51               ` Krzysztof Mazur
2012-11-28  0:54                 ` David Woodhouse
2012-11-28  8:08                   ` Krzysztof Mazur
2012-11-28  9:58                     ` David Woodhouse
2012-11-28 16:41               ` David Miller
2012-11-28 17:01                 ` David Woodhouse
2012-11-28 17:04                   ` David Miller
2012-11-28 17:09                     ` David Woodhouse
2012-11-28 17:11                       ` David Miller
2012-11-30  1:18                       ` Nathan Williams
2012-11-30  1:34                         ` David Woodhouse
2012-11-28  9:21           ` [PATCH v2 3/3] pppoatm: protect against freeing of vcc David Laight
2012-11-28 10:04             ` Krzysztof Mazur
2012-11-28 10:24               ` David Woodhouse
2012-11-28 15:18                 ` chas williams - CONTRACTOR
2012-11-28 22:18             ` David Woodhouse
2012-11-29 10:57               ` Krzysztof Mazur
2012-11-29 11:55                 ` David Woodhouse
2012-11-29 12:43                   ` [PATCH] solos-pci: don't call vcc->pop() after pclose() Krzysztof Mazur
2012-11-29 12:57                     ` David Woodhouse
2012-11-29 13:20                       ` Krzysztof Mazur
2012-11-29 14:42                         ` David Woodhouse
2012-11-29 14:55                           ` Krzysztof Mazur
2012-11-29 14:41                     ` chas williams - CONTRACTOR
2012-11-29 14:29                 ` [PATCH v2 3/3] pppoatm: protect against freeing of vcc chas williams - CONTRACTOR
2012-11-29 15:09               ` Krzysztof Mazur
2012-11-29 15:47                 ` David Woodhouse
2012-11-29 15:59                   ` chas williams - CONTRACTOR
2012-11-29 16:24                     ` David Woodhouse
2012-11-29 17:17                       ` chas williams - CONTRACTOR
2012-11-29 18:11                         ` David Woodhouse
2012-11-29 18:29                           ` chas williams - CONTRACTOR
2012-11-29 22:17                             ` David Woodhouse
2012-11-30  1:38                               ` Chas Williams (CONTRACTOR)
2012-11-30  1:57                                 ` David Woodhouse
2012-11-30  8:25                                   ` David Woodhouse
2012-11-30  9:53                                     ` Krzysztof Mazur
2012-11-30 12:10                                       ` David Woodhouse
2012-11-30 16:23                                         ` David Woodhouse
2012-11-30 17:00                                           ` Krzysztof Mazur
2012-11-30 18:33                                             ` David Woodhouse
2012-11-30 17:12                                           ` chas williams - CONTRACTOR
2012-11-30 17:39                                             ` Krzysztof Mazur
2012-11-29 16:28                   ` Krzysztof Mazur
2012-11-29 15:37               ` chas williams - CONTRACTOR
2012-11-29 15:59                 ` David Woodhouse
2012-11-29 16:11                   ` chas williams - CONTRACTOR
2012-10-23  6:52 ` [PATCH v2 1/3] pppoatm: don't send frames to destroyed vcc David Miller
2012-10-23  8:12   ` David Woodhouse
2012-10-30  9:35 ` David Woodhouse
2012-10-30 20:19   ` Krzysztof Mazur

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=20121203201118.GB19460@shrek.podlesie.net \
    --to=krzysiek@podlesie.net \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®