Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5069451ybl; Wed, 22 Jan 2020 09:43:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwyHEGNLKosYRXumvUj1nkTgM0CzV4gPr0ottp0Ikqk4pgXusudefXtdgLzz0RH4AjpuT/W X-Received: by 2002:aca:e146:: with SMTP id y67mr7296620oig.93.1579715007083; Wed, 22 Jan 2020 09:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579715007; cv=none; d=google.com; s=arc-20160816; b=FivhUJFwT0UZg5lHWxqz7E2BMzvRqD6gMYJ1SC0yVvXjH0vS1GsYgiHrQgdLUxyxnJ oGs4boxSZbjJ2YVeEsFvJHuyPEJHINvYxMajjp7YGeBTgJ41GUs/+97X16nWYNRFy+Sr Z5kgjO/hYbxUQjZFp0bbn6wN8eGI0W7X2OBqJvzYMo5rLaVqhUO7KV7oTQwSixrpKAUe GDKHIbSLjYvF01P2Q3lKUX6ix2JU1G4ypDCbS0sFB0nmoK8EuYNBhA82KfENio1EWbGN sL5V6KcI1BRqhQ/bi3jHdGIJC62bE9YFytwENbuAEn7KwgM+30UPF8Agsat/nlpWMUni xKAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=24nXVGNihp6P5QO9XwKTkQp/ccb3B1yMPPAU+dzzXac=; b=vklgvmqtGPlxD1Lt4gEsr82M5CqGXVWXdTNP58gNsLmwSjzCeVHHD8b8TXzt5zQoH4 JbHuq9xtosbq6i5ptyGVc/YsvMJeJX3FOJHzZM7fujYjdwzKsYf7zOfwWCctqR+t0fcs iHHCV128PumYOh3lVWP4Rc/Fvh1aqM4cx+rFhm/aUuWpx5idgA5yhfNfwX6/NHxjHB0j qJamy9Rdphgjmt9mhukZ8h/bDJSo59JhpiWfD4Ukv5k8GtCZbnYABheeq1pGkiop62ij dTYeC8UFJvjSkuM++FkOGBi2ZyvkgL9Kod4cbrsYRuUF0oY35pf4/USnwg4PHJuBLvkJ 9B/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 r10si21958752otn.241.2020.01.22.09.43.14; Wed, 22 Jan 2020 09:43:27 -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; 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 S1729009AbgAVRln (ORCPT + 99 others); Wed, 22 Jan 2020 12:41:43 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:38948 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgAVRlm (ORCPT ); Wed, 22 Jan 2020 12:41:42 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iuK0P-000izi-Q7; Wed, 22 Jan 2020 17:41:29 +0000 Date: Wed, 22 Jan 2020 17:41:29 +0000 From: Al Viro To: Linus Torvalds Cc: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Andrew Morton , Linux Kernel Mailing List , linuxppc-dev , linux-fsdevel , Linux-MM Subject: Re: [PATCH v1 1/6] fs/readdir: Fix filldir() and filldir64() use of user_access_begin() Message-ID: <20200122174129.GH23230@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 08:13:12AM -0800, Linus Torvalds wrote: > On Wed, Jan 22, 2020 at 5:00 AM Christophe Leroy > wrote: > > > > Modify filldir() and filldir64() to request the real area they need > > to get access to. > > Not like this. > > This makes the situation for architectures like x86 much worse, since > you now use "put_user()" for the previous dirent filling. Which does > that expensive user access setup/teardown twice again. > > So either you need to cover both the dirent's with one call, or you > just need to cover the whole (original) user buffer passed in. But not > this unholy mixing of both unsafe_put_user() and regular put_user(). I would suggest simply covering the range from dirent->d_off to buf->current_dir->d_name[namelen]; they are going to be close to each other and we need those addresses anyway...