mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@clusterfs.com>
To: il boba <il_boba@hotmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: what`s wrong?
Date: Wed, 24 Apr 2002 10:40:56 -0600	[thread overview]
Message-ID: <20020424164056.GA15812@turbolinux.com> (raw)
In-Reply-To: <F218eE3VsX7PVTdAMDm0000842f@hotmail.com>

On Apr 24, 2002  18:06 +0200, il boba wrote:
> Is there anybody that can help me understand what`s wrong with this code?

Yes, easily spotted a major problem without even reading the whole
thing.

> #define BUFSIZ 8192
> 
> int init_module()
> {
>  int err_frame[BUFSIZ];

The entire kernel stack is only 8kB in size.  You have already killed
a bunch of random memory by allocating this much memory on the stack.
You allocated 4*8192 = 32kB on the stack here.

> #if CONFIG_MODVERSIONS==1
> #define MODVERSIONS
> #include <linux/modversions.h>
> #endif

You shouldn't do things like this.  Rather have a makefile which sets
the correct defines.

> int init_err_frame(int err_frame[]) {
>  int i, k = 0, j = 0;
>  char buffer[BUFSIZ];

Another 8kB on the stack here - further random corruption.

>  struct file * f = 
> filp_open("/usr/src/kernel-source-2.2.19/pinux/misc/err_file", 0, 0);  /* i 
> want it only readable */

More clear to add "O_RDONLY" to filp_open, even though it is still 0.

>  if (f == '\0'){
>       printk ("errore nell' APERTURA del file d'errore");
>       return -1;
>  }

How about "if (f == NULL)"?

>  if ((generic_file_read(f, buffer, BUFSIZ, &f->f_pos)) < 0 ){

Calling generic_file_read() may work in some cases, but not others.  It
depends on the filesystem.  Use "f->f_op->read" instead.

Cheers, Andreas
--
Andreas Dilger
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/


  reply	other threads:[~2002-04-24 16:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-24 16:06 il boba
2002-04-24 16:40 ` Andreas Dilger [this message]
2002-04-25  0:42   ` Jerry Cooperstein

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=20020424164056.GA15812@turbolinux.com \
    --to=adilger@clusterfs.com \
    --cc=il_boba@hotmail.com \
    --cc=linux-kernel@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®