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.9 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 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 8EDD7C33CAF for ; Wed, 22 Jan 2020 20:16:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6463A2073A for ; Wed, 22 Jan 2020 20:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579724164; bh=UwSm8VaE5Zar7jbwm21fqcL8/v1SlG8YOnDXnHw17ZE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=JmlhuTcBgX/TiorIZoNIh1qd9fCVxpteJdAHPKmFBWC7T6zK8Hj93zpIR/MJ9ItsG bovIMoo5stkzH/iu9bFrlV4Od1vBZFJRUSfoxl1u8M9nbe99Rr0nSKf46FQZF/VoCw NMsJVtF77zMYREJT6fhVhso4sfs2qYPeMCI0iaTw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729021AbgAVUQD (ORCPT ); Wed, 22 Jan 2020 15:16:03 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34445 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbgAVUQD (ORCPT ); Wed, 22 Jan 2020 15:16:03 -0500 Received: by mail-lf1-f65.google.com with SMTP id l18so606770lfc.1 for ; Wed, 22 Jan 2020 12:16:01 -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=GLaXGgH4O8WRc84Pr2qZRgc6Y4dR2xbO1cV7z28yhvw=; b=c6/3aq9HZcbkVeterj3636njxvpxgw2prgy9shUHvAD8OXcz0f+wkIkYAuQbjGEWBg wVKr74EpV63VLAZVJqyVwqQj1WCI2m0sZGTgzXF83HkQ+44OAwRd+/sOaE20vmKvYmlT 36kGk2sd4GMMWPOxwa4EBhU0TxNUpffdyIDvY= 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=GLaXGgH4O8WRc84Pr2qZRgc6Y4dR2xbO1cV7z28yhvw=; b=eZeedV9/KZOKlQJ12zr9J4Z5j2TIHzbiU+NkrqAFXDee6/4R5pneIAAwmHY4RLYoZR xsMYSoLAd6LHrPnvoPsNM4nLz0zz8b60Ec+TwPGMKg8LYy1dA3EGe0dIsCx8pIF+Hkcy IS9KFzaz86xkpXlHjnS+BJM+JoPt53FGTf19C7WmUJtsryC2aOU7uETdTsudQOdlF51g yIJZ/wXaQ+oMEhisG/kP/UqNOnfmpOd/dSumTvNyGeaTya2Ae86Wirp1oPOZJeLfyywf hwJnkuqzp9SFSzqO1xRAWpRA30IGNB8V7weqxdX+TNt0P6ALoSNJiA/obisAxkYUpthk queA== X-Gm-Message-State: APjAAAXVwZB+GXQBhUoannrvzzWRQ+tz7+hdlyvVYaH3lxX3WsB1+q7+ F0/Us1afNZrtssRVDGsH/eVDl8/S8Aw= X-Google-Smtp-Source: APXvYqx+byr03N4H26lk76L5AlAXTN5d+NoystmwdiqLSbvTH/4+hiFVa1uKpAYuXjCAMX2RAwMljg== X-Received: by 2002:ac2:4436:: with SMTP id w22mr2655537lfl.185.1579724159657; Wed, 22 Jan 2020 12:15:59 -0800 (PST) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id v29sm9823547ljd.69.2020.01.22.12.15.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2020 12:15:58 -0800 (PST) Received: by mail-lj1-f179.google.com with SMTP id a13so450097ljm.10 for ; Wed, 22 Jan 2020 12:15:58 -0800 (PST) X-Received: by 2002:a05:651c:282:: with SMTP id b2mr20649915ljo.41.1579724158165; Wed, 22 Jan 2020 12:15:58 -0800 (PST) MIME-Version: 1.0 References: <12a4be679e43de1eca6e5e2173163f27e2f25236.1579715466.git.christophe.leroy@c-s.fr> In-Reply-To: From: Linus Torvalds Date: Wed, 22 Jan 2020 12:15:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/6] fs/readdir: Fix filldir() and filldir64() use of user_access_begin() To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Alexander Viro , Andrew Morton , Linux Kernel Mailing List , linuxppc-dev , linux-fsdevel , Linux-MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 22, 2020 at 12:00 PM Linus Torvalds wrote: > > A bit more re-organization also allows us to do the unsafe_put_user() > unconditionally. I meant the "user_access_begin()", of course. Code was right, explanation was wrong. That said, with this model, we _could_ make the unsafe_put_user(offset, &prev->d_off, efault_end); be unconditional too, since now 'prev' will actually be a valid pointer - it will match 'dirent' if there was no prev. But since we want to test whether we had a previous entry anyway (for the signal handling latency issue), making the write to the previous d_reclen unconditional (and then overwriting it the next iteration) doesn't actually buy us anything. It was the user_access_begin() I'd rather have unconditional, since otherwise it gets duplicated in two (very slightly) different versions and we have unnecessary code bloat. Linus 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=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 E7BB9C33CB6 for ; Wed, 22 Jan 2020 20:16:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A73522073A for ; Wed, 22 Jan 2020 20:16:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="c6/3aq9H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A73522073A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 401CD6B0006; Wed, 22 Jan 2020 15:16:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D9226B0007; Wed, 22 Jan 2020 15:16:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EF096B0008; Wed, 22 Jan 2020 15:16:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 1511C6B0006 for ; Wed, 22 Jan 2020 15:16:03 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id BF8BF8248047 for ; Wed, 22 Jan 2020 20:16:02 +0000 (UTC) X-FDA: 76406376564.22.news55_179b63ef9a50e X-HE-Tag: news55_179b63ef9a50e X-Filterd-Recvd-Size: 4614 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Jan 2020 20:16:02 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id y1so579010lfb.6 for ; Wed, 22 Jan 2020 12:16:01 -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=GLaXGgH4O8WRc84Pr2qZRgc6Y4dR2xbO1cV7z28yhvw=; b=c6/3aq9HZcbkVeterj3636njxvpxgw2prgy9shUHvAD8OXcz0f+wkIkYAuQbjGEWBg wVKr74EpV63VLAZVJqyVwqQj1WCI2m0sZGTgzXF83HkQ+44OAwRd+/sOaE20vmKvYmlT 36kGk2sd4GMMWPOxwa4EBhU0TxNUpffdyIDvY= 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=GLaXGgH4O8WRc84Pr2qZRgc6Y4dR2xbO1cV7z28yhvw=; b=GyqpPs9RWdo448lcAfoZLLe5/h7drTtRLeudAz5GqpKJ/5vpgTNXxNGNcKjuGD07sv jN3Aw3p+r0Ri3Ov/oFaknLwvXRV5V7mnrJGplF8hUtzDxOcK6M48wuJjQ6ZJNyrpIT0P T9fop1WtpIb/AcxC+ll27iBYnOlYWeCk59zaZGiNedu+uZs0lFkqpTy+RXBGwxrFo3G1 5icVugPqmcH/gGE8vmUGwyuut34MxVy7bUodne9WIgvMZ5l5Z0arQx8fEZMqOBk8SB8g YibJ5IrtzIS9S/e/wkJvhga+aaJOPwJ0n0gDY5HRyF16OrNes1pjgelaG5TmSXcNE+So 4ykQ== X-Gm-Message-State: APjAAAVMqjfmg25vq86ksfPVwtDn0sY4kILVQ3NxogDJt9OEIuf6puxR LniDaVZh7v4PepiY312nbAt/NGfBf7c= X-Google-Smtp-Source: APXvYqzstJhPKq5eaxCrMgbO9W/5cQvFL8nj9ceH6HlgdofOXtBveJM8luBLtTt19sXK20N+EAX9Kg== X-Received: by 2002:a19:c210:: with SMTP id l16mr2732011lfc.35.1579724159628; Wed, 22 Jan 2020 12:15:59 -0800 (PST) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com. [209.85.208.171]) by smtp.gmail.com with ESMTPSA id i1sm20855630lji.71.2020.01.22.12.15.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2020 12:15:58 -0800 (PST) Received: by mail-lj1-f171.google.com with SMTP id j26so439224ljc.12 for ; Wed, 22 Jan 2020 12:15:58 -0800 (PST) X-Received: by 2002:a05:651c:282:: with SMTP id b2mr20649915ljo.41.1579724158165; Wed, 22 Jan 2020 12:15:58 -0800 (PST) MIME-Version: 1.0 References: <12a4be679e43de1eca6e5e2173163f27e2f25236.1579715466.git.christophe.leroy@c-s.fr> In-Reply-To: From: Linus Torvalds Date: Wed, 22 Jan 2020 12:15:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/6] fs/readdir: Fix filldir() and filldir64() use of user_access_begin() To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Alexander Viro , Andrew Morton , Linux Kernel Mailing List , linuxppc-dev , linux-fsdevel , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jan 22, 2020 at 12:00 PM Linus Torvalds wrote: > > A bit more re-organization also allows us to do the unsafe_put_user() > unconditionally. I meant the "user_access_begin()", of course. Code was right, explanation was wrong. That said, with this model, we _could_ make the unsafe_put_user(offset, &prev->d_off, efault_end); be unconditional too, since now 'prev' will actually be a valid pointer - it will match 'dirent' if there was no prev. But since we want to test whether we had a previous entry anyway (for the signal handling latency issue), making the write to the previous d_reclen unconditional (and then overwriting it the next iteration) doesn't actually buy us anything. It was the user_access_begin() I'd rather have unconditional, since otherwise it gets duplicated in two (very slightly) different versions and we have unnecessary code bloat. Linus 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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 D045EC2D0DB for ; Wed, 22 Jan 2020 20:17:59 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB9A92073A for ; Wed, 22 Jan 2020 20:17:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="c6/3aq9H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB9A92073A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 482xY03Q7DzDqW7 for ; Thu, 23 Jan 2020 07:17:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=2a00:1450:4864:20::142; helo=mail-lf1-x142.google.com; envelope-from=torvalds@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=google header.b=c6/3aq9H; dkim-atps=neutral Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 482xVr3dkDzDqTs for ; Thu, 23 Jan 2020 07:16:04 +1100 (AEDT) Received: by mail-lf1-x142.google.com with SMTP id 203so545635lfa.12 for ; Wed, 22 Jan 2020 12:16:03 -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=GLaXGgH4O8WRc84Pr2qZRgc6Y4dR2xbO1cV7z28yhvw=; b=c6/3aq9HZcbkVeterj3636njxvpxgw2prgy9shUHvAD8OXcz0f+wkIkYAuQbjGEWBg wVKr74EpV63VLAZVJqyVwqQj1WCI2m0sZGTgzXF83HkQ+44OAwRd+/sOaE20vmKvYmlT 36kGk2sd4GMMWPOxwa4EBhU0TxNUpffdyIDvY= 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=GLaXGgH4O8WRc84Pr2qZRgc6Y4dR2xbO1cV7z28yhvw=; b=HCKg58KQHNZkqVIQlsMG5Zb7c58HHShspn53TL1MPuipKzvRKf9xG/z5OH75hcfyxu KiWnnJQqm8iTO5gdzc7tYGg1rIgjU7pcxTtCYF2fGIhRF3ff9DZ5AiUiTnoWDRaSHTgn Z+dcmPRSDSk+InM+5QDNQbdMsrM+q7NuffzSYMf4iFwJVlVGEbP66FFkENa3yGxnAu83 bfstwgubvd2xmahCLZkGRiy43+nUbEvlYYuqt8r4oOygMnbs/Ip6XTNJO4Slixe18Ywh mKIrox8tMjMwj0rdhOhVBmxhNiZIk/M9tgsedebizAND7zoyTTgcUFz2Xoj4EEKsNB/Q KuPA== X-Gm-Message-State: APjAAAWLiyBwTKFvrv3LLeznNGSljSG8fy3tT/C+/ajFcqrt8Gc1EQ4H AjpIUYzs5Qa/pKWI+U1Ws0N0bdwG//4= X-Google-Smtp-Source: APXvYqxzBU+bq7N0UXa/cgeyso8wrb8HoY+V6GdSz4QWMY1EkgJHQhTcZ3SL2fTP8Nirod3X2GIkeQ== X-Received: by 2002:ac2:5596:: with SMTP id v22mr2690013lfg.200.1579724159544; Wed, 22 Jan 2020 12:15:59 -0800 (PST) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com. [209.85.208.171]) by smtp.gmail.com with ESMTPSA id v8sm21015819lji.16.2020.01.22.12.15.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2020 12:15:58 -0800 (PST) Received: by mail-lj1-f171.google.com with SMTP id y4so458763ljj.9 for ; Wed, 22 Jan 2020 12:15:58 -0800 (PST) X-Received: by 2002:a05:651c:282:: with SMTP id b2mr20649915ljo.41.1579724158165; Wed, 22 Jan 2020 12:15:58 -0800 (PST) MIME-Version: 1.0 References: <12a4be679e43de1eca6e5e2173163f27e2f25236.1579715466.git.christophe.leroy@c-s.fr> In-Reply-To: From: Linus Torvalds Date: Wed, 22 Jan 2020 12:15:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/6] fs/readdir: Fix filldir() and filldir64() use of user_access_begin() To: Christophe Leroy Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux Kernel Mailing List , Linux-MM , Paul Mackerras , Alexander Viro , linux-fsdevel , Andrew Morton , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, Jan 22, 2020 at 12:00 PM Linus Torvalds wrote: > > A bit more re-organization also allows us to do the unsafe_put_user() > unconditionally. I meant the "user_access_begin()", of course. Code was right, explanation was wrong. That said, with this model, we _could_ make the unsafe_put_user(offset, &prev->d_off, efault_end); be unconditional too, since now 'prev' will actually be a valid pointer - it will match 'dirent' if there was no prev. But since we want to test whether we had a previous entry anyway (for the signal handling latency issue), making the write to the previous d_reclen unconditional (and then overwriting it the next iteration) doesn't actually buy us anything. It was the user_access_begin() I'd rather have unconditional, since otherwise it gets duplicated in two (very slightly) different versions and we have unnecessary code bloat. Linus