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