From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 27 07:00:33 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CBFF316A4CE for ; Wed, 27 Apr 2005 07:00:33 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B18743D5D for ; Wed, 27 Apr 2005 07:00:33 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j3R70XAF053307 for ; Wed, 27 Apr 2005 07:00:33 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j3R70Xxt053306; Wed, 27 Apr 2005 07:00:33 GMT (envelope-from gnats) Resent-Date: Wed, 27 Apr 2005 07:00:33 GMT Resent-Message-Id: <200504270700.j3R70Xxt053306@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andre Albsmeier Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F38D316A4CE for ; Wed, 27 Apr 2005 06:52:31 +0000 (GMT) Received: from thoth.sbs.de (thoth.sbs.de [192.35.17.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0ECCB43D62 for ; Wed, 27 Apr 2005 06:52:31 +0000 (GMT) (envelope-from Andre.Albsmeier@siemens.com) Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.12.6/8.12.6) with ESMTP id j3R6qTfc015493 for ; Wed, 27 Apr 2005 08:52:29 +0200 Received: from mars.cert.siemens.com (mars.cert.siemens.com [139.25.19.9]) by mail3.siemens.de (8.12.6/8.12.6) with ESMTP id j3R6qTXJ016482 for ; Wed, 27 Apr 2005 08:52:29 +0200 Received: from mail-ct.mchp.siemens.de (mail-ct.mchp.siemens.de [139.25.31.51]) mail/cert.mc.pre,v 1.66 2005/02/14 15:55:03 mailadm Exp $) with ESMTP id j3R6qTFK049398 for ; Wed, 27 Apr 2005 08:52:29 +0200 (CEST) Received: from curry.mchp.siemens.de (curry [139.25.42.7]) j3R6qS2W021675 for ; Wed, 27 Apr 2005 08:52:29 +0200 (MEST) Received: (from localhost) by curry.mchp.siemens.de (8.13.3/8.13.3) id j3R6qSdx041510 for FreeBSD-gnats-submit@freebsd.org; Wed, 27 Apr 2005 08:52:28 +0200 (CEST) Message-Id: <200504270652.j3R6qSxv038497@curry.mchp.siemens.de> Date: Wed, 27 Apr 2005 08:52:28 +0200 (CEST) From: Andre Albsmeier To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/80390: fstatfs() returns wrong flags or libexec/rtld-elf/rtld.c is broken X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2005 07:00:33 -0000 >Number: 80390 >Category: kern >Synopsis: fstatfs() returns wrong flags or libexec/rtld-elf/rtld.c is broken >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 27 07:00:32 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Andre Albsmeier >Release: FreeBSD 5.4-STABLE i386 >Organization: >Environment: FreeBSD 5.4-STABLE i386 used as NFS client >Description: On a FreeBSD 5.4-STABLE system fstatfs() used on an NFS mounted volume now returns the NFS mount option flags (as defined in sys/nfsclient/nfsargs.h) instead of the "normal" filesystem flags as defined in sys/sys/mount.h. This means that if you mount the remote fs with the -r (set read size) option set, fstatfs() will return a value with NFSMNT_RSIZE (0x00000004) set. However, libexec/rtld-elf/rtld.c uses the result of fstatfs() to determine if someone tried to circumvent a possibly set noexec flag on the filesystem, see http://www.freebsd.org/cgi/cvsweb.cgi/src/libexec/rtld-elf/rtld.c.diff?r1=1.104&r2=1.105 Therefore, an NFS fs which has been mounted using -r, appears to rtld.c as if the -o noexec option was given. >How-To-Repeat: Mount an NFS filesystem using -r on a 5.4-STABLE client. Try to build perl5.8 from ports on it (The perl build tries to execute some "LD_LIBRARY_PATH=blahblah ./miniperl ..." command which fails due to the MNT_NOEXEC seen by the linker). >Fix: "man fstatfs" clearly states that the returned flags are the "normal" filesystem flags as defined in sys/sys/mount.h. If it is intended that fstatfs() now returns the NFS mount option flags (as defined in sys/nfsclient/nfsargs.h), rtld.c and the fstatfs manpage must be fixed. Otherwise, the following patch restores the old behaviour as known from FreeBSD-4 and as documented in the manpage: --- sys/kern/vfs_syscalls.c.ORI Mon Feb 28 06:54:34 2005 +++ sys/kern/vfs_syscalls.c Wed Apr 27 08:44:26 2005 @@ -242,10 +242,10 @@ */ sp->f_version = STATFS_VERSION; sp->f_namemax = NAME_MAX; - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; error = VFS_STATFS(mp, sp, td); if (error) return (error); + sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; if (suser(td)) { bcopy(sp, &sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; @@ -293,10 +293,10 @@ */ sp->f_version = STATFS_VERSION; sp->f_namemax = NAME_MAX; - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; error = VFS_STATFS(mp, sp, td); if (error) return (error); + sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; if (suser(td)) { bcopy(sp, &sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; @@ -356,7 +356,6 @@ */ sp->f_version = STATFS_VERSION; sp->f_namemax = NAME_MAX; - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; /* * If MNT_NOWAIT or MNT_LAZY is specified, do not * refresh the fsstat cache. MNT_NOWAIT or MNT_LAZY @@ -370,6 +369,7 @@ vfs_unbusy(mp, td); continue; } + sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; if (suser(td)) { bcopy(sp, &sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; >Release-Note: >Audit-Trail: >Unformatted: