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=-15.5 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 D2426C4338F for ; Mon, 2 Aug 2021 07:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A21B360EE3 for ; Mon, 2 Aug 2021 07:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232211AbhHBHZ0 (ORCPT ); Mon, 2 Aug 2021 03:25:26 -0400 Received: from mail-ej1-f51.google.com ([209.85.218.51]:41856 "EHLO mail-ej1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbhHBHZZ (ORCPT ); Mon, 2 Aug 2021 03:25:25 -0400 Received: by mail-ej1-f51.google.com with SMTP id x11so28410026ejj.8 for ; Mon, 02 Aug 2021 00:25:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WcetUWPb8culgJfYwcXyd4enV0COOIi+oGgXXHCJxs8=; b=kTt84qINj5N5gTXBGk9fMhNsqnP+XO5ahzaHBM/BHhvdufKyM810SIVRSNAk6h6CmI Zj+4UZ4b2JTdSHVlegPyXXfbVasbDqhA4SSmDsX3Gm1c7D4+I4usHLMoFcGprbzwswGU SreMiL8EgR/17sO3oM5V5vIMHYyODpXyd51ODUVE6CsP5s5mQK+/kNZ0BMoGoHe1YHMh pZhrYp0OLM07LSvQ2gXJRp85y5tlwiU8lUpfmzMLn0RdLZxkHBt0n0J5Z02V3xZDatpO 9DyMBgECgCsgqba7k5s8ck8rovsb4TXWHm+PQ1tyTypmPLN4locXqdq4NH3XKzsB3V+o W/6w== X-Gm-Message-State: AOAM5334cCPBenRM1G9DTQRmObf2dUSdQJgsPR5NJEE6DjrwFG2x4vWa dJL0Fp+jm2hHHq0qGNMl3sQ= X-Google-Smtp-Source: ABdhPJxWTIdE9MBJiFVNAsUjUXU9AE4QP/vAPTBU9gQDwWpXVj1nFXiA6JbVTS8aEqGldEf1vZCzFQ== X-Received: by 2002:a17:906:394:: with SMTP id b20mr14197279eja.462.1627889114838; Mon, 02 Aug 2021 00:25:14 -0700 (PDT) Received: from ?IPv6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id i11sm5384121eds.72.2021.08.02.00.25.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 00:25:14 -0700 (PDT) Subject: Re: [PATCH 2/2] virtio-console: remove unnecessary kmemdup() To: Xianting Tian , gregkh@linuxfoundation.org, amit@kernel.org, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, osandov@fb.com References: <20210801051655.79048-1-xianting.tian@linux.alibaba.com> From: Jiri Slaby Message-ID: Date: Mon, 2 Aug 2021 09:25:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210801051655.79048-1-xianting.tian@linux.alibaba.com> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, why is this 2/2? I seem (Lore neither) to find 1/2. On 01. 08. 21, 7:16, Xianting Tian wrote: > hvc framework will never pass stack memory to the put_chars() function, Am I blind or missing something? hvc_console_print(...) { char c[N_OUTBUF] ... cons_ops[index]->put_chars(vtermnos[index], c, i); The same here: hvc_poll_put_char(..., char ch) { ... n = hp->ops->put_chars(hp->vtermno, &ch, 1); AFAICS both of them *pass* a pointer to stack variable. > So the calling of kmemdup() is unnecessary, remove it. > > Fixes: c4baad5029 ("virtio-console: avoid DMA from stack") This patch doesn't "Fix" -- it reverts the commit. You should've CCed the author too. > Signed-off-by: Xianting Tian > --- > drivers/char/virtio_console.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index 7eaf303a7..4ed3ffb1d 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -1117,8 +1117,6 @@ static int put_chars(u32 vtermno, const char *buf, int count) > { > struct port *port; > struct scatterlist sg[1]; > - void *data; > - int ret; > > if (unlikely(early_put_chars)) > return early_put_chars(vtermno, buf, count); > @@ -1127,14 +1125,8 @@ static int put_chars(u32 vtermno, const char *buf, int count) > if (!port) > return -EPIPE; > > - data = kmemdup(buf, count, GFP_ATOMIC); > - if (!data) > - return -ENOMEM; > - > - sg_init_one(sg, data, count); > - ret = __send_to_port(port, sg, 1, count, data, false); > - kfree(data); > - return ret; > + sg_init_one(sg, buf, count); > + return __send_to_port(port, sg, 1, count, (void *)buf, false); > } > > /* > -- js suse labs 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=-15.5 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 31D57C4338F for ; Mon, 2 Aug 2021 07:25:41 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 421BA60EE3 for ; Mon, 2 Aug 2021 07:25:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 421BA60EE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GdV0L5T50z3bnG for ; Mon, 2 Aug 2021 17:25:38 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.218.48; helo=mail-ej1-f48.google.com; envelope-from=jirislaby@gmail.com; receiver=) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GdV000TGmz2yhd for ; Mon, 2 Aug 2021 17:25:19 +1000 (AEST) Received: by mail-ej1-f48.google.com with SMTP id e19so29328614ejs.9 for ; Mon, 02 Aug 2021 00:25:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WcetUWPb8culgJfYwcXyd4enV0COOIi+oGgXXHCJxs8=; b=F9F+P9HIitF2nx6blNgSeDlfB2MYKWDSvLc/H74vTbfAPiFtSs5C+xaFKg2VhppwwD ewrD/akPsJboa72PG1WqUxKLYdZjl1yKY4W4HDvSoF0XnaePC4K4NNaGpawotcePcjk/ 7QKh7RtXEDtJIsUobkoOAWY6Yy0G8QstRwERE4i5L8P8hEBcAaaCyo6QZv8V5ud2pjQ6 UuN1XZJXCviksA8wBebJGLCjiuywEQWfRK0oMNyFkEuXe7P/MN/lmtPaD3edu+HvwGxJ UqP6CizLelNWSVNwLPODMSAd83GoyEY+SDMOHRCMSXlWWL9i4et03Lx5VV7cADI1EQnC LLeA== X-Gm-Message-State: AOAM533BO3OjbSu2sxbM5Y7ZxUt+z6H9GHZGQ/qepjAep3czwdWeOCMk BBPh0i4DEj/sidV21+VgrKo= X-Google-Smtp-Source: ABdhPJxWTIdE9MBJiFVNAsUjUXU9AE4QP/vAPTBU9gQDwWpXVj1nFXiA6JbVTS8aEqGldEf1vZCzFQ== X-Received: by 2002:a17:906:394:: with SMTP id b20mr14197279eja.462.1627889114838; Mon, 02 Aug 2021 00:25:14 -0700 (PDT) Received: from ?IPv6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id i11sm5384121eds.72.2021.08.02.00.25.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 00:25:14 -0700 (PDT) Subject: Re: [PATCH 2/2] virtio-console: remove unnecessary kmemdup() To: Xianting Tian , gregkh@linuxfoundation.org, amit@kernel.org, arnd@arndb.de References: <20210801051655.79048-1-xianting.tian@linux.alibaba.com> From: Jiri Slaby Message-ID: Date: Mon, 2 Aug 2021 09:25:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210801051655.79048-1-xianting.tian@linux.alibaba.com> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: osandov@fb.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi, why is this 2/2? I seem (Lore neither) to find 1/2. On 01. 08. 21, 7:16, Xianting Tian wrote: > hvc framework will never pass stack memory to the put_chars() function, Am I blind or missing something? hvc_console_print(...) { char c[N_OUTBUF] ... cons_ops[index]->put_chars(vtermnos[index], c, i); The same here: hvc_poll_put_char(..., char ch) { ... n = hp->ops->put_chars(hp->vtermno, &ch, 1); AFAICS both of them *pass* a pointer to stack variable. > So the calling of kmemdup() is unnecessary, remove it. > > Fixes: c4baad5029 ("virtio-console: avoid DMA from stack") This patch doesn't "Fix" -- it reverts the commit. You should've CCed the author too. > Signed-off-by: Xianting Tian > --- > drivers/char/virtio_console.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index 7eaf303a7..4ed3ffb1d 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -1117,8 +1117,6 @@ static int put_chars(u32 vtermno, const char *buf, int count) > { > struct port *port; > struct scatterlist sg[1]; > - void *data; > - int ret; > > if (unlikely(early_put_chars)) > return early_put_chars(vtermno, buf, count); > @@ -1127,14 +1125,8 @@ static int put_chars(u32 vtermno, const char *buf, int count) > if (!port) > return -EPIPE; > > - data = kmemdup(buf, count, GFP_ATOMIC); > - if (!data) > - return -ENOMEM; > - > - sg_init_one(sg, data, count); > - ret = __send_to_port(port, sg, 1, count, data, false); > - kfree(data); > - return ret; > + sg_init_one(sg, buf, count); > + return __send_to_port(port, sg, 1, count, (void *)buf, false); > } > > /* > -- js suse labs