From: levonshe@yandex.com (Lev Olshvang)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Why replacing running executable file is forbidden, but overwriting of memory mapped shared object is allowed ?
Date: Fri, 10 Nov 2017 21:04:22 +0300 [thread overview]
Message-ID: <489841510337062@web43g.yandex.ru> (raw)
In-Reply-To: <16969.1510331047@turing-police.cc.vt.edu>
10.11.2017, 19:24, "valdis.kletnieks at vt.edu" <valdis.kletnieks@vt.edu>:
> On Fri, 10 Nov 2017 16:30:17 +0300, Lev Olshvang said:
>
>> ?But the attempt to replace shared object library succeeded, and I do not
>> ?understand the logic of this decision
>
> You might want to do an lsof after such an upgrade, and ponder what
> *really* happened.
>
> Hint 1: How do you do this in a way that doesn't break currently running binaries?
>
> Hint 2: Do you see the string '(deleted)' in the lsof output? What does it mean?
>
>> ??I want to patch my kernel to forbid shared objects live replacement. ( as I
>> ?said I worry about security issue)
>
> Attackers doing that is the least of your problems. If your system is
> correctly set up, if an attacker manages to get to a point where this attack is
> feasible, you're *already* in deep trouble even before they do a live
> replacement.
>
> For bonus points - you're probably worrying about the wrong security issue,
> because you're probably only thinking about the *obvious* problem. The trouble
> is that even if you forbid live replacement of a .so, that's *not* the only
> attack surface.
>
> Phrack ran an interesting article many years ago on how to inject a module into
> a Linux kernel *even if the kernel was built with CONFIG_MODULE=n*.
>
> http://phrack.org/issues/58/7.html#article
>
> (The important part isn't the exact mechanism - that SucKIT code from 16
> years ago probably won't work on a 4.14 kernel. But it illustrates the out-of-box
> thinking the attacker can use - and that you'll have to defend against.
>
> How did Emacs in times gone by do an 'unexec()' to write out an executable
> image of itself, as the state was after startup?
>
> What can you over-write by setting /proc/sys/kernel/core_pattern, forking,
> and then forcing a coredump in the child process?
>
> Can you combine the techniques to splat a .so that's currently in use?
>
> ,
Hi Valdis,
Thank you for prompt response.
I am afraid you did not quite understand my question.
I am going to patch inode reference count of mapped shared libs to disable overwrite because I do not see any other
solution giving requirements I got - prevent overwrite by simple tools like dd.
I agree with you that is is this is not enough to protect the system, but this is just one line of defense.
I understand that it is hard to not crash running executable by changing lib under the hood, but hackers can repedeately crash
programs until desired result achieved.
I am not seasoned kernel developer, there are a lot of things do not know about kernel.
I would like to consult with list whether increment inode nlink_count in shared libraries in the same way is done for
executable will break things in kernel.
next prev parent reply other threads:[~2017-11-10 18:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 13:30 Why replacing running executable file is forbidden, but overwriting of memory mapped shared object is allowed ? Lev Olshvang
2017-11-10 14:52 ` Ricardo Ribalda Delgado
2017-11-10 16:24 ` valdis.kletnieks at vt.edu
2017-11-10 18:04 ` Lev Olshvang [this message]
2017-11-10 19:04 ` valdis.kletnieks at vt.edu
2017-11-14 11:18 ` Lev Olshvang
2017-11-14 16:59 ` valdis.kletnieks at vt.edu
2017-11-10 17:49 ` Jeffrey Walton
2017-11-10 22:43 ` Ruben Safir
2017-11-11 0:05 ` valdis.kletnieks at vt.edu
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=489841510337062@web43g.yandex.ru \
--to=levonshe@yandex.com \
--cc=kernelnewbies@lists.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).