kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Sahibzada Irfanullah <irfan.gomalian@gmail.com>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: Fwd: Need Help regarding Reading and Writting to a file from kernel function file
Date: Tue, 24 Sep 2019 09:35:35 +0200	[thread overview]
Message-ID: <20190924073535.GA489411@kroah.com> (raw)
In-Reply-To: <CAGaWEbr96h+Bi4qmP-1Wse+wk=r4Us3CeDY3AXO6xR+_QceNKw@mail.gmail.com>

On Tue, Sep 24, 2019 at 04:10:07PM +0900, Sahibzada Irfanullah wrote:
> Dear Sir,
> Hope you are doing well. Actually, I have one problem metioned in the
> subject line. The problem is:  I am trying to write/read page faulted
> physical addresses to a file in a kernel (v5.3-1) function, i.e.,
> handle_ept_violation() which is present in vmx.c. I have followed this
> <https://stackoverflow.com/questions/1184274/read-write-files-within-a-linux-kernel-module>,
> it's working as a standalone kernel module when I load/unload this kernel
> module, but when I try to use this code in the handle_ept_violation()
> function, I can't able to open the file and get the error codes, i.e., -2,
> -3, or -13. It's compiled successfully but generate the error at runtime. I
> searched for error codes online but I didn't find any help.
> Can anyone please provide me with any good guidlines, or links where I can
> start and solve this problem in a fast way.

Please do not try to read or write a file from within the kernel, that
way almost always lies madness and major problems.

Step back and try to describe the problem you are attempting to solve
here first.  Odds are it can be done in a much better way.

Also, do you have a pointer to your code anywhere?

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2019-09-24  7:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGaWEbomboZ=MCT4GaKj+5tUNDGc5ZknvhLTikCPSWpjY5E7hA@mail.gmail.com>
2019-09-24  7:10 ` Fwd: Need Help regarding Reading and Writting to a file from kernel function file Sahibzada Irfanullah
2019-09-24  7:35   ` Greg KH [this message]
2019-09-24  8:48   ` Valdis Klētnieks
2019-09-24  9:51     ` Saket Sinha
2019-09-24 13:32       ` Greg KH
2019-09-24 10:02     ` Martin Christian

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=20190924073535.GA489411@kroah.com \
    --to=greg@kroah.com \
    --cc=irfan.gomalian@gmail.com \
    --cc=kernelnewbies@kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).