Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC503C433F5 for ; Mon, 29 Nov 2021 22:13:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbhK2WQv (ORCPT ); Mon, 29 Nov 2021 17:16:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231307AbhK2WQk (ORCPT ); Mon, 29 Nov 2021 17:16:40 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89792C0FE6D1 for ; Mon, 29 Nov 2021 13:53:21 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id z5so12786828edd.3 for ; Mon, 29 Nov 2021 13:53:21 -0800 (PST) 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=slW4IJtLPUe+dCTHZwT8J5Hyfi+JKfCkiz5Jx8MZKyY=; b=OIIkDWpAmMxBagMHTq19qfJ/pA9QYr/FKz8j6+SnJ2OrelhnpGAnnKmCIO3mUxo8Q6 3kiR81AGz32H1FqBqW5zns775gFrUt+SLbtgMVdaHVpW1sxT7KmTN6wWstYt3DlOV4Dj +J3pR3O4PkRhYpRorn4h4+cgIw+4SIqeCwE5g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=slW4IJtLPUe+dCTHZwT8J5Hyfi+JKfCkiz5Jx8MZKyY=; b=RpXDaXD5zzQUQ3KRJIRr42VMbVfyuWGjBdn7+CUVJAspMHQJK2uK7VYT8wG9HV4xZZ pHxYjS4HDd7ABvHVyGWjWOEOsEyS2YJ/eYRlwSIIN2roFs0AibgMhPy2PsHYjqxK1SCy SEmXEBVa9VEylQIBIQpZOOJiYfnf21iYwW/NZ5RzPvIYVTuaGltYYP6PwAgVFMdZLv24 gx/+VtEYpZ0Hrs7wt9bAiUMNacSvsqe+wREgqzgMP0jpB5D3LL/VfI2r7BEC/2zzNiJh 32ItBjL0MDWco3T0ibPBxO+tG5iL/PVh8Jgg+QeBJlAqSERVVLlPj5WhBR7tsTc/kUwF oOTA== X-Gm-Message-State: AOAM531e07rdn+VHZvKxCy3c7M9VkoAAWrlUAS0rg/KRcRWlFXEaAaPI MWzGuZHcC5J3lS89k9KEDQKLMSrbM9IgKs0UHQg= X-Google-Smtp-Source: ABdhPJwJKpNizjv3EaDpwpIBRkOB7/Dc8/MhB79A5CZ/LyLpA50Y+gcEiZRS/aQABcxuhYH4/6KVKA== X-Received: by 2002:a17:906:dff1:: with SMTP id lc17mr62434552ejc.215.1638222799842; Mon, 29 Nov 2021 13:53:19 -0800 (PST) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com. [209.85.221.53]) by smtp.gmail.com with ESMTPSA id s2sm8690507ejn.96.2021.11.29.13.53.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Nov 2021 13:53:19 -0800 (PST) Received: by mail-wr1-f53.google.com with SMTP id q3so17037098wru.5 for ; Mon, 29 Nov 2021 13:53:18 -0800 (PST) X-Received: by 2002:adf:e5c7:: with SMTP id a7mr37419983wrn.318.1638222798596; Mon, 29 Nov 2021 13:53:18 -0800 (PST) MIME-Version: 1.0 References: <20211127123958.588350-1-agruenba@redhat.com> In-Reply-To: From: Linus Torvalds Date: Mon, 29 Nov 2021 13:53:01 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults To: Catalin Marinas Cc: Andreas Gruenbacher , Matthew Wilcox , Josef Bacik , David Sterba , Al Viro , Andrew Morton , Will Deacon , linux-fsdevel , LKML , Linux ARM , linux-btrfs Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 29, 2021 at 12:56 PM Catalin Marinas wrote: > > For arm64 at least __put_user() does the access_ok() check. I thought > only unsafe_put_user() should skip the checks. If __put_user() can write > arbitrary memory, we may have a bigger problem. That's literally be the historical difference between __put_user() and put_user() - the access check. > I think that would be useful, though it doesn't solve the potential > livelock with sub-page faults. I was assuming we'd just do the sub-page faults. In fact, I was assuming we'd basically just replace all the PAGE_ALIGN and PAGE_SIZE with SUBPAGE_{ALIGN,SIZE}, together with something like if (size > PAGE_SIZE) size = PAGE_SIZE; to limit that size thing (or possibly make that "min size" be a parameter, so that people who have things like that "I need at least this initial structure to be copied" issue can document their minimum size needs). Linus