mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
Cc: Harald Welte <laforge@netfilter.org>, linux-kernel@vger.kernel.org
Subject: Re: seq_file and exporting dynamically allocated data
Date: Sat, 15 Nov 2003 21:30:53 +0000	[thread overview]
Message-ID: <20031115213053.GQ24159@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.44.0311152031590.743-100000@einstein.homenet>

On Sat, Nov 15, 2003 at 08:41:45PM +0000, Tigran Aivazian wrote:
> in fs/seq_file.c:seq_read()
> 
>         if (!m->buf) {
>                 m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);

... and below
                m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);

> are you saying that it is possible for userspace to request, say, 256K and 
> say 250K of available data could be returned (with seq_file API) on a 
> single read(2) call? I thought this is impossible and hence in the 

> So, as soon as ->show() is asked to display an element which didn't fit in
> the m->buf page it returns -1 and so the user gets a page (or almost a
> page, i.e.  as many entries as fit in there).

a) it's not a page; if any ->show() will need more, buffer will grow.

b) unless you are willing to allocate 250Kb per read(), you *can't* do
what you are asking for.  Regardless of implementation.  Which is an
immediate DoS (again, regardless of implementation).

read() is not atomic.  Never had been.  With seq_file you are guaranteed
that what you get will consist of entire entries (IOW, if previous read()
had ended inside the entry, the rest will be preserved for the next read()).
There are no stronger warranties and there never had been.

  reply	other threads:[~2003-11-15 21:30 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-14 20:42 Harald Welte
2003-11-14 21:01 ` Tigran Aivazian
2003-11-15  9:38   ` Harald Welte
2003-11-15 17:18     ` viro
2003-11-15 17:33       ` Harald Welte
2003-11-15 19:49         ` Tigran Aivazian
2003-11-15 20:14           ` viro
2003-11-15 20:41             ` Tigran Aivazian
2003-11-15 21:30               ` viro [this message]
2003-11-15 20:50             ` Tigran Aivazian
2003-11-15 21:33               ` viro
2003-11-15 21:54                 ` Tigran Aivazian
2003-11-16  7:27                   ` Tigran Aivazian
2003-11-17  5:48                     ` viro
2003-11-17  8:21                       ` Tigran Aivazian
2003-11-17  8:30                         ` William Lee Irwin III
2003-11-17  8:38                           ` Tigran Aivazian
2003-11-17  8:48                             ` William Lee Irwin III
2003-11-17  9:03                               ` William Lee Irwin III
2003-11-17  9:42                                 ` Tigran Aivazian
2003-11-17  9:50                                   ` William Lee Irwin III
2003-11-17  9:55                                   ` viro
2003-11-17 10:08                                     ` Tigran Aivazian
2003-11-17 10:35                                       ` viro
2003-11-17  9:48                                 ` viro
2003-11-16 20:45               ` Harald Welte
2003-11-15 20:36         ` viro
2003-11-16 20:42           ` Harald Welte

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=20031115213053.GQ24159@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=laforge@netfilter.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tigran@aivazian.fsnet.co.uk \
    /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

Powered by JetHome