Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5205328ybl; Wed, 22 Jan 2020 12:18:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzNR6sf7oHGPbmL3o9ZYyuiqFm+cZMN7DclEkdyGFGfcKcdvr5pPSfFi5HHdRHUBgxgNoxg X-Received: by 2002:a05:6808:315:: with SMTP id i21mr7841762oie.139.1579724298157; Wed, 22 Jan 2020 12:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579724298; cv=none; d=google.com; s=arc-20160816; b=Qwx0xkhYqTfcVRDDztKez3EEhnDrKoMWiMkZVyRizR8CDaqBDolmc2f6INzz/v9PrP t6j4mnalHErWcPXRjWCHPspHIS9XGXxkYmGLTerGupvUkxFPp0+nmGDIWzxE5S2DyIaf 785ffM9+BBfdbR5XGOwaoxb5GBUzr2JpOCcl9oZuLYns2TGfdpC8OKe1Igs23v3eGOWw YYYecZlygN/HHU8viB0lZV78eTna95nClFlhQ+CEm/kSC2+ljCudmA6H88q5G1Ta4aHL XzOUinswJ1NmVyAlbD7X57LntV/CoGJzT5ucNC/WGcPzTsZVgQwWyH3+zQ+iFnEP3MSw RdqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GLaXGgH4O8WRc84Pr2qZRgc6Y4dR2xbO1cV7z28yhvw=; b=OL/hBcMvi2ppFPTw0AvjeE8+wxst2EpgsHqhpQ9lpvV8FUWIWZidKVgmm2b8IoX8XK lyUn++tf16xeRgmXvbkdiJVtbYIRFmBSLE4LWU1JFof50YA0cTy8y1XENRrhOLpS2Db6 7xaMi+CN53V/FeVTxcGLC9SHpNpuCbbnNPPa5FvlYwqIfYYii83Q1qy1Q69ibbPG1MzS kJXUEy1XIYOIA9EUawuDW9opYm1/QyICeHTAWPAbhqLHDhdMt2rleCUweXbCfRcPh6dp FD5zOmdqj5xRnb99OLsyWogUAC4KnP5bR79+YckPJdEWXawrVfKkmJvAONAMAtpRIPa5 FITg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="c6/3aq9H"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si22096443oih.217.2020.01.22.12.18.05; Wed, 22 Jan 2020 12:18:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="c6/3aq9H"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728998AbgAVUQD (ORCPT + 99 others); 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-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