From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA35AC433DF for ; Tue, 19 May 2020 22:28:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B96512072C for ; Tue, 19 May 2020 22:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726535AbgESW2j (ORCPT ); Tue, 19 May 2020 18:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726432AbgESW2j (ORCPT ); Tue, 19 May 2020 18:28:39 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B0D4C061A0E for ; Tue, 19 May 2020 15:28:39 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jbAiu-00C3IO-5R; Tue, 19 May 2020 22:28:32 +0000 Date: Tue, 19 May 2020 23:28:32 +0100 From: Al Viro To: Thiago Macieira Cc: linux-fsdevel@vger.kernel.org, Linus Torvalds Subject: Re: fcntl(F_DUPFD) causing apparent file descriptor table corruption Message-ID: <20200519222832.GU23230@ZenIV.linux.org.uk> References: <1645568.el9gB4U55B@tjmaciei-mobl1> <20200519214520.GS23230@ZenIV.linux.org.uk> <6266026.WxYS4g2YVZ@tjmaciei-mobl1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6266026.WxYS4g2YVZ@tjmaciei-mobl1> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, May 19, 2020 at 03:18:13PM -0700, Thiago Macieira wrote: > > I really wonder about the missing couple of syscalls in your strace, though; > > could you verify that they _are_ missing and see what the fix above does to > > your testcase? > > Looking at my terminal backtrace, I might have made a copy & paste mistake of > the trace while flipping pages. Unfortunately, the trace file I had in /tmp > was lost because I needed to reboot the machine. The other traces I have in my > terminal show: > > fcntl(2, F_DUPFD, 134217728) = 134217728 > close(134217728) = 0 > fcntl(2, F_DUPFD, 268435456) = 268435456 > close(268435456) = 0 > fcntl(2, F_DUPFD, 536870912) = 536870912 > close(536870912) = 0 > write(1, "success\n", 8) = ? > ^C^Czsh: killed sudo strace ./dupfd-bug > > I had to killall -9 strace at this point. See the attached oops. BS values in the array of struct file pointers due to the problem above. And very likely a memory corruption as well. > Then I insisted: > > fcntl(2, F_DUPFD, 67108864) = 67108864 > close(67108864) = 0 > fcntl(2, F_DUPFD, 134217728) = 134217728 > close(134217728) = 0 > fcntl(2, F_DUPFD, 268435456Shared connection to closed. > > At this point, I need to drive to the office to reboot the machine. Building > the kernel and testing will take a few days. > > Note to self: don't play with possible kernel bugs without a VM. ... at least not without remote console, complete with ability to powercycle the box.