From owner-freebsd-current@freebsd.org Wed Nov 28 09:51:21 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B61D114ECE7 for ; Wed, 28 Nov 2018 09:51:21 +0000 (UTC) (envelope-from pho@holm.cc) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id BB0A86D30F for ; Wed, 28 Nov 2018 09:51:20 +0000 (UTC) (envelope-from pho@holm.cc) Received: by mailman.ysv.freebsd.org (Postfix) id 7E5B7114ECE6; Wed, 28 Nov 2018 09:51:20 +0000 (UTC) Delivered-To: current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59E8D114ECE5 for ; Wed, 28 Nov 2018 09:51:20 +0000 (UTC) (envelope-from pho@holm.cc) Received: from relay01.pair.com (relay01.pair.com [209.68.5.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D18E86D2F3 for ; Wed, 28 Nov 2018 09:51:09 +0000 (UTC) (envelope-from pho@holm.cc) Received: from x2.osted.lan (87-58-223-204-dynamic.dk.customer.tdc.net [87.58.223.204]) by relay01.pair.com (Postfix) with ESMTP id ADA9AD01AB8; Wed, 28 Nov 2018 04:51:02 -0500 (EST) Received: from x2.osted.lan (localhost [127.0.0.1]) by x2.osted.lan (8.15.2/8.15.2) with ESMTPS id wAS9p0MB013672 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 28 Nov 2018 10:51:00 +0100 (CET) (envelope-from pho@x2.osted.lan) Received: (from pho@localhost) by x2.osted.lan (8.15.2/8.15.2/Submit) id wAS9p0iU013661; Wed, 28 Nov 2018 10:51:00 +0100 (CET) (envelope-from pho) Date: Wed, 28 Nov 2018 10:50:59 +0100 From: Peter Holm To: Konstantin Belousov Cc: Vladimir Kondratyev , current@freebsd.org Subject: Re: r340343 triggers kernel assertion if file is opened with O_BENEATH flag set through symlink Message-ID: <20181128095059.GA13602@x2.osted.lan> References: <20181127234617.GE2378@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181127234617.GE2378@kib.kiev.ua> User-Agent: Mutt/1.10.0 (2018-05-17) X-Rspamd-Queue-Id: BB0A86D30F X-Spamd-Result: default: False [-5.82 / 15.00]; FORGED_RECIPIENTS_FORWARDING(0.00)[]; FORWARDED(0.00)[current@mailman.ysv.freebsd.org]; TO_DN_SOME(0.00)[]; MX_GOOD(-0.01)[cached: mailwash28.pair.com]; RCVD_IN_DNSWL_MED(-0.20)[5.0.0.0.0.5.0.0.0.0.0.0.0.0.0.0.a.6.0.2.4.5.2.2.0.0.9.1.1.0.0.2.list.dnswl.org : 127.0.9.2]; NEURAL_HAM_SHORT(-0.99)[-0.985,0]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_NO_TLS_LAST(0.10)[]; RECEIVED_SPAMHAUS_PBL(0.00)[204.223.58.87.zen.spamhaus.org : 127.0.0.11]; FORGED_SENDER(0.00)[peter@holm.cc,pho@holm.cc]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:10310, ipnet:2001:1900:2254::/48, country:US]; IP_SCORE(-3.63)[ip: (-9.87), ipnet: 2001:1900:2254::/48(-4.67), asn: 10310(-3.50), country: US(-0.09)]; FROM_NEQ_ENVFROM(0.00)[peter@holm.cc,pho@holm.cc]; FORGED_RECIPIENTS(0.00)[kostikbel@gmail.com ..,freebsd-current@freebsd.org]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FORGED_SENDER_FORWARDING(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[holm.cc]; AUTH_NA(1.00)[]; R_SPF_NA(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Nov 2018 09:51:21 -0000 On Wed, Nov 28, 2018 at 01:46:17AM +0200, Konstantin Belousov wrote: > On Wed, Nov 28, 2018 at 12:54:21AM +0300, Vladimir Kondratyev wrote: > > Following test case triggers assertion after r340343: > > > > > > #include > > > > int > > main(int argc, char **argv) > > { > >         openat(open("/etc", O_RDONLY), "termcap", O_RDONLY | O_BENEATH); > > } > > > > It results in: > > > > panic: Assertion (ndp->ni_lcf & NI_LCF_LATCH) != 0 failed at > > /usr/src/sys/kern/vfs_lookup.c:182 > > > > The following should fix it. Problem was that the topping directory was > only latched when the initial path was absolute. Since your example > switched from the relative argument to the absolute symlink, the BENEATH > tracker rightfully complained that there were no recorded top. > > I also added some asserts I used during the debugging. > > diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c > index 78893c4f2bd..7a80775d91d 100644 > --- a/sys/kern/vfs_lookup.c With this patch I got a: $ ./beneath.sh open("a/b") succeeded stat("a/b panic: Assertion (ndp->ni_lcf & NI_LCF_LATCH) != 0 failed at ../../../kern/vfs_lookup.c:269 cpuid = 4 time = 1543397647 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00c71881a0 vpanic() at vpanic+0x1a3/frame 0xfffffe00c7188200 panic() at panic+0x43/frame 0xfffffe00c7188260 namei_handle_root() at namei_handle_root+0xf7/frame 0xfffffe00c71882b0 namei() at namei+0x617/frame 0xfffffe00c71884f0 vn_open_cred() at vn_open_cred+0x526/frame 0xfffffe00c7188640 vn_open() at vn_open+0x4c/frame 0xfffffe00c7188680 kern_openat() at kern_openat+0x2e9/frame 0xfffffe00c71888e0 sys_openat() at sys_openat+0x69/frame 0xfffffe00c7188910 syscallenter() at syscallenter+0x4e3/frame 0xfffffe00c71889f0 amd64_syscall() at amd64_syscall+0x4d/frame 0xfffffe00c7188ab0 fast_syscall_common() at fast_syscall_common+0x101/frame 0xfffffe00c7188ab0 --- syscall (499, FreeBSD ELF64, sys_openat), rip = 0x8003a215a, rsp = 0x7fffffffe4f8, rbp = 0x7fffffffe5e0 --- https://people.freebsd.org/~pho/stress/log/kostik1127.txt - Peter