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=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 227B5C3A5A9 for ; Wed, 4 Sep 2019 21:43:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E520F208E4 for ; Wed, 4 Sep 2019 21:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567633402; bh=tgy971/fztqpwi8qOFwtwVHTIiYHicIXvVYLFwGHYnc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=WSEGkUbPd0hwbKiQpDxZ7Qk+uTWSdES+y4nszRisNb6q/worZ44MmijSs9cbEtf0h yLEfVzB8u7jghPXpHzVL8I7/MQQ7EjS/94fut0WJAps+cv9B2qnl63Hma9kVr+K44N syfXFQOs7+2vuFF7j2PuCIYuG0xhhooyronMYOd8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729740AbfIDVnV (ORCPT ); Wed, 4 Sep 2019 17:43:21 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:47021 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbfIDVnV (ORCPT ); Wed, 4 Sep 2019 17:43:21 -0400 Received: by mail-lf1-f68.google.com with SMTP id t8so183048lfc.13 for ; Wed, 04 Sep 2019 14:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uwuNMQc72pWyQK8TRg0HstY3l1Ai6DJhnuFaRewpYp4=; b=UP6KagylPWKv8Byd7UP6AZwOW79kEJrWCRQxdYQs3r+rkYYHaRtzINkvSv7M05KzA6 ZrkfCbIxdXLJg806nwevShkWeJseq5zYukSmtR6H1DU8VX49HoqAiZNvCj+iW0/x6oAZ eynsh3dcmA1ab+qwfUmxb81iuiDdfGEMPS8+s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uwuNMQc72pWyQK8TRg0HstY3l1Ai6DJhnuFaRewpYp4=; b=Fj0pVsgKQlN9VFa91KbN3ONuJFFZ9G58W0IM+3BA/e1R+RRrnE0EPFKlN6tVNG4DZV dslO0evfiQbvvQa4BLUCrR0xik0YVLeAswkgguLnIsfIjXtOhUCfIy5PueP8A/5SzRoT WV4ARDa3iw+c7hi4hHvUdxPzP96IZe1NJ4UTm/9UKS6vBQO7I8RUMKpcDlg/ifOXKlri UTUdt0otH/naSdJ6s1SVuVqSUHuXqSgBpKEKUSYXw5Ns/7WUck0OQ0zALieaxssiM0Ju TMWgo1CHRy2US2OTHTL1xypM0Mm9TA1DTPOLjshard13nILYbHwSq9jqj9wUJVmRS6Al z7Cw== X-Gm-Message-State: APjAAAVJbhJo8DndMw0oggJKuXpTSiWZvO2RM0t7rmrYsqcCUkxoRvN0 Wo6RvoJAn7YtUb4nuLSDtgEmoVB8z54= X-Google-Smtp-Source: APXvYqwLRdLbERckEHxTNaVtjn6t6ctl5mgVzk2EvJN7p75eOmcvmS57ag1mMBLNMkLBCZWyabkn0A== X-Received: by 2002:a19:6b09:: with SMTP id d9mr188654lfa.8.1567633398642; Wed, 04 Sep 2019 14:43:18 -0700 (PDT) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id y10sm6074ljk.5.2019.09.04.14.43.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Sep 2019 14:43:18 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id h3so235872ljb.5 for ; Wed, 04 Sep 2019 14:43:17 -0700 (PDT) X-Received: by 2002:a2e:3c14:: with SMTP id j20mr10927110lja.84.1567632938615; Wed, 04 Sep 2019 14:35:38 -0700 (PDT) MIME-Version: 1.0 References: <20190904201933.10736-1-cyphar@cyphar.com> <20190904201933.10736-11-cyphar@cyphar.com> In-Reply-To: From: Linus Torvalds Date: Wed, 4 Sep 2019 14:35:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v12 10/12] namei: aggressively check for nd->root escape on ".." resolution To: Aleksa Sarai Cc: Al Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Shuah Khan , Shuah Khan , Ingo Molnar , Peter Zijlstra , Christian Brauner , Jann Horn , Kees Cook , Eric Biederman , Andy Lutomirski , Andrew Morton , Alexei Starovoitov , Tycho Andersen , David Drysdale , Chanho Min , Oleg Nesterov , Rasmus Villemoes , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Aleksa Sarai , Linux Containers , alpha , Linux API , linux-arch , Linux ARM , linux-fsdevel , linux-ia64@vger.kernel.org, Linux List Kernel Mailing , "open list:KERNEL SELFTEST FRAMEWORK" , linux-m68k , linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390 , Linux-sh list , linux-xtensa@linux-xtensa.org, sparclinux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Wed, Sep 4, 2019 at 2:09 PM Linus Torvalds wrote: > > So you'd have three stages: > > 1) ".." always returns -EXDEV > > 2) ".." returns -EXDEV if there was a concurrent rename/mount > > 3) ".." returns -EXDEV if there was a concurrent rename/mount and we > reset the sequence numbers and check if you escaped. In fact, I wonder if this should return -EAGAIN instead - to say that "retrying may work". Because then: > Also, I'm not 100% convinced that (3) is needed at all. I think the > retry could be done in user space instead, which needs to have a > fallback anyway. Yes? No? Any user mode fallback would want to know whether it's a final error or whether simply re-trying might make it work again. I think that re-try case is valid for any of the possible "races happened, we can't guarantee that it's safe", and retrying inside the kernel (or doing that re-validation) could have latency issues. Maybe ".." is the only such case. I can't think of any other ones in your series, but at least conceptually they could happen. For example, we've had people who wanted pathname lookup without any IO happening, because if you have to wait for IO you could want to use another thread etc if you're doing some server in user space.. Linus