mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: "Andrew V. Samoilov" <kai@cmail.ru>
Cc: linux-kernel@vger.kernel.org
Subject: Re: mmap successed but SIGBUS generated on access
Date: Wed, 19 Sep 2001 14:00:58 +0100	[thread overview]
Message-ID: <20010919140058.B21005@kushida.degree2.com> (raw)
In-Reply-To: <200109191036.f8JAa9J20856@cmail.ru>
In-Reply-To: <200109191036.f8JAa9J20856@cmail.ru>; from kai@cmail.ru on Wed, Sep 19, 2001 at 02:36:10PM +0400

Andrew V. Samoilov wrote:
> I have bad CD-R with a some number of unreadable files.
> 
> Then user-space program use mmap system it returns ok but any
> attempt to access a memory pointed by this system call finishes 
> with SIGBUS. So Midnight Commander internal file viewer faults.

You can get the same problem even without read errors with some
configurations of NFS.  (root mmaps a file owned by someone else, but
cannot read the file due to `root_squash' on server).

> This error is 100 % reproduceable at 2.2.19 and 2.4.2 kernels.

It's not an error, it's standard behaviour.

> Is there any way to detect such problem in user-space without signal
> handlers ?

I don't think there is any way without a signal handler.

It is possible to do something useful with a signal handler sometimes.
For example, you can mmap() a zero page into the offending page once
you've got the fault address, or read() a zero page if you did
MAP_PRIVATE (this produces fewer VMAs), set a flag, and let the program
continue until it checks the flag and aborts the parsing or whatever
operation it's doing.

Unfortunately I don't think the signal handler's si_errno is set
properly to indicate the error.  So another thing to try is read() of
the offending page, to get a useful error code.  (And if the read
succeeds, that's ok because you did it at the correct address so the
program can proceed anyway).

Fwiw, unfortunately not all versions of the kernel, or all
architectures, set si_addr properly for SIGBUS.

enjoy,
-- Jamie

  reply	other threads:[~2001-09-19 13:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-19 10:36 Andrew V. Samoilov
2001-09-19 13:00 ` Jamie Lokier [this message]
2001-09-19 16:57 Andrew V. Samoilov
2001-09-19 22:51 ` Jamie Lokier

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=20010919140058.B21005@kushida.degree2.com \
    --to=lk@tantalophile.demon.co.uk \
    --cc=kai@cmail.ru \
    --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

Powered by JetHome