Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp112084lqo; Tue, 7 May 2024 14:00:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSLmIgHn8X53kPsi82UsJXWMyLfxsJlolbGZzuP/X7Y3S8+FGveJQFGWopydRGJ1Kl6zNKCoEPvBloW4HdfqXJ2C3C12Vk7ubbx2xOZQ== X-Google-Smtp-Source: AGHT+IH+Ma2UiEoqr87ZqiJfvvCzxeVqZU/Z+EDwzzqG2a6IdER2VJuydLj5hzkfZQmVcfSUYB1M X-Received: by 2002:a05:6359:4106:b0:18b:d44:52b6 with SMTP id e5c5f4694b2df-192d2d229a9mr114637455d.16.1715115616285; Tue, 07 May 2024 14:00:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715115616; cv=pass; d=google.com; s=arc-20160816; b=WYJnvOQtjgLQ1VbF6cxeS21sbNaLAlXKcg7gjCHKQ0icf7RkpqBwQRttpRscMi5BX0 28zO9Dalc6XRYmYf5L3VsObel8oB+I9XIObF3Z1bw6ORK293GgEilP2W190cZ2hVINee Mf/eTIQ8hw6+HyWXgKxI6/txQGIgQ3+wl1IaeJStkvgsI7XUNCO0oEbuQ7pQvPu2fNUu 1cYi1o12ILBCvRA0FH+wptVGuavdsXlg5gcE4kAaGR8T4jl9v6qWgDoppNS30p0P+vfs fzQyfALLgrzfj7PBeQuSYtvoyOrA7odsSXveyn6Gn+viXLINyO58+kueiCNH24RdFcpb Y1HQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=bk57LfF5IJRUTZp8F/Afjo6cLQ7YrYnev8qqlUkN1Fs=; fh=m0H+pFiL0qDd8rDn5w2kHqINFpkmsrZtXBYM/dTRLS4=; b=yo8xNwmXSV86ePtomXSSWAjeya6YKQks1+kDEfKYMqWQs272/xnuPAjLkxMaWxtZ7Q gWcFt62QAmn0EtduJ/2A6QSsAMDcq5JB27cRK4blL9/Td2yeg+ibDqsEvtI4AMgDLGwy iTwGNwGvvI9E3Am8FPIhTBDUoIXrq9Ut2qFms1qJkFchUGWYw6gc7dHsxMXqGlcskJ4s ZOedwFAm5Ruzg19uSx6+1iILu1qPv/3kjNOvRJXiGvlhNQ0RgxgFvKlzb2MrwJEulnOM vY5US/Qtx9f/0eaHAkOi3VVUscT3MeOQdjyS/B7QcGQDqp8RYt2c2jinCKfKhDzmCQ6w uxxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=jHLGKIa3; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=kObYxWcr; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-172169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s8-20020a632c08000000b005f7ddef45bfsi9175480pgs.789.2024.05.07.14.00.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 14:00:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=jHLGKIa3; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=kObYxWcr; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-172169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4ABD2B24DBF for ; Tue, 7 May 2024 20:49:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C775356B6F; Tue, 7 May 2024 20:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="jHLGKIa3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="kObYxWcr" Received: from wfout1-smtp.messagingengine.com (wfout1-smtp.messagingengine.com [64.147.123.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC03454FAA; Tue, 7 May 2024 20:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.144 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715114932; cv=none; b=RswfOPwZhD71jVX5rtFQFpNW+AuP6lZ35W8EKfW3eWrEBqzbH92omItNbn8fZrS9/dqDew463rbZ7cli6HAm/Z8Smu8xS9mJ6vZLyx4ZzgLMqPSxNywDmdfIUPj+sI4ka21osWHHfeSPCZ2qL9lJYOXqJ4ue13Jwmcbf3W55fYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715114932; c=relaxed/simple; bh=HEUFsU6+GbrvvWJ5r0D3OYRudWAEMmNWkbpg2pnlAck=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=sUHfAz5FxE00XIVobYAviz2PSX4ZMXDH4z3QIlzWxL5Tbg5yPiaybGAW1nmyi43ioS83sQWHvL/y/wz+kYTtShdxKecVFfFQEdsXkxE/8ze6k5sz08mcwjw1IFWSuYO5Y7wHZWgNd03IbGd6thlJqKerg5r89N0dEXuDicpBNaY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=jHLGKIa3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=kObYxWcr; arc=none smtp.client-ip=64.147.123.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id 94C0C1C0010C; Tue, 7 May 2024 16:48:49 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Tue, 07 May 2024 16:48:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1715114929; x=1715201329; bh=bk57LfF5IJ RUTZp8F/Afjo6cLQ7YrYnev8qqlUkN1Fs=; b=jHLGKIa3qEI3RgJasiaH9SsUaw X79aOnnHvHVgkOosQFLPc0t963nlCvuO6Yc03ZS1ruBcJ8btrM3KtGhm5FxgW0Ll zgA8HBjq6ioGdUnu/Ddd8+KRNY0lCeGYsZmDdULvrjAgxa2JuSpsTUx4I/shvVDy w3VqVmVATXrwND1RmJWvN04/R6aVOcCdohU+3Iq9YDWEbzy3TeLH7wT5HApuDuYI Pt/0hPQIYxVXD4YlvA9gvX2MZdfIPWTBngvCVprCECXA4110EDIjq5K0A1pXtYuK 6k635JQn+T8nEHKyjiFKlUxx8uk8hHvs9+lk9iO7QLjrIY69zC/tHlEsUaJw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715114929; x=1715201329; bh=bk57LfF5IJRUTZp8F/Afjo6cLQ7Y rYnev8qqlUkN1Fs=; b=kObYxWcrRekpOxEtvCJBSwu9WrJ3saNNzge2zGuNoBkK OCyjfJ1ke1ifE84O6HIWbIQtCfLaWYOdA9eVjNm4Rh3ezbzgqIzT81Z/15epD+g5 9hI2FzEvaKdhx1O81buQ28ue1Obdqnhy/FvqLCFQKEOyHeDPd5kgraO0GFHSWylJ 0H2ReUCM8VrfN6izgNefffb9qTCNp32uyxrqKK2ek+U64enwd2iP0it6T05+PCAX 015josKe+GqYO0MTd2AZdQ6Y2yvZD+u0abyxgeZsAyaKKQr6dOuQBfp2VUQNYn3u lzG9vKW8vbO6RC+bNlbz2O0WZZlpRfU0fOrelwouOA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvkedgudehudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedt keetffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id BB590B6008F; Tue, 7 May 2024 16:48:48 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-443-g0dc955c2a-fm-20240507.001-g0dc955c2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <29b33c18-f123-4656-8507-406c87a12ec8@app.fastmail.com> In-Reply-To: <20240507201238.213396-2-thorsten.blum@toblux.com> References: <20240507201238.213396-2-thorsten.blum@toblux.com> Date: Tue, 07 May 2024 22:48:26 +0200 From: "Arnd Bergmann" To: "Thorsten Blum" , "Srinivas Kandagatla" , "Amol Maheshwari" , "Greg Kroah-Hartman" Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] misc: fastrpc: Use memdup_user() Content-Type: text/plain On Tue, May 7, 2024, at 22:12, Thorsten Blum wrote: > Switching to memdup_user() overwrites the allocated memory only once, > whereas kzalloc() followed by copy_from_user() initializes the allocated > memory to zero and then immediately overwrites it. > > Fixes the following Coccinelle/coccicheck warning reported by > memdup_user.cocci: > > WARNING opportunity for memdup_user > > Signed-off-by: Thorsten Blum The patch looks correct to me. > --- > drivers/misc/fastrpc.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index 4c67e2c5a82e..2857cddaf812 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -1259,17 +1259,12 @@ static int > fastrpc_init_create_static_process(struct fastrpc_user *fl, > goto err; > } > > - name = kzalloc(init.namelen, GFP_KERNEL); > - if (!name) { > - err = -ENOMEM; > + name = memdup_user((void __user *)(uintptr_t)init.name, init.namelen); > + if (IS_ERR(name)) { > + err = PTR_ERR(name); > goto err; > } There is also a chance to simplify this further using u64_to_user_ptr() instead of the double cast if you want. Acked-by: Arnd Bergmann Arnd