From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbdHQJBg (ORCPT ); Thu, 17 Aug 2017 05:01:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:36462 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752419AbdHQJBc (ORCPT ); Thu, 17 Aug 2017 05:01:32 -0400 Date: Thu, 17 Aug 2017 10:53:32 +0200 From: Jan Kara To: Ross Zwisler Cc: Andrew Morton , linux-kernel@vger.kernel.org, Alexander Viro , Christoph Hellwig , Dan Williams , Dave Chinner , Jan Kara , Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, Kees Cook , Will Deacon , Catalin Marinas , Robin Murphy , Mark Rutland Subject: Re: [PATCH] dax: explain how read(2)/write(2) addresses are validated Message-ID: <20170817085332.GA7644@quack2.suse.cz> References: <20170816173615.10098-1-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170816173615.10098-1-ross.zwisler@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 16-08-17 11:36:15, Ross Zwisler wrote: > Add a comment explaining how the user addresses provided to read(2) and > write(2) are validated in the DAX I/O path. We call dax_copy_from_iter() > or copy_to_iter() on these without calling access_ok() first in the DAX > code, and there was a concern that the user might be able to read/write to > arbitrary kernel addresses with this path. > > Signed-off-by: Ross Zwisler Looks OK to me so feel free to add: Reviewed-by: Jan Kara Just I'd note that standard buffered read / write path is no different so I don't see a big point in adding this comment when it is not in any other path either... Honza > --- > > Adding a comment instead of adding redundant access_ok() calls in the DAX > code. If this is the wrong path to take, please let me know. > > fs/dax.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/fs/dax.c b/fs/dax.c > index 8c67517..2d50f32 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -1060,6 +1060,11 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, > if (map_len > end - pos) > map_len = end - pos; > > + /* > + * The userspace address for the memory copy has already been > + * validated via access_ok() in either vfs_read() or > + * vfs_write(), depending on which operation we are doing. > + */ > if (iov_iter_rw(iter) == WRITE) > map_len = dax_copy_from_iter(dax_dev, pgoff, kaddr, > map_len, iter); > -- > 2.9.5 > -- Jan Kara SUSE Labs, CR