mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jon Smirl" <jonsmirl@gmail.com>
To: "Sergey Vlasov" <vsu@altlinux.ru>
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org, stable@kernel.org
Subject: Re: [patch 03/26] sysfs: zero terminate sysfs write buffers (CVE-2006-1055)
Date: Wed, 5 Apr 2006 11:30:54 -0400	[thread overview]
Message-ID: <9e4733910604050830x2daf2ec1vd1fe16073b51de8c@mail.gmail.com> (raw)
In-Reply-To: <20060405190928.17b9ba6a.vsu@altlinux.ru>

On 4/5/06, Sergey Vlasov <vsu@altlinux.ru> wrote:
> On Tue, 4 Apr 2006 16:59:47 -0700 gregkh@suse.de wrote:
>
> > No one should be writing a PAGE_SIZE worth of data to a normal sysfs
> > file, so properly terminate the buffer.
> >
> > Thanks to Al Viro for pointing out my stupidity here.
> >
> > CVE-2006-1055 has been assigned for this.
> >
> > Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
> >
> > ---
> >  fs/sysfs/file.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > --- linux-2.6.16.1.orig/fs/sysfs/file.c
> > +++ linux-2.6.16.1/fs/sysfs/file.c
> > @@ -183,7 +183,7 @@ fill_write_buffer(struct sysfs_buffer *
> >               return -ENOMEM;
> >
> >       if (count >= PAGE_SIZE)
> > -             count = PAGE_SIZE;
> > +             count = PAGE_SIZE - 1;
> >       error = copy_from_user(buffer->page,buf,count);
> >       buffer->needs_read_fill = 1;
> >       return error ? -EFAULT : count;
>
> This will break the "color_map" sysfs file for framebuffers -
> drivers/video/fbsysfs.c:store_cmap() expects to get exactly 4096 bytes
> for a colormap with 256 entries.  In fact, the original patch which
> changed PAGE_SIZE - 1 to PAGE_SIZE:
>
> http://kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9d9d27fb651a7c95a46f276bacb4329db47470a6
>
> was done exactly for use with that "color_map" file.
>
> This patch also does not completely guarantee that the buffer will be
> null-terminated.  A program may first call read() on the sysfs file,
> which will allocate buffer->page and invoke ->show to fill that page;
> then subsequent write() on the same file will reuse buffer->page.  To
> get really bad results, you need to have ->store which assumes
> null-terminated buffer together with ->show which writes to the last
> byte of the page (which is probably rare, but show_cmap() does exactly
> that).
>

That is correct, that the color_map attribute will break. Color_map is
not in general use outside the Mesa development community.

The whole scheme of using sysfs instead of IOCTLs is not working out
very well for framebuffer. The original idea was to let you control
your framebuffer with simple scripts or from the keyboard. But since
the attributes don't strip \n and blanks, it has made them more
complex to use from the keyboard.

The one attribute per file model doesn't work well when the attributes
need to be changed in a transaction. For example you want to change
your display to 1024x768 16bit color.  As you set the attributes one
at a time the display has to change since there is not guarantee that
you will complete the sequence. The framebuffer sysfs interface breaks
the one attribute per file rule and uses strings for grouped
attributes.

Ultimately I expect framebuffer will switch back to a helper app and
binary IOCTLs. Mainly because the help app can signal begin/end around
a change to a group of attributes.

--
Jon Smirl
jonsmirl@gmail.com

  parent reply	other threads:[~2006-04-05 15:30 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060404235634.696852000@quad.kroah.org>
2006-04-04 23:59 ` [patch 00/26] 2.6.16.2 -stable review gregkh
2006-04-04 23:59   ` [patch 01/26] tlclk: fix handling of device major gregkh
2006-04-04 23:59   ` [patch 02/26] USB: Fix irda-usb use after use gregkh
2006-04-05  0:16     ` David S. Miller
2006-04-06  0:55       ` [stable] " Greg KH
2006-04-05  0:22     ` Randy.Dunlap
2006-04-04 23:59   ` [patch 03/26] sysfs: zero terminate sysfs write buffers (CVE-2006-1055) gregkh
2006-04-05 15:09     ` Sergey Vlasov
2006-04-05 15:21       ` Al Viro
2006-04-05 15:38         ` Jon Smirl
2006-04-05 15:39           ` Al Viro
2006-04-05 15:43             ` Jon Smirl
2006-04-05 15:46               ` Al Viro
2006-04-05 16:18                 ` Jon Smirl
2006-04-05 17:04                   ` Al Viro
2006-04-05 19:58             ` Valdis.Kletnieks
2006-04-05 20:07               ` Greg KH
2006-04-06  1:05               ` Al Viro
2006-04-05 16:34         ` Jon Smirl
2006-04-05 17:02           ` Al Viro
2006-04-05 17:06             ` Jon Smirl
2006-04-05 17:27               ` Al Viro
2006-04-05 15:30       ` Jon Smirl [this message]
2006-04-05 18:52         ` [stable] " Greg KH
2006-04-04 23:59   ` [patch 04/26] USB: EHCI full speed ISO bugfixes gregkh
2006-04-04 23:59   ` [patch 05/26] USB: usbcore: usb_set_configuration oops (NULL ptr dereference) gregkh
2006-04-05  0:00   ` [patch 06/26] sbp2: fix spinlock recursion gregkh
2006-04-05  0:00   ` [patch 07/26] powerpc: make ISA floppies work again gregkh
2006-04-05  0:00   ` [patch 08/26] PCMCIA_SPECTRUM must select FW_LOADER gregkh
2006-04-05  0:00   ` [patch 09/26] pcmcia: permit single-character-identifiers gregkh
2006-04-05  0:00   ` [patch 10/26] opti9x - Fix compile without CONFIG_PNP gregkh
2006-04-05  0:00   ` [patch 11/26] IPOB: Move destructor from neigh->ops to neigh_param gregkh
2006-04-05  0:07     ` David S. Miller
2006-04-05  0:12       ` [stable] " Greg KH
2006-04-05  0:14       ` Roland Dreier
2006-04-05  0:17         ` David S. Miller
2006-04-05  0:42           ` Roland Dreier
2006-04-05  0:47             ` David S. Miller
2006-04-05  1:08               ` Roland Dreier
2006-04-05  7:58               ` Michael S. Tsirkin
2006-04-05  0:00   ` [patch 12/26] Mark longhaul driver as broken gregkh
2006-04-05  0:00   ` [patch 13/26] isicom must select FW_LOADER gregkh
2006-04-05  0:00   ` [patch 14/26] {ip, nf}_conntrack_netlink: fix expectation notifier unregistration gregkh
2006-04-05  0:00   ` [patch 15/26] wrong error path in dup_fd() leading to oopses in RCU gregkh
2006-04-05  0:00   ` [patch 16/26] Fix the p4-clockmod N60 errata workaround gregkh
2006-04-05  0:00   ` [patch 17/26] Fix module refcount leak in __set_personality() gregkh
2006-04-05  0:00   ` [patch 18/26] fib_trie.c node freeing fix gregkh
2006-04-05  0:01   ` [patch 19/26] fbcon: Fix big-endian bogosity in slow_imageblit() gregkh
2006-04-05  0:01   ` [patch 20/26] drivers/net/wireless/ipw2200.c: fix an array overun gregkh
2006-04-05  0:01   ` [patch 21/26] Fix NULL pointer dereference in node_read_numastat() gregkh
2006-04-05  0:01   ` [patch 22/26] AIRO{,_CS} <-> CRYPTO fixes gregkh
2006-04-05  0:01   ` [patch 23/26] Add default entry for CTL Travel Master U553W gregkh
2006-04-05  0:01   ` [patch 24/26] hostap: Fix EAPOL frame encryption gregkh
2006-04-05  0:01   ` [patch 25/26] knfsd: Correct reserved reply space for read requests gregkh
2006-04-05  0:01   ` [patch 26/26] kdump proc vmcore size oveflow fix gregkh

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=9e4733910604050830x2daf2ec1vd1fe16073b51de8c@mail.gmail.com \
    --to=jonsmirl@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.org \
    --cc=vsu@altlinux.ru \
    /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®