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 B21F6C3A5AB for ; Wed, 4 Sep 2019 21:35:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8AEB5208E4 for ; Wed, 4 Sep 2019 21:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567632946; bh=tgy971/fztqpwi8qOFwtwVHTIiYHicIXvVYLFwGHYnc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=w03+fLi8w3SHZ8OOSZ1U1ltkSDpLhVt3d+uwTYmcuDePg8lcTNx9OkeUS7C7fHM1c 6icgFs+DqGO6Nx3DRlU62+/HD/WM2H+rjiVUMo2Hj+lA9lf9wV5WiNU2qPDcmUISf7 QQ5xBx7SB9lmdPBQ7b2F0PsT+9rU2qmOlM57s7JU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbfIDVfq (ORCPT ); Wed, 4 Sep 2019 17:35:46 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34680 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729626AbfIDVfp (ORCPT ); Wed, 4 Sep 2019 17:35:45 -0400 Received: by mail-lf1-f66.google.com with SMTP id z21so223890lfe.1 for ; Wed, 04 Sep 2019 14:35:44 -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=inBLhFmTgqjvtXBwcGmXMX2k62xWaaofXoZjaP1B4GrEWpaEPv4VusQMHX7tnoSGmt 4aozTkVdIhT/mg4od+VOV48tgpeCNXtv3EcZ1vrcRNLnjWGfVLzkJEffGCBSLOQVm2pC aLVZ/u8gamsP9GsjlTdXSZnJZcOreefOVfcsx0U7rtQBNwAADLz6RfwNqxoNLseNllOV wRG/F5oj1xP3beSlteb5epko5FcVh8NY1hYaHyEPh5BpH7wQ/k+KdWkThHKgUUHcO5yq tX9YySYWM6oTTXUH3DAJh2tAI3jrOqJ4cQbU3/Z7/KThHFTn6EUQhzcNCmqcLFnoXHFL yeeQ== X-Gm-Message-State: APjAAAXANyERRf3ZzCBS3qC7LASvbepLvkCQP2apMdw9ZXE7kcyeRf8C Pfw51XCoPbi5mVUZ/Ul9GaSnvK5CPjU= X-Google-Smtp-Source: APXvYqyLNItRsFOihxX13OzIsBEdzI/9+Sc2uUElQQzn/StgVXuoc35wGFh/ylGtlUgNzo/XTPq84g== X-Received: by 2002:ac2:4906:: with SMTP id n6mr139805lfi.81.1567632942873; Wed, 04 Sep 2019 14:35:42 -0700 (PDT) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id b205sm11401lfg.72.2019.09.04.14.35.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Sep 2019 14:35:41 -0700 (PDT) Received: by mail-lj1-f181.google.com with SMTP id l1so180560lji.12 for ; Wed, 04 Sep 2019 14:35:40 -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-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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