Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A0F6C433EF for ; Mon, 6 Dec 2021 14:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245138AbhLFOIa (ORCPT ); Mon, 6 Dec 2021 09:08:30 -0500 Received: from verein.lst.de ([213.95.11.211]:50605 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244907AbhLFOIY (ORCPT ); Mon, 6 Dec 2021 09:08:24 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id 49AB068AFE; Mon, 6 Dec 2021 15:04:51 +0100 (CET) Date: Mon, 6 Dec 2021 15:04:51 +0100 From: Christoph Hellwig To: Amit Daniel Kachhap Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Vincenzo Frascino , Kevin Brodsky , linux-fsdevel , kexec , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Young , Baoquan He , Vivek Goyal , x86 Subject: Re: [RFC PATCH 01/14] fs/proc/vmcore: Update read_from_oldmem() for user pointer Message-ID: <20211206140451.GA4936@lst.de> References: <20211203104231.17597-1-amit.kachhap@arm.com> <20211203104231.17597-2-amit.kachhap@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211203104231.17597-2-amit.kachhap@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 03, 2021 at 04:12:18PM +0530, Amit Daniel Kachhap wrote: > + return read_from_oldmem_to_kernel(buf, count, ppos, > + cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)); Overly long line. > +ssize_t read_from_oldmem(char __user *ubuf, char *kbuf, size_t count, > + u64 *ppos, bool encrypted) > { > unsigned long pfn, offset; > size_t nr_bytes; > @@ -156,19 +163,27 @@ ssize_t read_from_oldmem(char *buf, size_t count, > /* If pfn is not ram, return zeros for sparse dump files */ > if (!pfn_is_ram(pfn)) { > tmp = 0; > - if (!userbuf) > - memset(buf, 0, nr_bytes); > - else if (clear_user(buf, nr_bytes)) > + if (kbuf) > + memset(kbuf, 0, nr_bytes); > + else if (clear_user(ubuf, nr_bytes)) > tmp = -EFAULT; This looks like a huge mess. What speak against using an iov_iter here?