From owner-freebsd-arch@freebsd.org Fri May 15 21:22:52 2020 Return-Path: Delivered-To: freebsd-arch@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D928F2DA151; Fri, 15 May 2020 21:22:52 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 49P1bH2b1Hz4TYq; Fri, 15 May 2020 21:22:50 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id Zhn5jwZ05YYpxZhn7jBhiM; Fri, 15 May 2020 15:22:49 -0600 X-Authority-Analysis: v=2.3 cv=OubUNx3t c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=sTwFKg_x9MkA:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=EkcXrb_YAAAA:8 a=YwyvHg-N9EvwjEekwyUA:9 a=CjuIK1q_8ugA:10 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [IPv6:fc00:1:1:1::5b]) by spqr.komquats.com (Postfix) with ESMTPS id 61630537; Fri, 15 May 2020 14:22:47 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id 04FLMluj007217; Fri, 15 May 2020 14:22:47 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id 04FLMkd8007214; Fri, 15 May 2020 14:22:47 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202005152122.04FLMkd8007214@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: "Poul-Henning Kamp" cc: Kyle Evans , Alan Somers , "Julian H. Stacey" , "freebsd-arch@freebsd.org" , "freebsd-hackers@freebsd.org" Subject: Re: [HEADSUP] Disallowing read() of a directory fd In-reply-to: <35501.1589529102@critter.freebsd.dk> References: <202005142017.04EKH0aA093503@fire.js.berklix.net> <33549.1589488226@critter.freebsd.dk> <35501.1589529102@critter.freebsd.dk> Comments: In-reply-to "Poul-Henning Kamp" message dated "Fri, 15 May 2020 07:51:42 -0000." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 15 May 2020 14:22:46 -0700 X-CMAE-Envelope: MS4wfANA8adDSzJTRtipvrqWGMZHDRYx3BCsTco9NeKiJ3KEv/lhqw9bNC2nGGsGcAKNseIzPiwBJyL7ZKsLkQEPaweYDzz4hN/ivILh2Mc3xZtnVHGCZ6nI hNhfy+/jEJzrLBp+H5WygSXJFt3YJyMuC8M7byI1WUrLowynaPDKOfs0Px9U7yo9vETsaucCPh/3gFcrrBL0rrDbX8fbwJMxVprv1AlhHo1ysKJj6ad0awvE trlbbIjaRzo+mApJaGp0W21ANIG/A/FITZq7usA2IRMC0u5z4k/3eJDZ1weYWdivltAv/7srEsRRuwDdftF+DvbwtZH3DahpRDTccAxtgsE= X-Rspamd-Queue-Id: 49P1bH2b1Hz4TYq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; spf=none (mx1.freebsd.org: domain of cy.schubert@cschubert.com has no SPF policy when checking 64.59.136.138) smtp.mailfrom=cy.schubert@cschubert.com X-Spamd-Result: default: False [-4.23 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com]; RCPT_COUNT_FIVE(0.00)[6]; REPLYTO_EQ_FROM(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[138.136.59.64.rep.mailspike.net : 127.0.0.17]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[17.125.67.70.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; R_SPF_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; RCVD_IN_DNSWL_LOW(-0.10)[138.136.59.64.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6327, ipnet:64.59.128.0/20, country:CA]; RCVD_TLS_LAST(0.00)[]; IP_SCORE(-2.53)[ip: (-6.66), ipnet: 64.59.128.0/20(-3.30), asn: 6327(-2.58), country: CA(-0.09)]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2020 21:22:52 -0000 In message <35501.1589529102@critter.freebsd.dk>, "Poul-Henning Kamp" writes: > -------- > In message m> > , Kyle Evans writes: > >On Thu, May 14, 2020 at 3:30 PM Poul-Henning Kamp wrote > : > > >Can we explore the possibility of using fsdb(8) to fulfill these needs > >in a way that you'd be comfortable with? > > First, I am perfectly comfortable with fsdb(8), but in both the two > scenarios it was much less timeconsuming to do: > > strings < /some/directory | head > > Which immediately gives you the first filenames in the directory, > without waiting for ls(1) to read the entire directory, which in > this case was well north of 100MB. > > In the other case > > hexdump -C < /some/directory | grep part_of_suspect_filename > > gave me the answer faster than I could have started fsdb, it gave > me the answer in convenient hexadecimal, and besides it was not > a UFS filesystem. > > Second, one of the major reasons, probably about 3/4 of the total > reason I ended up in FreeBSD, was because of some utterly shit > experiences with commercial operating systems, where I had been in > a tight corner at 00-dark o'clock, and run straight into something > some idiot of at the vendor thought root should not be able to do > "for their own safety". > > This change falls right into that category: If root wants to hexdump > a directory, an entire bloody disk, or even if root wants to go > and do binary surgery on a mounted file system with a hex-editor, > root should be able to do that. > > She may have to `sysctl kern.warranty_voided=999` first, to disable > *under normal circumstances* reasonable and sensible protections. > > I'm perfectly fine with that: We do not want to make being root a > minefield, and I myself put the ability to munge mounted filesystems > under such a interlock in GEOM. > > But we should not make it *impossible* to do these things, and in > particular, we should not make them require a reboot, because ten > times out of nine, when you find yourself doing this kind of shit, > it is usually because you're pretty sure everything is lost if you > reboot. > > Summary: I'm perfectly fine with read(2) returning error on a > directory *under normal circumstances*, and I think it makes good > sense by protecting a lot of terminals from a lot of binary > garbage. > > But there is absolutely no reason to make it *impossible* for > a competent root to do what competent roots do. A kern.geom.debugflags-like thing might help but the complexity the code remains. Kyle's patch reduces complexity to a degree. A debugflags sysctl won't, it will add a little complexity. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few.