From owner-freebsd-bugs Mon Apr 29 1:20:24 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id BD39D37B416 for ; Mon, 29 Apr 2002 01:20:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3T8K1S95863; Mon, 29 Apr 2002 01:20:01 -0700 (PDT) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 84CB637B404 for ; Mon, 29 Apr 2002 01:11:23 -0700 (PDT) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3T8BNi94570; Mon, 29 Apr 2002 01:11:23 -0700 (PDT) (envelope-from nobody) Message-Id: <200204290811.g3T8BNi94570@freefall.freebsd.org> Date: Mon, 29 Apr 2002 01:11:23 -0700 (PDT) From: Peter Edwards To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: kern/37554: [PATCH] Make ELF shared libraries immutable once loaded (like executables) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 37554 >Category: kern >Synopsis: [PATCH] Make ELF shared libraries immutable once loaded (like executables) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Apr 29 01:20:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Peter Edwards >Release: 4-STABLE >Organization: >Environment: FreeBSD rocklobster 4.5-STABLE FreeBSD 4.5-STABLE #30: Mon Apr 29 08:00:03 IST 2002 petere@rocklobster:/pub/FreeBSD/work/src/sys/compile/ROCKLOBSTER i386 >Description: Before executing a program, the kernel marks the executable file as immutable by setting the VTEXT flag in its vnode. This makes write operations return with ETXTBSY when attempted. However, no such flag is set for shared libraries mapped by rtld. This patch adds a new fcntl command, F_TXTBSY, which sets the VTEXT flag in the vnode associated with the file, and gets rtld-elf to make use of it. There may be security issues here, allowing user code to set this flag in contexts it wasn't designed for, but I don't think it allows you do anything that you couldn't already. You can't stop someone creating a custom executable in order to get VTEXT set on it anyway, and root can always kill any processes holding the object in memory to clear the flag if neccessary. >How-To-Repeat: Write a program that depends on a shared library, and overwrite that library while the program is running. Bad Things happen. Trying the same on an executable results in the write operation returning ETXTBSY >Fix: Apply the following patch. begin 644 shlib-textbusy.tar.Z M26YD97@Z(&QI8F5X96,OPDO*B!& M:7)S="!UPI);F1E M>#H@7,O:V5R;B]K97)N7V1E#H@7,O9F-N=&PN:`DS($IU M;B`R,#`Q(#`U.C`P.C$P("TP,#`P"3$N.2XR+C(**RLK('-Y7,O9F-N M=&PN:`DR.2!!<'(@,C`P,B`P-SHS,3HR-2`M,#`P,`I`0"`M,32!F:6QE('-E9VUE;G0@;&]C M:VEN9R!D871A('1Y<&4@+0H@("H@:6YF;W)M871I;VX@<&%S2!URelease-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message