From owner-freebsd-arch Sun Sep 8 3: 8:10 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A770C37B400; Sun, 8 Sep 2002 03:08:04 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7395B43E42; Sun, 8 Sep 2002 03:08:03 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA29092; Sun, 8 Sep 2002 20:07:56 +1000 Date: Sun, 8 Sep 2002 20:15:33 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Garrett Wollman Cc: jmallett@FreeBSD.ORG, Subject: Re: CFR: signalinfo(3) In-Reply-To: <200209071711.g87HBLxO048550@khavrinen.lcs.mit.edu> Message-ID: <20020908195306.N2533-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, 7 Sep 2002, Garrett Wollman wrote: > In article <20020907022003.A66983@FreeBSD.org> you write: > > >See, signal(3) installs handlers for the sa_handler variety of signal > >handlers, and yet this is not the only type of handler one might want > >to have, one might also want the "traditional" sa_sigaction handler > >style, which includes siginfo_t, and struct sigcontext, both of which > >are very useful, depending on the signal. > > Actually, those are new-style (POSIX Real-Time Signals) handlers. The > traditional (Standard C) style takes a single argument. The > really-old-fashioned (4.2BSD, pre-C89) handlers provided three > arguments but they weren't the same as the three arguments used in > RTS handlers and in any case we don't support that now. We still support 2 of the args of 4.2BSD handlers in a binary compatible way, at least on i386's. All signal handlers get passed extra args no matter how they are declared. 4.2BSD args: int signum, int sigcode, struct sigcontext *scp FreeBSD-old args: same FreeBSD-not-so-old args: int signum, int sigcode, struct sigcontext *scp, vm_offset_t faultaddr FreeBSD args: int signum, siginfo_t *sip, struct sigcontext *scp, vm_offset_t faultaddr In -current, SA_SIGINFO just causes sip to be non-NULL. In my test, sip pointed to not very interesting and apparently broken info: % Program received signal SIGUSR1, User defined signal 1. % 0x280a5963 in kill () from /usr/lib/libc.so.5 % (gdb) c % Continuing. % % Breakpoint 1, sig (code=30, sip=0xbfbff84c, scp=0xbfbff708, addr=0) at z.c:7 % 7 } % (gdb) where % #0 sig (code=30, sip=0xbfbff84c, scp=0xbfbff708, addr=0) at z.c:7 % #1 % #2 0x280a5963 in kill () from /usr/lib/libc.so.5 % #3 0x080484e1 in _start () % (gdb) p *sip % $1 = {si_signo = 30, si_errno = 0, si_code = 0, si_pid = 0, si_uid = 0, % si_status = 0, si_addr = 0x2, si_value = {sigval_int = 0, sigval_ptr = 0x0}, % si_band = 0, __spare__ = {0, 0, 0, 0, 0, 0, 0}} I expected at least si_pid and si_uid to be nonzero here. > >So I wrote signalinfo(3) > >which installs *those* kinds of signal handlers, no fuss. > > I'm confused. Why would you want to use this? There is already a > perfectly good interface for installing Real-Time Signal handlers, > and it's specified in the standard: sigaction(3). I don't think > that this convenience function belongs in the C library. I agree. There are approximately 2^( + ) convenience functions that can be built from sigaction(). Which ones are actually convenient is application-specific. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Sun Sep 8 7:38:53 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F3BD237B400; Sun, 8 Sep 2002 07:38:34 -0700 (PDT) Received: from chat.ru (171-175.dialup.permonline.ru [212.120.171.175]) by mx1.FreeBSD.org (Postfix) with SMTP id CF5D043E3B; Sun, 8 Sep 2002 07:37:56 -0700 (PDT) (envelope-from golden_st@rambler.ru) From: Василий Subject: Ваша заработная плата! Reply-To: golden_st@rambler.ru X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.5 Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1251" Date: Sun, 8 Sep 2002 20:45:41 +0600 Message-Id: <20020908143756.CF5D043E3B@mx1.FreeBSD.org> To: undisclosed-recipients: ; Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Здравствуйте, извините если я Вас отвлёк от важных государственных дел. Просто я хотел бы предложить Вам заработать на чай, кофе, потанцуем или на пиво, водка, полежим (каждому своё) Несмотря на то, что это всетаки пирамидка. С неё можно реально зарабатывать в месяц от 1000руб. Это не золотые горы, но зато надёжно. Если вам это интересно, то пишите, а если нет, то извините за беспокойство. Продолжайте заниматься важными государственными делами. С уважением, Василий. PS: Я лично зарабатываю 500-1500руб в месяц To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Sun Sep 8 18:40:14 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D231637B400 for ; Sun, 8 Sep 2002 18:40:10 -0700 (PDT) Received: from sccrmhc01.attbi.com (sccrmhc01.attbi.com [204.127.202.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id 552CD43E3B for ; Sun, 8 Sep 2002 18:40:10 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by sccrmhc01.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020909014009.GYXL9751.sccrmhc01.attbi.com@InterJet.elischer.org>; Mon, 9 Sep 2002 01:40:09 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id SAA54038; Sun, 8 Sep 2002 18:27:44 -0700 (PDT) Date: Sun, 8 Sep 2002 18:27:42 -0700 (PDT) From: Julian Elischer To: Jeff Roberson Cc: arch@freebsd.org Subject: UMA locks In-Reply-To: <20020822200207.S57142-100000@mail.chesapeake.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Is there a reason that the UMA CPU lock is a sleep lock? how log is it held? I would think it would only be held for brief moments? (e.g. to grab the per-cpu bucket list to do some work on it) Because it is a sleep lock, callers with the sched lock must drop it to free things (such as thread structures). I have a 'sidestep' around this but it requires holding my own global queue of freed threads (with its own spin lock) to hold freed items until I can get out enough to actually free them. The UMA code is so central to all sorts of other modules that if you briefly need a lock to manipulate it's per-cpu structures, it is possible a spinlock might be a better choice. (depending on how long you hold it for.) just a thought. julian To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Sun Sep 8 18:42: 8 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E060B37B400 for ; Sun, 8 Sep 2002 18:42:06 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id A650643E65 for ; Sun, 8 Sep 2002 18:42:06 -0700 (PDT) (envelope-from baka@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1921) id 6E416AE1C1; Sun, 8 Sep 2002 18:42:06 -0700 (PDT) Date: Sun, 8 Sep 2002 18:42:06 -0700 From: Jon Mini To: Julian Elischer Cc: Jeff Roberson , arch@FreeBSD.ORG Subject: Re: UMA locks Message-ID: <20020909014206.GY7265@elvis.mu.org> References: <20020822200207.S57142-100000@mail.chesapeake.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Julian Elischer [julian@elischer.org] wrote : > The UMA code is so central to all sorts of other modules that > if you briefly need a lock to manipulate it's per-cpu structures, > it is possible a spinlock might be a better choice. > (depending on how long you hold it for.) Being able to uma_free while holding a spinlock would be very nice. -- Jonathan Mini http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Sun Sep 8 19:20:15 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF48637B40E; Sun, 8 Sep 2002 19:20:10 -0700 (PDT) Received: from rwcrmhc51.attbi.com (rwcrmhc51.attbi.com [204.127.198.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id DDB9143E3B; Sun, 8 Sep 2002 19:20:09 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc51.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020909022008.PVRI19682.rwcrmhc51.attbi.com@InterJet.elischer.org>; Mon, 9 Sep 2002 02:20:08 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id TAA54252; Sun, 8 Sep 2002 19:17:22 -0700 (PDT) Date: Sun, 8 Sep 2002 19:17:21 -0700 (PDT) From: Julian Elischer To: Jon Mini Cc: Jeff Roberson , arch@FreeBSD.ORG Subject: Re: UMA locks In-Reply-To: <20020909014206.GY7265@elvis.mu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 8 Sep 2002, Jon Mini wrote: > Julian Elischer [julian@elischer.org] wrote : > > > The UMA code is so central to all sorts of other modules that > > if you briefly need a lock to manipulate it's per-cpu structures, > > it is possible a spinlock might be a better choice. > > (depending on how long you hold it for.) > > Being able to uma_free while holding a spinlock would be very nice. of course we could always drop schedlock in thread_exit(), or do what we do do, which is call thread_stash() instead of thread_free() when we want to free the spare thread td_spare, but then we are doing EXTRA locking ops... hmm schedlock is being helppd for some quite long periods. It's probably worth looking at it some time.. > > -- > Jonathan Mini > http://www.freebsd.org/ > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Mon Sep 9 0:31:25 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DBD7937B400; Mon, 9 Sep 2002 00:31:22 -0700 (PDT) Received: from mail.chesapeake.net (chesapeake.net [205.130.220.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 221BB43E4A; Mon, 9 Sep 2002 00:31:22 -0700 (PDT) (envelope-from jroberson@chesapeake.net) Received: from localhost (jroberson@localhost) by mail.chesapeake.net (8.11.6/8.11.6) with ESMTP id g897VCT22529; Mon, 9 Sep 2002 03:31:12 -0400 (EDT) (envelope-from jroberson@chesapeake.net) Date: Mon, 9 Sep 2002 03:31:12 -0400 (EDT) From: Jeff Roberson To: Julian Elischer Cc: Jon Mini , Subject: Re: UMA locks In-Reply-To: Message-ID: <20020909032849.W47384-100000@mail.chesapeake.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 8 Sep 2002, Julian Elischer wrote: > > > On Sun, 8 Sep 2002, Jon Mini wrote: > > > Julian Elischer [julian@elischer.org] wrote : > > > > > The UMA code is so central to all sorts of other modules that > > > if you briefly need a lock to manipulate it's per-cpu structures, > > > it is possible a spinlock might be a better choice. > > > (depending on how long you hold it for.) > > > > Being able to uma_free while holding a spinlock would be very nice. > > of course we could always drop schedlock in thread_exit(), > or do what we do do, which is call thread_stash() instead of thread_free() > when we want to free the spare thread td_spare, but then we are doing > EXTRA locking ops... hmm > > schedlock is being helppd for some quite long periods. > It's probably worth looking at it some time.. > > I believe it is safe to turn uma per cpu locks into spin locks now. Go ahead and try and do some perf runs with it. The changes should be completely localized in uma_int.h. Look for the locking macros at the bottom. Jeff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 6:57:44 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C651F37B40A; Tue, 10 Sep 2002 06:57:34 -0700 (PDT) Received: from baraca.united.net.ua (ns.united.net.ua [193.111.8.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id DDFA143E8A; Tue, 10 Sep 2002 06:57:13 -0700 (PDT) (envelope-from sobomax@FreeBSD.org) Received: from vega.vega.com (xDSL-2-2.united.net.ua [193.111.9.226]) by baraca.united.net.ua (8.11.6/8.11.6) with ESMTP id g8ADunS65166; Tue, 10 Sep 2002 16:56:50 +0300 (EEST) (envelope-from sobomax@FreeBSD.org) Received: from FreeBSD.org (big_brother.vega.com [192.168.1.1]) by vega.vega.com (8.12.5/8.12.5) with ESMTP id g8ADuj1X002617; Tue, 10 Sep 2002 16:56:45 +0300 (EEST) (envelope-from sobomax@FreeBSD.org) Message-ID: <3D7DFA6B.566DC85B@FreeBSD.org> Date: Tue, 10 Sep 2002 16:58:03 +0300 From: Maxim Sobolev Organization: Vega International Capital X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en,uk,ru MIME-Version: 1.0 To: Will Andrews Cc: "Simon 'corecode' Schubert" , Wes Peters , ports@FreeBSD.org, arch@FreeBSD.org Subject: Re: package tools into ports/ (was: Re: Bzipped?) References: <20020901142653.A32415@capable.rogards.com> <20020901191937.GI87971@leviathan.inethouston.net> <20020902103215.36ae8e3b.corecode@corecode.ath.cx> <20020902085654.GH2072@procyon.firepipe.net> <3D7445D3.DAA2C9B9@softweyr.com> <20020903100258.068fb3ab.corecode@corecode.ath.cx> <20020903121413.GN2072@procyon.firepipe.net> <20020903130237.GB8010@vega.vega.com> <20020903173228.GO2072@procyon.firepipe.net> <20020903221613.GC9384@vega.vega.com> <20020903221800.GE48750@procyon.firepipe.net> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Will Andrews wrote: > > On Wed, Sep 04, 2002 at 01:16:13AM +0300, Maxim Sobolev wrote: > > I could take src/usr.sbin/pkg_install part, leaving bsd.port.mk and > > actual pkg_tools (pkg_install?) port to you. > > OK. I did my part, now it's your turn. I'll toss few ideas for consideration: 1. Hypothetic pkg_install port should have sources in place, so that it is available right after cvsup. 2. Once installed, the port shouldn't register itself with /var/db/pkg, becase (a) we don't want zillion versions of pkg_install-xx.yy.zz cluttering /var/db/pkg and (b) no installed package should depend on a specific pkg_install package - it's ports only thing. I'd suggest to separate pkg_install version checking/updating routine into special target in bsd.port.mk and put this target even before pre-everything in _FETCH_SEQ. -Maxim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 10: 0: 6 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D411C37B400 for ; Tue, 10 Sep 2002 10:00:03 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 35FE243E65 for ; Tue, 10 Sep 2002 10:00:03 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id JAA60557 for ; Tue, 10 Sep 2002 09:58:01 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g8AGuJ433605 for freebsd-arch@freebsd.org; Tue, 10 Sep 2002 09:56:19 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200209101656.g8AGuJ433605@arch20m.dellroad.org> Subject: /dev/stdout behavior To: freebsd-arch@freebsd.org Date: Tue, 10 Sep 2002 09:56:19 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Is there an 'official' spec about how /dev/stdout is supposed to behave? For example, if you use fcntl() to set flags on fd 0, and then open /dev/stdout, the new file descriptor you get back will have those same flags set. Run the program below to see an example. This is in agreement with the man page, which states that opening /dev/stdout is equivalent to dup(2)'ing fd 0. However, on RedHat Linux 7.3, the program below behaves in the opposite manner from FreeBSD, i.e., it prints "O_NONBLOCK is not set". So at least one of FreeBSD or Linux is 'wrong' about /dev/stdout, or maybe there is no general agreement about what /dev/stdout means.. ? Thanks, -Archie P.S. This issue underlies PR misc/41331: http://www.freebsd.org/cgi/query-pr.cgi?pr=41331 __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com #include #include #include int main(int argc, char **argv) { int flags; int fd; if ((flags = fcntl(0, F_GETFL, 0)) == -1) err(1, "fcntl"); if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) err(1, "fcntl"); if ((fd = open("/dev/stdout", O_WRONLY, 0)) == -1) err(1, "open"); if ((flags = fcntl(fd, F_GETFL, 0)) == -1) err(1, "fcntl"); printf("O_NONBLOCK is %s\n", (flags & O_NONBLOCK) ? "set" : "not set"); return (0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 10:17:48 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB0D737B400 for ; Tue, 10 Sep 2002 10:17:46 -0700 (PDT) Received: from wellington.cnchost.com (wellington.concentric.net [207.155.252.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 21A2B43E42 for ; Tue, 10 Sep 2002 10:17:46 -0700 (PDT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by wellington.cnchost.com id NAA07504; Tue, 10 Sep 2002 13:17:45 -0400 (EDT) [ConcentricHost SMTP Relay 1.14] Message-ID: <200209101717.NAA07504@wellington.cnchost.com> To: Archie Cobbs Cc: freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior In-reply-to: Your message of "Tue, 10 Sep 2002 09:56:19 PDT." <200209101656.g8AGuJ433605@arch20m.dellroad.org> Date: Tue, 10 Sep 2002 10:17:44 -0700 From: Bakul Shah Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > For example, if you use fcntl() to set flags on fd 0, and then open > /dev/stdout, the new file descriptor you get back will have those > same flags set. Run the program below to see an example. This is > in agreement with the man page, which states that opening /dev/stdout > is equivalent to dup(2)'ing fd 0. Careful reading of man stdout will reveal that opening /dev/stdout is equivalent to dup()ing fd 1, not fd 0. FreeBSD has a bug. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 10:53: 4 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7E09937B400 for ; Tue, 10 Sep 2002 10:53:02 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id E5B9743E6A for ; Tue, 10 Sep 2002 10:52:57 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 18675 invoked by uid 1000); 10 Sep 2002 17:52:58 -0000 Date: Tue, 10 Sep 2002 10:52:58 -0700 (PDT) From: Nate Lawson To: Archie Cobbs Cc: freebsd-arch@freebsd.org Subject: Re: /dev/stdout behavior In-Reply-To: <200209101656.g8AGuJ433605@arch20m.dellroad.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 10 Sep 2002, Archie Cobbs wrote: > Is there an 'official' spec about how /dev/stdout is supposed to behave? > > For example, if you use fcntl() to set flags on fd 0, and then open > /dev/stdout, the new file descriptor you get back will have those > same flags set. Run the program below to see an example. This is > in agreement with the man page, which states that opening /dev/stdout > is equivalent to dup(2)'ing fd 0. > grep FILENO /usr/include/unistd.h #define STDIN_FILENO 0 /* standard input file descriptor */ #define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */ -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 11: 0: 5 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6DC7637B400 for ; Tue, 10 Sep 2002 11:00:03 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id E8C3A43E65 for ; Tue, 10 Sep 2002 11:00:02 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id KAA60914; Tue, 10 Sep 2002 10:59:44 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g8AHw2C33935; Tue, 10 Sep 2002 10:58:02 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200209101758.g8AHw2C33935@arch20m.dellroad.org> Subject: Re: /dev/stdout behavior In-Reply-To: <200209101717.NAA07504@wellington.cnchost.com> "from Bakul Shah at Sep 10, 2002 10:17:44 am" To: Bakul Shah Date: Tue, 10 Sep 2002 10:58:02 -0700 (PDT) Cc: freebsd-arch@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bakul Shah writes: > > For example, if you use fcntl() to set flags on fd 0, and then open > > /dev/stdout, the new file descriptor you get back will have those > > same flags set. Run the program below to see an example. This is > > in agreement with the man page, which states that opening /dev/stdout > > is equivalent to dup(2)'ing fd 0. > > Careful reading of man stdout will reveal that opening > /dev/stdout is equivalent to dup()ing fd 1, not fd 0. Arg, this whole time I meant to use '1' instead of '0'... But, hey-- now there's an even bigger bug! -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 12:30:10 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5A43637B400 for ; Tue, 10 Sep 2002 12:30:03 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id D0EFD43E4A for ; Tue, 10 Sep 2002 12:30:02 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id MAA61471; Tue, 10 Sep 2002 12:22:49 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g8AJL7J34317; Tue, 10 Sep 2002 12:21:07 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200209101921.g8AJL7J34317@arch20m.dellroad.org> Subject: Re: /dev/stdout behavior In-Reply-To: "from Nate Lawson at Sep 10, 2002 10:52:58 am" To: Nate Lawson Date: Tue, 10 Sep 2002 12:21:07 -0700 (PDT) Cc: freebsd-arch@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Nate Lawson writes: > > Is there an 'official' spec about how /dev/stdout is supposed to behave? > > > > For example, if you use fcntl() to set flags on fd 0, and then open > > /dev/stdout, the new file descriptor you get back will have those > > same flags set. Run the program below to see an example. This is > > in agreement with the man page, which states that opening /dev/stdout > > is equivalent to dup(2)'ing fd 0. > > > grep FILENO /usr/include/unistd.h > #define STDIN_FILENO 0 /* standard input file descriptor */ > #define STDOUT_FILENO 1 /* standard output file descriptor */ > #define STDERR_FILENO 2 /* standard error file descriptor */ Sorry.. please replace '0' with '1' everywhere. The original question remains. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 13: 3:47 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CBB4537B400 for ; Tue, 10 Sep 2002 13:03:44 -0700 (PDT) Received: from thunderer.cnchost.com (thunderer.concentric.net [207.155.252.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3373D43E3B for ; Tue, 10 Sep 2002 13:03:44 -0700 (PDT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by thunderer.cnchost.com id QAA28365; Tue, 10 Sep 2002 16:03:40 -0400 (EDT) [ConcentricHost SMTP Relay 1.14] Message-ID: <200209102003.QAA28365@thunderer.cnchost.com> To: Archie Cobbs Cc: freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior In-reply-to: Your message of "Tue, 10 Sep 2002 10:58:02 PDT." <200209101758.g8AHw2C33935@arch20m.dellroad.org> Date: Tue, 10 Sep 2002 13:03:39 -0700 From: Bakul Shah Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > Bakul Shah writes: > > > For example, if you use fcntl() to set flags on fd 0, and then open > > > /dev/stdout, the new file descriptor you get back will have those > > > same flags set. Run the program below to see an example. This is > > > in agreement with the man page, which states that opening /dev/stdout > > > is equivalent to dup(2)'ing fd 0. > > > > Careful reading of man stdout will reveal that opening > > /dev/stdout is equivalent to dup()ing fd 1, not fd 0. > > Arg, this whole time I meant to use '1' instead of '0'... > > But, hey-- now there's an even bigger bug! As the accidental discoverer of the bug, you should report it! dup(2) says that everything but the close-on-exec flag is shared by the new fd with the old fd. So (except for this bigger bug) the FreeBSD behavior is correct as verified by changing if ((flags = fcntl(0, F_GETFL, 0)) == -1) err(1, "fcntl"); if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) to if ((flags = fcntl(1, F_GETFL, 0)) == -1) err(1, "fcntl"); if (fcntl(1, F_SETFL, flags | O_NONBLOCK) == -1) You need to fix your test program similarly and run it under Linux to see if the two OSes behave differently. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 14:45: 5 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C596337B400 for ; Tue, 10 Sep 2002 14:45:03 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 35C8643E42 for ; Tue, 10 Sep 2002 14:45:03 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id OAA62208; Tue, 10 Sep 2002 14:37:15 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g8ALZXm34757; Tue, 10 Sep 2002 14:35:33 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200209102135.g8ALZXm34757@arch20m.dellroad.org> Subject: Re: /dev/stdout behavior In-Reply-To: <200209102003.QAA28365@thunderer.cnchost.com> "from Bakul Shah at Sep 10, 2002 01:03:39 pm" To: Bakul Shah Date: Tue, 10 Sep 2002 14:35:33 -0700 (PDT) Cc: freebsd-arch@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bakul Shah writes: > You need to fix your test program similarly and run it under > Linux to see if the two OSes behave differently. They do behave differently, even after adjusting '0' to '1': $ uname -a Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 i686 unknown $ ./flags O_NONBLOCK is not set -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 14:49:28 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 370B237B400 for ; Tue, 10 Sep 2002 14:49:22 -0700 (PDT) Received: from gull.mail.pas.earthlink.net (gull.mail.pas.earthlink.net [207.217.120.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id C475C43E42 for ; Tue, 10 Sep 2002 14:49:21 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0098.cvx21-bradley.dialup.earthlink.net ([209.179.192.98] helo=mindspring.com) by gull.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17ossj-0004LV-00; Tue, 10 Sep 2002 14:49:14 -0700 Message-ID: <3D7E6896.B586D5E1@mindspring.com> Date: Tue, 10 Sep 2002 14:48:06 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Archie Cobbs Cc: freebsd-arch@freebsd.org Subject: Re: /dev/stdout behavior References: <200209101656.g8AGuJ433605@arch20m.dellroad.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Archie Cobbs wrote: > Is there an 'official' spec about how /dev/stdout is supposed to behave? > > For example, if you use fcntl() to set flags on fd 0, and then open > /dev/stdout, the new file descriptor you get back will have those > same flags set. Run the program below to see an example. This is > in agreement with the man page, which states that opening /dev/stdout > is equivalent to dup(2)'ing fd 0. > > However, on RedHat Linux 7.3, the program below behaves in the opposite > manner from FreeBSD, i.e., it prints "O_NONBLOCK is not set". > > So at least one of FreeBSD or Linux is 'wrong' about /dev/stdout, or maybe > there is no general agreement about what /dev/stdout means.. ? The "O_NDELAY"/"O_NONBLOCK" is part and parcel with the "partial open" state for tty devices, so the value is actually supposed to be reset. There's a similar value that gets set with O_EXCL, or is supposed to. Basically, Linux is exhibiting SVR4 behaviour, which is technically more correct than BSD behaviour, given the adoption of the POSIX specification by BSD. There are a couple of ways to look at how this could be happening; I would have to look at the Linux kernel sources, which are hard to keep up to date, given that there is no moral equivalent to cvsup or anoncvs, in order to be certain what the root cause is. The difference comes down to the resetting of the flags, and whether or not the flags are per descriptor, per struct file, or per device node. BSD shares the struct file and the device node after the open; Linux may or may not share the struct file. Where the flag lives dictates which behaviour you end up getting. The O_EXCL (exclusive use bit) is similarly handled. I think the best public code you are going to find that indirectly documents the assumptions here is mgetty, and looking at what it does to open the port without DCD present on SVR4 boxes. FWIW, the "partial open hack", for opening a tty on SVR4 without DCD present, in order to be able to talk to a modem, without disabling modem control on the port so that DCD/DTR drop could still be correctly detected, was implemented like so: /* unset O_EXCL, set by blocking open, and not reset by * aborting the blocking open, by performing a blocking * open without O_EXCL set to reset the bits on the device; * alarm out of it, in case DCD not present or modem control, * so that we do not block forever. This is necessary so a * fork() child process doesn't lose access to the device * later because of O_EXCL, which is not reset if O_NDELAY * is used. */ alarm(1); fd = open( portname, O_RDWR, 0); alarm(0); /* If the open was successful, instead of alarming out, close it*/ if( fd != -1) close( fd); /* Perform a non-blocking open; this will leave the descriptor * in non-blocking mode, which can not be unset on some devices, * e.g. those opened over Intel OpenNET, or those which do not * implement an fcntl() method entry point for unsetting O_NDELAY. */ fdn = open( portname, O_NDELAY | O_RDWR, 0); /* Perform second blocking open. Because it is the second open, * it will not block, merely increment the reference count. Note * the the system open file table entry ("struct file") is not * shared, and the O_NDELAY flag is implemented there, so we will * be able to do blocking reads/write on the fd returned. In * other words, the device is already "partially open". */ fd = open( portname, O_RDWR, 0); /* Close the non-blocking descriptor, because we are going to * only use the blocking descriptor, so that we don't end up * buzz-looping with read returning 0 characters available (is * also needed to detect EOF condition via a short read). */ close( fdn); Maybe this is legacy SVR4 code you are looking at porting to BSD here? -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 14:52:48 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 874FE37B400 for ; Tue, 10 Sep 2002 14:52:44 -0700 (PDT) Received: from gull.mail.pas.earthlink.net (gull.mail.pas.earthlink.net [207.217.120.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 20AAF43E6E for ; Tue, 10 Sep 2002 14:52:44 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0098.cvx21-bradley.dialup.earthlink.net ([209.179.192.98] helo=mindspring.com) by gull.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17osw6-00026l-00; Tue, 10 Sep 2002 14:52:42 -0700 Message-ID: <3D7E6967.AC9D0F14@mindspring.com> Date: Tue, 10 Sep 2002 14:51:35 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bakul Shah Cc: Archie Cobbs , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior References: <200209101717.NAA07504@wellington.cnchost.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bakul Shah wrote: > > For example, if you use fcntl() to set flags on fd 0, and then open > > /dev/stdout, the new file descriptor you get back will have those > > same flags set. Run the program below to see an example. This is > > in agreement with the man page, which states that opening /dev/stdout > > is equivalent to dup(2)'ing fd 0. > > Careful reading of man stdout will reveal that opening > /dev/stdout is equivalent to dup()ing fd 1, not fd 0. > FreeBSD has a bug. The stdin and stdout fd's are not guaranteed to not share a struct file, so that's not correct. It's technically permitted to have the flag on the device or on the struct file, rather than the descriptor itself. In fact, the implementation pretty much demands it. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 15: 3:27 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4BAB137B400 for ; Tue, 10 Sep 2002 15:03:25 -0700 (PDT) Received: from thunderer.cnchost.com (thunderer.concentric.net [207.155.252.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id A317643E3B for ; Tue, 10 Sep 2002 15:03:24 -0700 (PDT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by thunderer.cnchost.com id SAA07377; Tue, 10 Sep 2002 18:00:05 -0400 (EDT) [ConcentricHost SMTP Relay 1.14] Message-ID: <200209102200.SAA07377@thunderer.cnchost.com> To: Archie Cobbs Cc: Bakul Shah , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior In-reply-to: Your message of "Tue, 10 Sep 2002 14:35:33 PDT." <200209102135.g8ALZXm34757@arch20m.dellroad.org> Date: Tue, 10 Sep 2002 15:00:04 -0700 From: Bakul Shah Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > You need to fix your test program similarly and run it under > > Linux to see if the two OSes behave differently. > > They do behave differently, even after adjusting '0' to '1': > > $ uname -a > Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 > i686 unknown > $ ./flags > O_NONBLOCK is not set Hmmm... are /dev/stdin etc. part of Posix? If not, linux can do what it wants. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 15:29:57 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 95FF337B400 for ; Tue, 10 Sep 2002 15:29:55 -0700 (PDT) Received: from agamemnon.cnchost.com (agamemnon.cnchost.com [207.155.252.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 03FB343E3B for ; Tue, 10 Sep 2002 15:29:55 -0700 (PDT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by agamemnon.cnchost.com id SAA27862; Tue, 10 Sep 2002 18:29:49 -0400 (EDT) [ConcentricHost SMTP Relay 1.14] Message-ID: <200209102229.SAA27862@agamemnon.cnchost.com> To: Terry Lambert Cc: Archie Cobbs , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior In-reply-to: Your message of "Tue, 10 Sep 2002 14:51:35 PDT." <3D7E6967.AC9D0F14@mindspring.com> Date: Tue, 10 Sep 2002 15:29:49 -0700 From: Bakul Shah Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > Careful reading of man stdout will reveal that opening > > /dev/stdout is equivalent to dup()ing fd 1, not fd 0. > > FreeBSD has a bug. > > The stdin and stdout fd's are not guaranteed to not share a > struct file, so that's not correct. It's technically permitted > to have the flag on the device or on the struct file, rather > than the descriptor itself. In fact, the implementation pretty > much demands it. Indeed, you are absolutely right. Thanks for setting me straight. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 16:18:42 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 09A0837B400 for ; Tue, 10 Sep 2002 16:18:41 -0700 (PDT) Received: from hawk.mail.pas.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA8FA43E86 for ; Tue, 10 Sep 2002 16:18:40 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0098.cvx21-bradley.dialup.earthlink.net ([209.179.192.98] helo=mindspring.com) by hawk.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17ouGj-00001n-00; Tue, 10 Sep 2002 16:18:05 -0700 Message-ID: <3D7E7D5B.B355328A@mindspring.com> Date: Tue, 10 Sep 2002 16:16:43 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bakul Shah Cc: Archie Cobbs , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior References: <200209102229.SAA27862@agamemnon.cnchost.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bakul Shah wrote: > > > FreeBSD has a bug. > > > > The stdin and stdout fd's are not guaranteed to not share a > > struct file, so that's not correct. It's technically permitted > > to have the flag on the device or on the struct file, rather > > than the descriptor itself. In fact, the implementation pretty > > much demands it. > > Indeed, you are absolutely right. Thanks for setting me > straight. Doesn't make the code work, though, does it. ;^). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 16:38:14 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D95B137B401 for ; Tue, 10 Sep 2002 16:38:12 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id E912343E4A for ; Tue, 10 Sep 2002 16:38:07 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 19607 invoked by uid 1000); 10 Sep 2002 23:38:09 -0000 Date: Tue, 10 Sep 2002 16:38:09 -0700 (PDT) From: Nate Lawson To: phk@freebsd.org, des@freebsd.org Cc: arch@freebsd.org Subject: PATCH: vnode->v_tag to const char * Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I have built and tested a patch that changes v_tag and all users of it. Since it should never be accessed other than for debugging, it is now a const char *, set by the caller of getnewvnode(9). There were a couple sticky points: * kern_descrip.c - checks for procfs on 0/1/2 and disallows sugid access. Added flag VV_UNSAFE to v_vflag and set it in pseudofs when the PFS_PROCDEP flag is sent to pfs_create_{file,dir,link}. I changed procfs to set this flag in each create call but a better approach might be to set the flag if the parent has the flag set and thus the flag in the root dir creation would get propagated to all. des@, comments? * kern/vfs_bio.c, vm/vm_swap.c - detecting NFS vnode is now done via: vp->v_mount->mnt_stat.f_type == nfs_mount_type Since NFS does this itself, I'm guessing it's the accepted way. * Bikeshed: Quotes around printing v_tag? Example: isofs/cd9660/cd9660_vnops.c: printf("tag \"%s\", isofs vnode\n", ap->a_vp->v_tag); Patch available (full build, tests ok for several fs types) at: http://www.root.org/~nate/freebsd/ -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 17: 0: 6 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B947137B400 for ; Tue, 10 Sep 2002 17:00:03 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 353DA43E4A for ; Tue, 10 Sep 2002 17:00:03 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id QAA63011; Tue, 10 Sep 2002 16:55:38 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g8ANruD35233; Tue, 10 Sep 2002 16:53:56 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200209102353.g8ANruD35233@arch20m.dellroad.org> Subject: Re: /dev/stdout behavior In-Reply-To: <200209102200.SAA07377@thunderer.cnchost.com> "from Bakul Shah at Sep 10, 2002 03:00:04 pm" To: Bakul Shah Date: Tue, 10 Sep 2002 16:53:56 -0700 (PDT) Cc: freebsd-arch@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bakul Shah writes: > > > You need to fix your test program similarly and run it under > > > Linux to see if the two OSes behave differently. > > > > They do behave differently, even after adjusting '0' to '1': > > > > $ uname -a > > Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 i686 unknown > > $ ./flags > > O_NONBLOCK is not set > > Hmmm... are /dev/stdin etc. part of Posix? If not, linux can > do what it wants. That was my original question :-) -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 17:36:36 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7C7837B400 for ; Tue, 10 Sep 2002 17:36:33 -0700 (PDT) Received: from espresso.q9media.com (espresso.q9media.com [65.39.129.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id 761D043E42 for ; Tue, 10 Sep 2002 17:36:33 -0700 (PDT) (envelope-from mike@espresso.q9media.com) Received: by espresso.q9media.com (Postfix, from userid 1002) id 33E549C11; Tue, 10 Sep 2002 20:30:12 -0400 (EDT) Date: Tue, 10 Sep 2002 20:30:12 -0400 From: Mike Barcroft To: Bakul Shah Cc: Archie Cobbs , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior Message-ID: <20020910203012.E40217@espresso.q9media.com> References: <200209102135.g8ALZXm34757@arch20m.dellroad.org> <200209102200.SAA07377@thunderer.cnchost.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200209102200.SAA07377@thunderer.cnchost.com>; from bakul@bitblocks.com on Tue, Sep 10, 2002 at 03:00:04PM -0700 Organization: The FreeBSD Project Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bakul Shah writes: > > > You need to fix your test program similarly and run it under > > > Linux to see if the two OSes behave differently. > > > > They do behave differently, even after adjusting '0' to '1': > > > > $ uname -a > > Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 > > i686 unknown > > $ ./flags > > O_NONBLOCK is not set > > Hmmm... are /dev/stdin etc. part of Posix? If not, linux can > do what it wants. POSIX specifies three special files: /dev/null, /dev/tty, and /dev/console. So the answer is no. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Tue Sep 10 20:43:48 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 05B1637B400 for ; Tue, 10 Sep 2002 20:43:46 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA5C643E72 for ; Tue, 10 Sep 2002 20:43:45 -0700 (PDT) (envelope-from baka@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1921) id A0735AE27F; Tue, 10 Sep 2002 20:43:40 -0700 (PDT) Date: Tue, 10 Sep 2002 20:43:40 -0700 From: Jon Mini To: arch@freebsd.org Subject: Commiting KSE pthreads prototype into -CURRENT. Message-ID: <20020911034340.GI3866@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG My work in the KSE p4 branch has reached the point where I have a functional pthreads library (a modified version of libc_r) that uses KSE for scheduling. An bug in the npx code is causing problems, but once that is resolved I want to commit these changes. A version of the diffs against -CURRENT is available at: http://www.freebsd.org/~mini/kse.diff These diffs modify libc_r rather than just show adding a new library, because that is easier to understand what changes are really happeneing. I would like to do the following: - Commit the kernel changes, minus the NPX modifications. - Commit the changes to libc (modification of the *context() functions). - Repo-copy the current libc_r to another directory, commit the modifications to work with KSE there, and attach it to the build. This brings us to a system where we can use both KSE threading or the old libc_r user threading in the same system, and libc_r is still the default. However, without the NPX changes, floating point operations will have race conditions in threaded apps that will cause inconsistent numerical results. - Once the NPX problems are resolved, commit those changes as well. Looking forward, once KSE has stabalized, we can switch the -pthread option to point to the KSE library rather than the old libc_r. Sometime after that, we can deprecate libc_r and eventually disconnect it from the build. This is some time down the road, however. Right now, we need to ship an experimental version of KSE with 5.0-RELEASE, and I think this is the best way to do it. Comments? Objections? -- Jonathan Mini http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 0:18: 8 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AE86C37B400; Wed, 11 Sep 2002 00:18:06 -0700 (PDT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD30F43E4A; Wed, 11 Sep 2002 00:18:05 -0700 (PDT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.3/8.12.2) with ESMTP id g8B7I3Uk024014; Wed, 11 Sep 2002 09:18:03 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: Nate Lawson Cc: des@freebsd.org, arch@freebsd.org Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: Your message of "Tue, 10 Sep 2002 16:38:09 PDT." Date: Wed, 11 Sep 2002 09:18:03 +0200 Message-ID: <24013.1031728683@critter.freebsd.dk> From: Poul-Henning Kamp Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message , Nate Lawson wri tes: >I have built and tested a patch that changes v_tag and all users of >it. Since it should never be accessed other than for debugging, it is now >a const char *, set by the caller of getnewvnode(9). Background: The main motivations for this change is to make it hard(er) for code to abuse v_tag, since doing so is almost invariably a mistake and to remove the need to edit the vtagtype enum in everytime a filesystem is added. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 0:35:48 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1C96837B438; Wed, 11 Sep 2002 00:35:38 -0700 (PDT) Received: from mail.nsu.ru (mx.nsu.ru [193.124.215.71]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59D4A43E3B; Wed, 11 Sep 2002 00:35:33 -0700 (PDT) (envelope-from fjoe@iclub.nsu.ru) Received: from drweb by mail.nsu.ru with drweb-scanned (Exim 3.20 #1) id 17p225-000672-00; Wed, 11 Sep 2002 14:35:29 +0700 Received: from iclub.nsu.ru ([193.124.215.97] ident=root) by mail.nsu.ru with esmtp (Exim 3.20 #1) id 17p225-00066p-00; Wed, 11 Sep 2002 14:35:29 +0700 Received: from iclub.nsu.ru (fjoe@localhost [127.0.0.1]) by iclub.nsu.ru (8.12.5/8.12.5) with ESMTP id g8B7ZSod006681; Wed, 11 Sep 2002 14:35:28 +0700 (NSS) (envelope-from fjoe@iclub.nsu.ru) Received: (from fjoe@localhost) by iclub.nsu.ru (8.12.5/8.12.5/Submit) id g8B7ZSBS006676; Wed, 11 Sep 2002 14:35:28 +0700 (NSS) Date: Wed, 11 Sep 2002 14:35:27 +0700 From: Max Khon To: Jon Mini Cc: arch@freebsd.org Subject: Re: Commiting KSE pthreads prototype into -CURRENT. Message-ID: <20020911143527.A4707@iclub.nsu.ru> References: <20020911034340.GI3866@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020911034340.GI3866@elvis.mu.org>; from mini@freebsd.org on Tue, Sep 10, 2002 at 08:43:40PM -0700 X-Envelope-To: mini@freebsd.org, arch@freebsd.org Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hi, there! On Tue, Sep 10, 2002 at 08:43:40PM -0700, Jon Mini wrote: > My work in the KSE p4 branch has reached the point where I have a > functional pthreads library (a modified version of libc_r) that > uses KSE for scheduling. An bug in the npx code is causing problems, > but once that is resolved I want to commit these changes. > A version of the diffs against -CURRENT is available at: > > http://www.freebsd.org/~mini/kse.diff > > These diffs modify libc_r rather than just show adding a new library, > because that is easier to understand what changes are really happeneing. > > I would like to do the following: > > - Commit the kernel changes, minus the NPX modifications. > - Commit the changes to libc (modification of the *context() > functions). > - Repo-copy the current libc_r to another directory, commit > the modifications to work with KSE there, and attach it to the > build. > > This brings us to a system where we can use both KSE threading or > the old libc_r user threading in the same system, and libc_r is > still the default. However, without the NPX changes, floating point > operations will have race conditions in threaded apps that will cause > inconsistent numerical results. > > - Once the NPX problems are resolved, commit those changes as well. > > Looking forward, once KSE has stabalized, we can switch the -pthread > option to point to the KSE library rather than the old libc_r. Sometime > after that, we can deprecate libc_r and eventually disconnect it from > the build. This is some time down the road, however. > Right now, we need to ship an experimental version of KSE with 5.0-RELEASE, > and I think this is the best way to do it. > > Comments? Objections? how will new pthreads library be named? -lpthread? if so we can drop -pthread option completely later. /fjoe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 0:40:29 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7A90C37B400 for ; Wed, 11 Sep 2002 00:40:25 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48B3643E42 for ; Wed, 11 Sep 2002 00:40:25 -0700 (PDT) (envelope-from baka@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1921) id 23270AE2B7; Wed, 11 Sep 2002 00:40:25 -0700 (PDT) Date: Wed, 11 Sep 2002 00:40:25 -0700 From: Jon Mini To: Max Khon Cc: arch@freebsd.org Subject: Re: Commiting KSE pthreads prototype into -CURRENT. Message-ID: <20020911074025.GP3866@elvis.mu.org> References: <20020911034340.GI3866@elvis.mu.org> <20020911143527.A4707@iclub.nsu.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020911143527.A4707@iclub.nsu.ru> User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Max Khon [fjoe@iclub.nsu.ru] wrote : > how will new pthreads library be named? -lpthread? > if so we can drop -pthread option completely later. This is the plan, yes. -- Jonathan Mini http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 3:47:55 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CD1237B400 for ; Wed, 11 Sep 2002 03:47:53 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 19C8C43E4A for ; Wed, 11 Sep 2002 03:47:52 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA25572; Wed, 11 Sep 2002 20:47:44 +1000 Date: Wed, 11 Sep 2002 20:55:32 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Archie Cobbs Cc: Bakul Shah , Subject: Re: /dev/stdout behavior In-Reply-To: <200209102135.g8ALZXm34757@arch20m.dellroad.org> Message-ID: <20020911204937.G1092-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 10 Sep 2002, Archie Cobbs wrote: > Bakul Shah writes: > > You need to fix your test program similarly and run it under > > Linux to see if the two OSes behave differently. > > They do behave differently, even after adjusting '0' to '1': > > $ uname -a > Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 i686 unknown > $ ./flags > O_NONBLOCK is not set This is a bug in Linux IMO. /dev/stdout should be as much like the real stdout as possible. E.g., it should share the file offset. This requires its descriptor to be a dup of stdout's descriptor for seekable files, and it would be surprising if non-seekable files like ttys were different. Sharing of O_NONBLOCK goes with sharing of the file (via diferent descriptors). Some device drivers have broken support for O_NONBLOCK (they do extra work to make it per-device), but tty devies get this right. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 6:54:21 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1026D37B400 for ; Wed, 11 Sep 2002 06:54:17 -0700 (PDT) Received: from hawk.mail.pas.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id A674A43E6A for ; Wed, 11 Sep 2002 06:54:16 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0034.cvx40-bradley.dialup.earthlink.net ([216.244.42.34] helo=mindspring.com) by hawk.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17p7wP-00046T-00; Wed, 11 Sep 2002 06:54:02 -0700 Message-ID: <3D7F4ABC.6C84FC79@mindspring.com> Date: Wed, 11 Sep 2002 06:53:00 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bruce Evans Cc: Archie Cobbs , Bakul Shah , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior References: <20020911204937.G1092-100000@gamplex.bde.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bruce Evans wrote: > > $ uname -a > > Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 i686 unknown > > $ ./flags > > O_NONBLOCK is not set > > This is a bug in Linux IMO. This is such a misinterpretation of O_NONBLOCK. The values of O_NDELAY and O_NONBLOCK are identical in their effects, with the exception of the return value of read(2) or write(2), in the case of a potential blocking operation: O_NDELAY is set: returns 0. O_NONBLOCK is set: returns -1 and sets errno to EAGAIN. Other than that they are identical. So it's reasonable to go looking at the behaviour of O_NDELAY. Realize that the existance of the O_NDELAY flag preceeds the ability to turn it off on an fd once it has been turned on. That is, there did not used to be an option to fcntl(, f_SETFL, flasg @ ~O_NDELAY);, and there did not used to be a FIONBIO ability to turn off the non-blocking I/O. You can obtain your own copy of the SVID, and other documents that are related to the System V ABI, from: http://www.caldera.com/developers/devspecs/ Unfortunately, they didn't also make the compliance validcation suite available online. 8-(. > /dev/stdout should be as much like the real > stdout as possible. E.g., it should share the file offset. This requires > its descriptor to be a dup of stdout's descriptor for seekable files, and > it would be surprising if non-seekable files like ttys were different. > Sharing of O_NONBLOCK goes with sharing of the file (via diferent > descriptors). Some device drivers have broken support for O_NONBLOCK > (they do extra work to make it per-device), but tty devies get this right. It's not standardized at all. The difference seems to be that FreeBSD takes it as an alias for a descriptor, whereas Linux takes it as an alias for the FS object to which the descriptor refers. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 7: 0:55 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B762937B400; Wed, 11 Sep 2002 07:00:52 -0700 (PDT) Received: from gw.nectar.cc (gw.nectar.cc [208.42.49.153]) by mx1.FreeBSD.org (Postfix) with ESMTP id 348A043E6A; Wed, 11 Sep 2002 07:00:52 -0700 (PDT) (envelope-from nectar@nectar.cc) Received: from madman.nectar.cc (madman.nectar.cc [10.0.1.111]) by gw.nectar.cc (Postfix) with ESMTP id CA9A764; Wed, 11 Sep 2002 09:00:51 -0500 (CDT) Received: by madman.nectar.cc (Postfix, from userid 1001) id 44092137BAB; Wed, 11 Sep 2002 09:00:51 -0500 (CDT) Date: Wed, 11 Sep 2002 09:00:51 -0500 From: "Jacques A. Vidrine" To: Mike Barcroft Cc: Bakul Shah , Archie Cobbs , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior Message-ID: <20020911140051.GI2539@madman.nectar.cc> Mail-Followup-To: "Jacques A. Vidrine" , Mike Barcroft , Bakul Shah , Archie Cobbs , freebsd-arch@FreeBSD.ORG References: <200209102135.g8ALZXm34757@arch20m.dellroad.org> <200209102200.SAA07377@thunderer.cnchost.com> <20020910203012.E40217@espresso.q9media.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020910203012.E40217@espresso.q9media.com> User-Agent: Mutt/1.4i X-Url: http://www.celabo.org/ Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Sep 10, 2002 at 08:30:12PM -0400, Mike Barcroft wrote: > Bakul Shah writes: > > > > You need to fix your test program similarly and run it under > > > > Linux to see if the two OSes behave differently. > > > > > > They do behave differently, even after adjusting '0' to '1': > > > > > > $ uname -a > > > Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 > > > i686 unknown > > > $ ./flags > > > O_NONBLOCK is not set > > > > Hmmm... are /dev/stdin etc. part of Posix? If not, linux can > > do what it wants. > > POSIX specifies three special files: /dev/null, /dev/tty, and > /dev/console. So the answer is no. POSIX specifies /dev/stdout as a magic argument to uudecode (only?). For example, in the POSIX specification of uudecode: `` The following option shall be supported by the implementation: -o outfile A pathname of a file that shall be used instead of any pathname contained in the input data. Specifying an outfile option-argument of /dev/stdout shall indicate standard output. '' and `` The /dev/stdout concept exists on most modern systems. The /dev/stdout syntax does not refer to a new special file. It is just a magic cookie to specify standard output. '' It seems that /dev/stdin and /dev/stderr are implementation specific constructs, as is /dev/stdout except for uudecode/uuencode. IMHO, it's very silly. Cheers, -- Jacques A. Vidrine http://www.celabo.org/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine@verio.net . nectar@FreeBSD.org . nectar@kth.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 10: 5:30 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 175F937B400 for ; Wed, 11 Sep 2002 10:05:29 -0700 (PDT) Received: from devonshire.cnchost.com (devonshire.concentric.net [207.155.248.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id BF57E43E4A for ; Wed, 11 Sep 2002 10:05:28 -0700 (PDT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by devonshire.cnchost.com id NAA17300; Wed, 11 Sep 2002 13:05:25 -0400 (EDT) [ConcentricHost SMTP Relay 1.14] Message-ID: <200209111705.NAA17300@devonshire.cnchost.com> To: Terry Lambert Cc: Bruce Evans , Archie Cobbs , freebsd-arch@FreeBSD.ORG Subject: Re: /dev/stdout behavior In-reply-to: Your message of "Wed, 11 Sep 2002 06:53:00 PDT." <3D7F4ABC.6C84FC79@mindspring.com> Date: Wed, 11 Sep 2002 10:05:24 -0700 From: Bakul Shah Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > /dev/stdout should be as much like the real > > stdout as possible. E.g., it should share the file offset. This requires > > its descriptor to be a dup of stdout's descriptor for seekable files, and > > it would be surprising if non-seekable files like ttys were different. > > Sharing of O_NONBLOCK goes with sharing of the file (via diferent > > descriptors). Some device drivers have broken support for O_NONBLOCK > > (they do extra work to make it per-device), but tty devies get this right. > > It's not standardized at all. The difference seems to be that > FreeBSD takes it as an alias for a descriptor, whereas Linux takes > it as an alias for the FS object to which the descriptor refers. It is not standardized but the FreeBSD interpretation is sensible. All opens of /dev/stdout, /dev/fd/1 and the actual stdout must point to the same struct file entry in the systemwide file table. I think the difference seems to be what flags are per process versus system wide (for a given file descriptor) and what per process flags are copied versus initialized. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 10:43:37 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D749837B400; Wed, 11 Sep 2002 10:43:34 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8353E43E3B; Wed, 11 Sep 2002 10:43:33 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id DAA23769; Thu, 12 Sep 2002 03:43:28 +1000 Date: Thu, 12 Sep 2002 03:43:20 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Nate Lawson Cc: phk@FreeBSD.ORG, , Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: Message-ID: <20020912033728.K3237-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 10 Sep 2002, Nate Lawson wrote: > I have built and tested a patch that changes v_tag and all users of > it. Since it should never be accessed other than for debugging, it is now > a const char *, set by the caller of getnewvnode(9). > > There were a couple sticky points: > > * kern_descrip.c - checks for procfs on 0/1/2 and disallows sugid > access. Added flag VV_UNSAFE to v_vflag and set it in pseudofs when the > PFS_PROCDEP flag is sent to pfs_create_{file,dir,link}. I changed procfs > to set this flag in each create call but a better approach might be to > set the flag if the parent has the flag set and thus the flag in the root > dir creation would get propagated to all. des@, comments? I like inheriting it. > * kern/vfs_bio.c, vm/vm_swap.c - detecting NFS vnode is now done via: > vp->v_mount->mnt_stat.f_type == nfs_mount_type > Since NFS does this itself, I'm guessing it's the accepted way. I don't like this. I can't find where nfs does this now, but remember thinking that this method doesn't work in general because nfs's variable can only be referenced if nfs is loaded. > * Bikeshed: Quotes around printing v_tag? Example: > isofs/cd9660/cd9660_vnops.c: > printf("tag \"%s\", isofs vnode\n", ap->a_vp->v_tag); Quotes shouldn't be necessary since you can choose names without any spaces. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Wed Sep 11 13:51:58 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C50CB37B400 for ; Wed, 11 Sep 2002 13:51:53 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 207C243E42 for ; Wed, 11 Sep 2002 13:51:53 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 22413 invoked by uid 1000); 11 Sep 2002 20:51:54 -0000 Date: Wed, 11 Sep 2002 13:51:54 -0700 (PDT) From: Nate Lawson To: Bruce Evans Cc: phk@FreeBSD.ORG, des@FreeBSD.ORG, arch@FreeBSD.ORG Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: <20020912033728.K3237-100000@gamplex.bde.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 12 Sep 2002, Bruce Evans wrote: > On Tue, 10 Sep 2002, Nate Lawson wrote: > > There were a couple sticky points: > > > > * kern_descrip.c - checks for procfs on 0/1/2 and disallows sugid > > access. Added flag VV_UNSAFE to v_vflag and set it in pseudofs when the > > PFS_PROCDEP flag is sent to pfs_create_{file,dir,link}. I changed procfs > > to set this flag in each create call but a better approach might be to > > set the flag if the parent has the flag set and thus the flag in the root > > dir creation would get propagated to all. des@, comments? > > I like inheriting it. Ok, I will change things so that it will be inherited from the parent. This is good since it will mean no changes to procfs code (only pseudofs) since the root dir for procfs is created with PFS_PROCDEP in the existing code (although for different reasons). > > * kern/vfs_bio.c, vm/vm_swap.c - detecting NFS vnode is now done via: > > vp->v_mount->mnt_stat.f_type == nfs_mount_type > > Since NFS does this itself, I'm guessing it's the accepted way. > > I don't like this. I can't find where nfs does this now, but remember > thinking that this method doesn't work in general because nfs's variable > can only be referenced if nfs is loaded. Here are the current places that reference nfs_mount_type: kern/vfs_subr.c:int nfs_mount_type = -1; sys/mount.h:extern int nfs_mount_type; /* vfc_typenum for nfs, or -1 */ vm/vnode_pager.c: (vp->v_mount->mnt_stat.f_type != nfs_mount_type)) { As you can see, NFS does not need to be loaded and this var is already ref'd in the vm code. For vm_swap.c, the code is seeing if it is enabling swapping to a file on an NFS-mounted fs, so v_mount has to be non-NULL. The only other option I considered was checking v_op == nfsv2_vnodeop_p but that has huge problems in that the vops for NFS are only present when NFS is loaded. If you have a better solution, I'm open to it. > > * Bikeshed: Quotes around printing v_tag? Example: > > isofs/cd9660/cd9660_vnops.c: > > printf("tag \"%s\", isofs vnode\n", ap->a_vp->v_tag); > > Quotes shouldn't be necessary since you can choose names without any > spaces. > > Bruce Ok, thank you for your comments. -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Thu Sep 12 3:36:34 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1FF2937B400; Thu, 12 Sep 2002 03:36:31 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id A21EA43E3B; Thu, 12 Sep 2002 03:36:29 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA22089; Thu, 12 Sep 2002 20:36:24 +1000 Date: Thu, 12 Sep 2002 20:40:54 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Nate Lawson Cc: phk@FreeBSD.ORG, , Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: Message-ID: <20020912202409.Y5891-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 11 Sep 2002, Nate Lawson wrote: > On Thu, 12 Sep 2002, Bruce Evans wrote: > > On Tue, 10 Sep 2002, Nate Lawson wrote: > > > * kern/vfs_bio.c, vm/vm_swap.c - detecting NFS vnode is now done via: > > > vp->v_mount->mnt_stat.f_type == nfs_mount_type > > > Since NFS does this itself, I'm guessing it's the accepted way. > > > > I don't like this. I can't find where nfs does this now, but remember > > thinking that this method doesn't work in general because nfs's variable > > can only be referenced if nfs is loaded. > > Here are the current places that reference nfs_mount_type: > > kern/vfs_subr.c:int nfs_mount_type = -1; > sys/mount.h:extern int nfs_mount_type; /* vfc_typenum for nfs, or -1 */ > vm/vnode_pager.c: (vp->v_mount->mnt_stat.f_type != > nfs_mount_type)) { > > As you can see, NFS does not need to be loaded and this var is already > ref'd in the vm code. For vm_swap.c, the code is seeing if it is enabling > swapping to a file on an NFS-mounted fs, so v_mount has to be non-NULL. This would be more convincing if the variable were actually initialized to something other than -1 :-). The non-null initialization was removed without comment in nfsclient/nfs_subs.c rev.1.105 (after a repo copy from nfs/nfs_subs.c rev.1.104), perhaps because the variable appeared to be a private to nfs and its one user in nfs (nfs_nqlease.c) went away. I wonder why no one noticed the effect of this on vm_swap.c. > The only other option I considered was checking v_op == nfsv2_vnodeop_p > but that has huge problems in that the vops for NFS are only present when > NFS is loaded. > > If you have a better solution, I'm open to it. I guess the global is the least of evils. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Thu Sep 12 4:41:37 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 351BB37B400; Thu, 12 Sep 2002 04:41:35 -0700 (PDT) Received: from columbus.cris.net (columbus.cris.net [212.110.128.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA55243E7B; Thu, 12 Sep 2002 04:41:15 -0700 (PDT) (envelope-from ml@phantom.cris.net) Received: from phantom.cris.net (root@phantom.cris.net [212.110.130.74]) by columbus.cris.net (8.9.3/8.9.3) with ESMTP id OAA52584; Thu, 12 Sep 2002 14:40:56 +0300 (EEST) Received: (from ml@localhost) by phantom.cris.net (8.12.2/8.12.2) id g8CBkOHj058136; Thu, 12 Sep 2002 14:46:24 +0300 (EEST) (envelope-from ml) Date: Thu, 12 Sep 2002 14:46:24 +0300 From: Alexey Zelkin To: Jon Mini Cc: arch@FreeBSD.ORG Subject: Re: Commiting KSE pthreads prototype into -CURRENT. Message-ID: <20020912144624.A58095@phantom.cris.net> References: <20020911034340.GI3866@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020911034340.GI3866@elvis.mu.org>; from mini@FreeBSD.ORG on Tue, Sep 10, 2002 at 08:43:40PM -0700 X-Operating-System: FreeBSD 4.5-STABLE i386 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hi, On Tue, Sep 10, 2002 at 08:43:40PM -0700, Jon Mini wrote: > My work in the KSE p4 branch has reached the point where I have a > functional pthreads library (a modified version of libc_r) that > uses KSE for scheduling. An bug in the npx code is causing problems, > but once that is resolved I want to commit these changes. [dd] > Looking forward, once KSE has stabalized, we can switch the -pthread > option to point to the KSE library rather than the old libc_r. Sometime > after that, we can deprecate libc_r and eventually disconnect it from > the build. This is some time down the road, however. As I recall correctly '-pthread' is required for 4-STABLE only. In CURRENT you just need to link against -lc_r to get threaded application. > Right now, we need to ship an experimental version of KSE with 5.0-RELEASE, > and I think this is the best way to do it. > > Comments? Objections? Go ahead. In case of having objections you just may not link it to build right now, so interested people may build it manually. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Thu Sep 12 12:16: 7 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B07FB37B400; Thu, 12 Sep 2002 12:16:05 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6814743E75; Thu, 12 Sep 2002 12:16:05 -0700 (PDT) (envelope-from baka@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1921) id 3C2AFAE25A; Thu, 12 Sep 2002 12:16:05 -0700 (PDT) Date: Thu, 12 Sep 2002 12:16:05 -0700 From: Jon Mini To: Alexey Zelkin Cc: arch@FreeBSD.ORG Subject: Re: Commiting KSE pthreads prototype into -CURRENT. Message-ID: <20020912191605.GZ3866@elvis.mu.org> References: <20020911034340.GI3866@elvis.mu.org> <20020912144624.A58095@phantom.cris.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020912144624.A58095@phantom.cris.net> User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Alexey Zelkin [phantom@FreeBSD.ORG] wrote : > As I recall correctly '-pthread' is required for 4-STABLE only. In CURRENT > you just need to link against -lc_r to get threaded application. You are correct on this. -- Jonathan Mini http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Thu Sep 12 14:10:31 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EFAF237B405; Thu, 12 Sep 2002 14:10:25 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id B404143E4A; Thu, 12 Sep 2002 14:10:25 -0700 (PDT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 88F0BAE23A; Thu, 12 Sep 2002 14:10:25 -0700 (PDT) Date: Thu, 12 Sep 2002 14:10:25 -0700 From: Alfred Perlstein To: Bruce Evans Cc: Nate Lawson , phk@FreeBSD.ORG, des@FreeBSD.ORG, arch@FreeBSD.ORG Subject: Re: PATCH: vnode->v_tag to const char * Message-ID: <20020912211025.GJ21806@elvis.mu.org> References: <20020912202409.Y5891-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020912202409.Y5891-100000@gamplex.bde.org> User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Bruce Evans [020912 03:36] wrote: > > > The only other option I considered was checking v_op == nfsv2_vnodeop_p > > but that has huge problems in that the vops for NFS are only present when > > NFS is loaded. > > > > If you have a better solution, I'm open to it. > > I guess the global is the least of evils. Wouldn't most of the 'nfs' specific hacks be applicable to other remote fs's? So then why not just a 'nfslike' flag where it is needed? -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Thu Sep 12 17:58:24 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DC14837B400 for ; Thu, 12 Sep 2002 17:58:21 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id E933843E4A for ; Thu, 12 Sep 2002 17:58:17 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 25432 invoked by uid 1000); 13 Sep 2002 00:58:19 -0000 Date: Thu, 12 Sep 2002 17:58:19 -0700 (PDT) From: Nate Lawson To: Alfred Perlstein Cc: Bruce Evans , phk@FreeBSD.ORG, des@FreeBSD.ORG, arch@FreeBSD.ORG Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: <20020912211025.GJ21806@elvis.mu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 12 Sep 2002, Alfred Perlstein wrote: > * Bruce Evans [020912 03:36] wrote: > > > > > The only other option I considered was checking v_op == nfsv2_vnodeop_p > > > but that has huge problems in that the vops for NFS are only present when > > > NFS is loaded. > > > > > > If you have a better solution, I'm open to it. > > > > I guess the global is the least of evils. > > Wouldn't most of the 'nfs' specific hacks be applicable to other remote > fs's? So then why not just a 'nfslike' flag where it is needed? I tend to agree although this may end up as a big discussion. I already have added VV_UNSAFE which is a propagation of PFS_PROCDEP (i.e. a kernel-mapped filesystem like procfs). I guess some filesystem groups might be: VV_NATIVE - ufs, ffs, mfs (full owner, ugid/flags support) VV_FOREIGN - msdosfs, ntfs, hpfs (don't support full unix semantics) VV_REMOTE - smbfs, nwfs (network-based) VV_KERNEL - procfs, fdescfs, devfs (view into kernel data) VV_WEIRD - unionfs ;-) Anyway, I'm not the right person for this but if perhaps you could come up with a list of the special cases in the VFS code that require certain semantics, we could check for capabilities instead of relying on the fs type. For instance, NFS would do this: getnewvnode("nfs",... VV_REMOTE | VV_NATIVE) And then vm/vm_swap could then just do if ((vp->v_vflag & VV_REMOTE) != 0) ... In looking through the use of v_tag, all people seemed to care about was VV_REMOTE and VV_KERNEL (as defined above) so perhaps that's all we need. -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Thu Sep 12 21: 4: 7 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A288737B498 for ; Thu, 12 Sep 2002 21:04:02 -0700 (PDT) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 14A2643E77 for ; Thu, 12 Sep 2002 21:04:02 -0700 (PDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.3/8.12.5) with ESMTP id g8D440Vo094246 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Fri, 13 Sep 2002 00:04:01 -0400 (EDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.3/8.12.5/Submit) id g8D440RF094243; Fri, 13 Sep 2002 00:04:00 -0400 (EDT) (envelope-from wollman) Date: Fri, 13 Sep 2002 00:04:00 -0400 (EDT) From: Garrett Wollman Message-Id: <200209130404.g8D440RF094243@khavrinen.lcs.mit.edu> To: arch@FreeBSD.org Subject: Potential fts(3) ABI breakage Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I'd like to break the ABI of fts(3) to remove its dependence on the struct hack, and thereby provide for the possibility of extending FTSENT to contain additional data (such as extended attributes). (Once this has been done, it should never be necessary to do so again.) anyone aware of non-system applications using this interface? Any other objections? Background: currently, FTSENT uses the struct hack to provide contiguous storage for the filename immediately following the end of the structure. This makes it impossible to extend the structure without breaking ABI compatibility. The change I plan to make will be to turn fts_path[] into *fts_path, without changing how memory is allocated; this will make future extensions possible without breaking the ABI. Only a very small (sizeof(FTSENT *)) increase in overhead will be required. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Thu Sep 12 21:56:48 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CE2DD37B400; Thu, 12 Sep 2002 21:56:44 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C23F43E6A; Thu, 12 Sep 2002 21:56:44 -0700 (PDT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 5A6A8AE1D7; Thu, 12 Sep 2002 21:56:44 -0700 (PDT) Date: Thu, 12 Sep 2002 21:56:44 -0700 From: Alfred Perlstein To: Nate Lawson Cc: Bruce Evans , phk@FreeBSD.ORG, des@FreeBSD.ORG, arch@FreeBSD.ORG Subject: Re: PATCH: vnode->v_tag to const char * Message-ID: <20020913045644.GM21806@elvis.mu.org> References: <20020912211025.GJ21806@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Nate Lawson [020912 17:58] wrote: > On Thu, 12 Sep 2002, Alfred Perlstein wrote: > > > > Wouldn't most of the 'nfs' specific hacks be applicable to other remote > > fs's? So then why not just a 'nfslike' flag where it is needed? > > I tend to agree although this may end up as a big discussion. I already > have added VV_UNSAFE which is a propagation of PFS_PROCDEP (i.e. a > kernel-mapped filesystem like procfs). I guess some filesystem groups > might be: > > VV_NATIVE - ufs, ffs, mfs (full owner, ugid/flags support) > VV_FOREIGN - msdosfs, ntfs, hpfs (don't support full unix semantics) > VV_REMOTE - smbfs, nwfs (network-based) > VV_KERNEL - procfs, fdescfs, devfs (view into kernel data) > VV_WEIRD - unionfs ;-) > > Anyway, I'm not the right person for this but if perhaps you could come up > with a list of the special cases in the VFS code that require certain > semantics, we could check for capabilities instead of relying on the fs > type. > > For instance, NFS would do this: > getnewvnode("nfs",... VV_REMOTE | VV_NATIVE) > > And then vm/vm_swap could then just do > if ((vp->v_vflag & VV_REMOTE) != 0) > ... > > In looking through the use of v_tag, all people seemed to care about was > VV_REMOTE and VV_KERNEL (as defined above) so perhaps that's all we need. It seems like you've put quite a bit more thought into this than I have, why not just take a bit of time to see how well your proposal maps to what we have, then do a quick drive-by commit, no one will complain. ;) -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Fri Sep 13 0:48:14 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B084137B400 for ; Fri, 13 Sep 2002 00:48:10 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 2104943E77 for ; Fri, 13 Sep 2002 00:48:06 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 26027 invoked by uid 1000); 13 Sep 2002 07:48:08 -0000 Date: Fri, 13 Sep 2002 00:48:08 -0700 (PDT) From: Nate Lawson To: Garrett Wollman Cc: arch@freebsd.org, imp@freebsd.org, peter@freebsd.org Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: <200209130213.g8D2DJP1093588@khavrinen.lcs.mit.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 12 Sep 2002, Garrett Wollman wrote: > In article you write: > > VV_NATIVE - ufs, ffs, mfs (full owner, ugid/flags support) > > VV_FOREIGN - msdosfs, ntfs, hpfs (don't support full unix semantics) > > VV_REMOTE - smbfs, nwfs (network-based) > > VV_KERNEL - procfs, fdescfs, devfs (view into kernel data) > > VV_WEIRD - unionfs ;-) > > vfsconf flags are your friends. > > -GAWollman Ok, now that works for NFS (VFCF_NETWORK). But the procfs check is horrible. For those just tuning in, if a set[ug]id program has /proc/mumble open on fds 0-2, it's possible it could inadvertently write to them, causing a crash. The check is_unsafe() in kern_descrip.c handles this case. I changed it to use VFCF_SYNTHETIC instead but that is not right -- fdescfs and devfs (think: /dev/fd/*, /dev/tty) are also synthetic. And what about portal ... ? What is the 'right' way to keep sugid programs from crashing the system with open 0-2 fds? Thanks, -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Fri Sep 13 5:37:25 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 752AC37B400; Fri, 13 Sep 2002 05:37:21 -0700 (PDT) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4941743E65; Fri, 13 Sep 2002 05:37:19 -0700 (PDT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.12.4/8.12.4) with SMTP id g8DCavOo098929; Fri, 13 Sep 2002 08:36:57 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Fri, 13 Sep 2002 08:36:56 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: Nate Lawson Cc: Garrett Wollman , arch@freebsd.org, imp@freebsd.org, peter@freebsd.org Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 13 Sep 2002, Nate Lawson wrote: > Ok, now that works for NFS (VFCF_NETWORK). But the procfs check is > horrible. > > For those just tuning in, if a set[ug]id program has /proc/mumble open > on fds 0-2, it's possible it could inadvertently write to them, causing > a crash. The check is_unsafe() in kern_descrip.c handles this case. > > I changed it to use VFCF_SYNTHETIC instead but that is not right -- > fdescfs and devfs (think: /dev/fd/*, /dev/tty) are also synthetic. And > what about portal ... ? > > What is the 'right' way to keep sugid programs from crashing the system > with open 0-2 fds? The risk isn't just that the system might crash, it's that I might be able to gain privilege by setting up a scenario of this sort. The ability to write to a procfs vnode (such as mem) can come and go as the privilege of the subject and target processes change, yet a file descriptor reference to the procfs vnode may remain valid throughout. Through careful timing, it may be possible to arrange for one setuid application to write to the memory space of another setuid application in a controlled form, which could be used to increase the level of privilege of the attacker by causing the target process to misbehave in a predictable way. Through careful racing, for example, you could arrange for the output of your arbitrary friendly setuid program (passwd, su, lpr, ...) to end up overwriting the buffer memory used by another command (passwd, su) to change its behavior to your benefit (as an attacker). Interestingly, procfs vnodes are one of the few cases where this can happen, since it's one of the few file systems we have with this sort of semantic. With MAC and securelevels/file flags, there are some other cases where the privilege to write to an object comes and goes, but you might still have a file descriptor. Arguably, this is a weakness to the UNIX model, and it's not yet clear to me what the right fix is. Certainly disallowing stdio from pointing to procfs nodes is a good start and prevents known problems. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Network Associates Laboratories To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Fri Sep 13 6:51: 3 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E45AE37B400; Fri, 13 Sep 2002 06:51:01 -0700 (PDT) Received: from avocet.mail.pas.earthlink.net (avocet.mail.pas.earthlink.net [207.217.120.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8D48E43E6A; Fri, 13 Sep 2002 06:51:01 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0166.cvx21-bradley.dialup.earthlink.net ([209.179.192.166] helo=mindspring.com) by avocet.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17pqqZ-000762-00; Fri, 13 Sep 2002 06:50:59 -0700 Message-ID: <3D81ED04.C016B3B0@mindspring.com> Date: Fri, 13 Sep 2002 06:49:56 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Nate Lawson Cc: Garrett Wollman , arch@freebsd.org, imp@freebsd.org, peter@freebsd.org Subject: Re: PATCH: vnode->v_tag to const char * References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Nate Lawson wrote: > For those just tuning in, if a set[ug]id program has /proc/mumble open on > fds 0-2, it's possible it could inadvertently write to them, causing a > crash. The check is_unsafe() in kern_descrip.c handles this case. > > I changed it to use VFCF_SYNTHETIC instead but that is not right -- > fdescfs and devfs (think: /dev/fd/*, /dev/tty) are also synthetic. And > what about portal ... ? > > What is the 'right' way to keep sugid programs from crashing the system > with open 0-2 fds? Hook 1 and 2, which are output fd's, to /dev/null, if you *must* have them open. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Fri Sep 13 9:46: 9 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9945F37B405 for ; Fri, 13 Sep 2002 09:46:05 -0700 (PDT) Received: from web11208.mail.yahoo.com (web11208.mail.yahoo.com [216.136.131.190]) by mx1.FreeBSD.org (Postfix) with SMTP id 1919243E6E for ; Fri, 13 Sep 2002 09:46:05 -0700 (PDT) (envelope-from gathorpe79@yahoo.com) Message-ID: <20020913164532.65101.qmail@web11208.mail.yahoo.com> Received: from [142.204.207.91] by web11208.mail.yahoo.com via HTTP; Fri, 13 Sep 2002 12:45:31 EDT Date: Fri, 13 Sep 2002 12:45:31 -0400 (EDT) From: Gary Thorpe Subject: Re: Commiting KSE pthreads prototype into -CURRENT. To: Jon Mini Cc: freebsd-arch@freebsd.org In-Reply-To: <20020912191605.GZ3866@elvis.mu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --- Jon Mini wrote: > Alexey Zelkin [phantom@FreeBSD.ORG] wrote : > > > As I recall correctly '-pthread' is required for > 4-STABLE only. In CURRENT > > you just need to link against -lc_r to get > threaded application. > > You are correct on this. > > -- > Jonathan Mini > http://www.freebsd.org/ > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-arch" in the body of the message Hmmm, isn't using -lc_r simply linking the application against a reentrant library? Using pthreads (or any other thread API) would *require* reentrant libraries, but using a reentrant library will not make the application itself threaded (unless code inside the library actively creates/destroys threads when called). To get pthread, you would have to use -lpthread or maybe even -pthread (FreeBSD's custom gcc flag)? If this is not the case (and -lc_r includes pthread support), then maybe scenarios when reentrant libraries are wanted but pthreads are not (e.g. when custom user space threading libraries are being used) should be considered? I.e. shouldn't the programmer decide whether to link reentrant libraries AND what thread support (if any) they want? ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Fri Sep 13 10:52:17 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DC98637B400 for ; Fri, 13 Sep 2002 10:52:14 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 35BA043E65 for ; Fri, 13 Sep 2002 10:52:14 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 27573 invoked by uid 1000); 13 Sep 2002 17:52:14 -0000 Date: Fri, 13 Sep 2002 10:52:14 -0700 (PDT) From: Nate Lawson To: Terry Lambert Cc: arch@freebsd.org Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: <3D81ED04.C016B3B0@mindspring.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Sorry, this isn't helpful. See the start of this thread where I am changing vp->v_tag. Since v_tag is not (and should never have been) usable as a fs type id, I need something to replace it with to detect a procfs vnode. Checking for VFCF_SYNTHETIC lumps devfs and fdescfs in with procfs and thus programs like su no longer work (because stdin is /dev/tty which is on devfs which, like procfs, has VFCF_SYNTHETIC set). Another possibility I considered was checking for VFCF_SYNTHETIC and vtype != VCHR (since procfs uses standard VDIR/VREG files). This didn't work either (I was able to hang the system with "su < /proc/curproc/mem"). I need two things: 1. To know all the filesystem types that are unsafe for set[ug]id programs with open descriptors on 0-2. Procfs is one, but there are probably others. Any fs where the semantics of the fd change across an exec is suspect. 2. A way to uniquely identify those fs types via a vnode. This may need to be a new flag somewhere (say, struct vfsconf). Pseudofs already uses PFS_PROCDEP but this never gets propagated to a vnode. -Nate On Fri, 13 Sep 2002, Terry Lambert wrote: > Nate Lawson wrote: > > For those just tuning in, if a set[ug]id program has /proc/mumble open on > > fds 0-2, it's possible it could inadvertently write to them, causing a > > crash. The check is_unsafe() in kern_descrip.c handles this case. > > > > I changed it to use VFCF_SYNTHETIC instead but that is not right -- > > fdescfs and devfs (think: /dev/fd/*, /dev/tty) are also synthetic. And > > what about portal ... ? > > > > What is the 'right' way to keep sugid programs from crashing the system > > with open 0-2 fds? > > Hook 1 and 2, which are output fd's, to /dev/null, if you *must* > have them open. > > -- Terry > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-arch" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Fri Sep 13 12:40: 8 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DCD6537B400 for ; Fri, 13 Sep 2002 12:40:01 -0700 (PDT) Received: from obsecurity.dyndns.org (adsl-64-165-226-88.dsl.lsan03.pacbell.net [64.165.226.88]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB9E743E65 for ; Fri, 13 Sep 2002 12:39:59 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 575CA66D7F; Fri, 13 Sep 2002 12:39:59 -0700 (PDT) Date: Fri, 13 Sep 2002 12:39:58 -0700 From: Kris Kennaway To: Garrett Wollman Cc: arch@FreeBSD.org Subject: Re: Potential fts(3) ABI breakage Message-ID: <20020913193958.GA49646@xor.obsecurity.org> References: <200209130404.g8D440RF094243@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline In-Reply-To: <200209130404.g8D440RF094243@khavrinen.lcs.mit.edu> User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Sep 13, 2002 at 12:04:00AM -0400, Garrett Wollman wrote: > I'd like to break the ABI of fts(3) to remove its dependence on the > struct hack, and thereby provide for the possibility of extending > FTSENT to contain additional data (such as extended attributes). > (Once this has been done, it should never be necessary to do so > again.) anyone aware of non-system applications using this interface? > Any other objections? I'm sure a number of ports use it. Kris --J/dobhs11T7y2rNN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE9gj8OWry0BWjoQKURAjBMAJ9PB8IYFGDZkgh7OaGcpi2U9p00YwCfVZFW qEYIZec0sK8kaXqDdT7Ytew= =9sJ5 -----END PGP SIGNATURE----- --J/dobhs11T7y2rNN-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Sat Sep 14 2:16: 2 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F416D37B413 for ; Sat, 14 Sep 2002 02:15:37 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 90F2C442F3 for ; Sat, 14 Sep 2002 02:07:28 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 28630 invoked by uid 1000); 14 Sep 2002 09:07:31 -0000 Date: Sat, 14 Sep 2002 02:07:31 -0700 (PDT) From: Nate Lawson To: Terry Lambert Cc: arch@freebsd.org Subject: Re: PATCH: vnode->v_tag to const char * In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 13 Sep 2002, Nate Lawson wrote: > Sorry, this isn't helpful. See the start of this thread where I am > changing vp->v_tag. Since v_tag is not (and should never have > been) usable as a fs type id, I need something to replace it with to > detect a procfs vnode. Checking for VFCF_SYNTHETIC lumps devfs and > fdescfs in with procfs and thus programs like su no longer work (because > stdin is /dev/tty which is on devfs which, like procfs, has > VFCF_SYNTHETIC set). > > Another possibility I considered was checking for VFCF_SYNTHETIC and vtype > != VCHR (since procfs uses standard VDIR/VREG files). This didn't work > either (I was able to hang the system with "su < /proc/curproc/mem"). The panic is due to a recursive lock and was not added (or fixed) by the v_tag commit. I am testing a local fix for the lock problem and will commit it soon. > I need two things: > 1. To know all the filesystem types that are unsafe for set[ug]id > programs with open descriptors on 0-2. Procfs is one, but there are > probably others. Any fs where the semantics of the fd change across an > exec is suspect. > 2. A way to uniquely identify those fs types via a vnode. > > This may need to be a new flag somewhere (say, struct vfsconf). Pseudofs > already uses PFS_PROCDEP but this never gets propagated to a vnode. > > -Nate I did this by adding VV_PROCDEP to vnode.h and setting it in pseudofs when allocing a new vnode and the client fs (say procfs) has set PFS_PROCDEP. The latter is propagated to children, which works cleanly for the other fs like this (linprocfs). -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message From owner-freebsd-arch Sat Sep 14 23:12:33 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 53DB537B400 for ; Sat, 14 Sep 2002 23:12:32 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1321C43E6A for ; Sat, 14 Sep 2002 23:12:32 -0700 (PDT) (envelope-from baka@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1921) id D36FFAE22C; Sat, 14 Sep 2002 23:12:31 -0700 (PDT) Date: Sat, 14 Sep 2002 23:12:31 -0700 From: Jon Mini To: Gary Thorpe Cc: freebsd-arch@freebsd.org Subject: Re: Commiting KSE pthreads prototype into -CURRENT. Message-ID: <20020915061231.GA3866@elvis.mu.org> References: <20020912191605.GZ3866@elvis.mu.org> <20020913164532.65101.qmail@web11208.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020913164532.65101.qmail@web11208.mail.yahoo.com> User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Gary Thorpe [gathorpe79@yahoo.com] wrote : > --- Jon Mini wrote: > > Alexey Zelkin [phantom@FreeBSD.ORG] wrote : > > > > > As I recall correctly '-pthread' is required for > > 4-STABLE only. In CURRENT > > > you just need to link against -lc_r to get > > threaded application. > > > > You are correct on this. > > Hmmm, isn't using -lc_r simply linking the application > against a reentrant library? Using pthreads (or any > other thread API) would *require* reentrant libraries, > but using a reentrant library will not make the > application itself threaded (unless code inside the > library actively creates/destroys threads when > called). Simply: no. The reentrant stuff needed in libc is already there. The -pthread gcc option hack is simply an alias for -lc_r right now. A threaded application in -CURRENT links against both libc_r and libc. This will be a replacement for libc_r. -- Jonathan Mini http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message