Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3384838imw; Mon, 18 Jul 2022 07:12:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tP+trqgARdkVkNtAXMDJ53IyxfnGCKZxXSeruSOmJ4cYmEtp7sAv6WHRRBEpCNkgLGjumN X-Received: by 2002:a05:6402:2804:b0:439:83c2:8be2 with SMTP id h4-20020a056402280400b0043983c28be2mr37506403ede.292.1658153564201; Mon, 18 Jul 2022 07:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658153564; cv=none; d=google.com; s=arc-20160816; b=kH7HV561U/kfmMI8eVqqQMUKpPOz3BTxYOpLfxIUmJO/4MAUv7yV7zdhuEKOQiIPGK LOU4IKRkt38SVCwOCZN3M7TTxpVKM4Fco8H7rVnqp+PhbeadJ3A1dmUZvR/XFBqo/Hdc 8ap+aK6+G9VniWsb7vsAgy/h0ylRyLIuOKJyt3D3lGTckZC9VeMco3ROm5AOOhRxoHtJ KWb/ieDSh9TnrUaAVmlaegUSB+Cgzs495pXo/V/4zt/sFYrOVUpiAArZ5dfUkHcXrecr dU7Ab+yrhkiJSH/MA5f3OpSFW5Jj5pWP/2DIRsafhMBbe5B/yDoTq+Y8JQ3qp1g+5yOX P4Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=he4BsFEqlETpQMe0yQVdnX/HTL6ufCO0M/YAN+bslNU=; b=mbnYN+MsvMSF6a67GPBlJ6b6gP0EWzHuB3T7ssPXjCkyMKO+yGuEYxmNCqm5gAPlGI Lu7XzhPMhczqDDG7qn0G8QbaneIeF3BT1pS2YaR3Qf2g7NZfgicYvEirh79b+k9unnVC vU3+4Z3Lnj8wfEJngkd6WpnOW3CeMw8C5qryxHmT5/pUoePF8U6NwjGTQwNTBuyBm9QY RIYL34G+dqYYwkxzRq9FXPbLcUVGKHzna3waWE8D/fjA+CoKtsUeJQlTxv5DibgAJZ6s /yJnAed5uvHI8NjyNwg12TjaKPSr9lV6lcXPZeVkt1UFKY+gxrGze+smV3wHt+EDfj+4 2XSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=d1bPonhb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a05640235d600b0043ae0b9e568si17985987edc.436.2022.07.18.07.12.10; Mon, 18 Jul 2022 07:12:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=d1bPonhb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235482AbiGRNsf (ORCPT + 99 others); Mon, 18 Jul 2022 09:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235446AbiGRNsc (ORCPT ); Mon, 18 Jul 2022 09:48:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C3E255BE; Mon, 18 Jul 2022 06:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=he4BsFEqlETpQMe0yQVdnX/HTL6ufCO0M/YAN+bslNU=; b=d1bPonhbieaRwnjlWIosd26sbt 4eaqaKU7ZGwauPRt0tQTKkz3dQk22w2G67cJSDwS2ILMIv52NZkkdgKPJQ3tfu0ri9Ux+fSpxLK6E Tb3UNKjFZmOw8Y19GLoITRPuOf54w3UVeaeOgYym2PHAkHmlZVxdwL0kRsDblEype+2f2pdtzs4C2 XSWzyZWPhIPcVfXaPP9fNM/5zmu5Qad8JePz6noKGSiOuASDo/b8+ct/ZjMSK8N7NKkI9caikM4fR yeip29miYKwy6bhGhb4Ra/P2+EPrmqMdNBOajMgNLbD5FNzIuF2qbSooIDtb31jTQ1hlw+1oHkknN lLqend1g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDR6j-00Cj5t-My; Mon, 18 Jul 2022 13:48:21 +0000 Date: Mon, 18 Jul 2022 14:48:21 +0100 From: Matthew Wilcox To: Alexander Gordeev Cc: Alexander Egorenkov , Heiko Carstens , Baoquan He , Christoph Hellwig , Vasily Gorbik , Al Viro , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH v3 2/3] s390/crash: use static swap buffer for copy_to_user_real() Message-ID: References: <77d50b4a2359d1791835b6111edaa155eb11c5ea.1658148067.git.agordeev@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <77d50b4a2359d1791835b6111edaa155eb11c5ea.1658148067.git.agordeev@linux.ibm.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18, 2022 at 03:32:40PM +0200, Alexander Gordeev wrote: > +++ b/arch/s390/kernel/crash_dump.c > @@ -53,6 +53,7 @@ struct save_area { > }; > > static LIST_HEAD(dump_save_areas); I'd suggest you need a mutex here so that simultaneous calls to copy_to_user_real() don't corrupt each others data. > +static char memcpy_real_buf[PAGE_SIZE]; > > /* > * Allocate a save area > @@ -179,23 +180,18 @@ int copy_oldmem_kernel(void *dst, unsigned long src, size_t count) > static int copy_to_user_real(void __user *dest, unsigned long src, unsigned long count) > { > int offs = 0, size, rc; > - char *buf; > > - buf = (char *)__get_free_page(GFP_KERNEL); > - if (!buf) > - return -ENOMEM; > rc = -EFAULT; > while (offs < count) { > size = min(PAGE_SIZE, count - offs); > - if (memcpy_real(buf, src + offs, size)) > + if (memcpy_real(memcpy_real_buf, src + offs, size)) > goto out; > - if (copy_to_user(dest + offs, buf, size)) > + if (copy_to_user(dest + offs, memcpy_real_buf, size)) > goto out; > offs += size; > } > rc = 0; > out: > - free_page((unsigned long)buf); > return rc; > } > > -- > 2.34.1 >