netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Kees Cook <keescook@chromium.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Salvatore Mesoraca <s.mesoraca16@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	David Laight <David.Laight@aculab.com>
Subject: Re: [PATCH v2] net: dsa: Remove VLA usage
Date: Sun, 29 Jul 2018 13:40:06 +0200	[thread overview]
Message-ID: <20180729114006.GA11104@amd> (raw)
In-Reply-To: <20180729113806.GC7333@amd>

[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]

Hi!

> > We avoid 2 VLAs by using a pre-allocated field in dsa_switch. We also
> > try to avoid dynamic allocation whenever possible (when using fewer than
> > bits-per-long ports, which is the common case).
> > 
> > Link: http://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
> > Link: http://lkml.kernel.org/r/20180505185145.GB32630@lunn.ch
> > Signed-off-by: Salvatore Mesoraca <s.mesoraca16@gmail.com>
> > [kees: tweak commit subject and message slightly]
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > ---
> >  include/net/dsa.h |  3 +++
> >  net/dsa/dsa2.c    | 14 ++++++++++++++
> >  net/dsa/switch.c  | 22 ++++++++++------------
> >  3 files changed, 27 insertions(+), 12 deletions(-)
> > 
> > diff --git a/include/net/dsa.h b/include/net/dsa.h
> > index fdbd6082945d..461e8a7661b7 100644
> > --- a/include/net/dsa.h
> > +++ b/include/net/dsa.h
> > @@ -259,6 +259,9 @@ struct dsa_switch {
> >  	/* Number of switch port queues */
> >  	unsigned int		num_tx_queues;
> >  
> > +	unsigned long		*bitmap;
> > +	unsigned long		_bitmap;
> 
> This looks rather confusing. _bitmap -> bitmap_data? bitmap_bits?

Actually, AFAICT that long is not used as a long, but as array of
bits. So maybe char bitmap_data[8] would be more appropriate?

(resend, now with right cc list).
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2018-07-29 11:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  4:10 [PATCH v2] net: dsa: Remove VLA usage Kees Cook
2018-07-18 20:33 ` David Miller
2018-07-18 20:37   ` Andrew Lunn
2018-07-18 22:08     ` David Miller
2018-07-29 11:38 ` Pavel Machek
2018-07-29 11:40   ` Pavel Machek [this message]
2018-07-30  8:59     ` David Laight

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=20180729114006.GA11104@amd \
    --to=pavel@ucw.cz \
    --cc=David.Laight@aculab.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=s.mesoraca16@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).