Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp534795lqh; Tue, 7 May 2024 06:56:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPRt0EAW5Gs3EFdIJW8TKCpJxgdWBeCTv8lz+KrX/AMVUiFtxLJo29iD6hMrCxPNxmFcv9hP2dRKvh1ssOT8l/JMYg2kNOOzZ2fWUrBA== X-Google-Smtp-Source: AGHT+IHHURgfPt7/3ZXBytx86hJDqLdirLNtwVu7+cCt41xfIQX3ZScoDg1vP1lvjcSlP9tNfgVJ X-Received: by 2002:a05:6214:2462:b0:6a0:cf21:abc9 with SMTP id im2-20020a056214246200b006a0cf21abc9mr16875968qvb.6.1715090197228; Tue, 07 May 2024 06:56:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715090197; cv=pass; d=google.com; s=arc-20160816; b=ojV171RnEYfEItybkpBLD5Nzrau1n5mQRjQ/6v1V9RenEvx4O9XDzFGDByT+LfFzYb yvST16sjssnLsguJmdsNT8HExDzOgqUy2KYJN2agtJ4xBSuAFJpM4mCEpjRcoj9a1J3E 3sUnD+wkKa1Q2FDSUs3Bo3HLGCWChPjsqNy7AqjyM+Ddk+2ll3tOQn18SfbDXjuyo03x fFv9g7xVrgDpjFU2woxgX4i3Mcpdvh51b7rHbrSKVcwtGS9Y3Re1BKTVHXxL1pEaI3q5 1qoA6CO/cSird5hrUrzvvaTI2PGDcEkMB6tXEdcmm6R1Gg67B0pWfdqPMETHXljT+o8c AUpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=5Cllnt0584C2d9JWXBonYHexJ7Kt7quU4B5rCiNuDu4=; fh=FK62yusUMaDBmj0XzT+Hwecnq10A8BzKUY7CdcDViFg=; b=ZES6+JpihI6th0f3dOvJXDh/AXoI+KeNhJr0da8sFN7L3pMbCejRY93o4R6JL67McK +hmH/sTo9Db3qpOTyYgQ6ebGBmM8NOddO1Myq97Oxsh2lO5QjeRVkM7mcPPFm2iDRfRE Cc362ThnEVgdDTSL4Pncn4NA6TOxiGfuryAjnedx8j52xeoKfDZX3EaDjgzo0uYNfXpU 42msOMIONqeWtShSSknW8CMIB8YaR6ZBAoibOyOwPy9uF+TvbvQaHIUq9U2btbb05Js1 jgKv0L3qAj3QjEudheDJAi+1hDmejghWaJClpAqUDmOcfh5MxVXWfYS/XPeuUKVXfGEb qSqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lKiwXRgo; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-171482-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171482-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m13-20020ad45dcd000000b006a09037ab16si11625794qvh.23.2024.05.07.06.56.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171482-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lKiwXRgo; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-171482-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171482-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E33811C2370F for ; Tue, 7 May 2024 13:56:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05EFC15EFC0; Tue, 7 May 2024 13:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lKiwXRgo" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 4C04315EFAE; Tue, 7 May 2024 13:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715090023; cv=none; b=CjBEEdw2YKzJ6kbPm9YmVidBeMtnT7r4u74oqn4LIQPumtFFr9h8TeraKNlm1qQkxw467LQrekn57Qx/Ft2lswAPTbTiGEb1NeyBOCJtPQavBXPh/dF+2pyFwjPCtpOPgYpCGUiBYSsnQVQl/eVANtTNupmrp+94gEb81Z/d1+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715090023; c=relaxed/simple; bh=QSB7S/LhI6JWUqm9lJDQdaIp2gPu/DOcCrLhezWQFN0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EcqWfrvTRivf87cCt3YZ62ltYbkhbcFK71TDa7awhkXoykZlJs0Ciln6d89eKbbxHKF+ipH2QWLUDpLqajnTVQvcHsRsz/lVh72fbJm0TaPtm9+bwA1whkKnV6Nhuzk74A3+FtS81/A52HddqCt2ftlS0ZAPUTVcIIYxV40pkNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=lKiwXRgo; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 447DgAWK027989; Tue, 7 May 2024 13:53:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=5Cllnt0584C2d9JWXBonYHexJ7Kt7quU4B5rCiNuDu4=; b=lKiwXRgoC38gQkjgwSLux11Ivt5uzNtzAGnhwzeyq3tIY/tNbTya041ia3bALWUanSq/ 8rdrTJKGXyoDRZYAF/xZnvnOB/tv7G4SZg5VFn1K8Y4eGGhuFWeAhRJ0vnR0r7IzR/EF w/Vjyt3zOqY/W0JPwe/U8qhELx3fhIilUr0Igfrc4sj2AllfLGTIlj39S3/iM/guGx2n x5N4LAq5RLHd8RuOhRnGDaAejy2+A/B9SaaTABz/wdH68l9BqApPUchehPOLGY4QUoKq 6Mx4t/krvpJF6Sw4Duhs22GBS0suJVo0kp5U7589/DS5ykLvKnOWV8gYlPdDq+Yb5quI uw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xyndn011x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 13:53:40 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 447DrdtA015788; Tue, 7 May 2024 13:53:39 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xyndn011t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 13:53:39 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 447ClfdS010584; Tue, 7 May 2024 13:53:38 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xx0bp6f86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 13:53:38 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 447DrXUG56754622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 May 2024 13:53:35 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EFBF020043; Tue, 7 May 2024 13:53:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6CCC220040; Tue, 7 May 2024 13:53:32 +0000 (GMT) Received: from [9.171.75.172] (unknown [9.171.75.172]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 7 May 2024 13:53:32 +0000 (GMT) Message-ID: Date: Tue, 7 May 2024 15:53:32 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] s390/pkey: use kvfree_sensitive() to fix Coccinelle warning To: Jules Irenge , svens@linux.ibm.com Cc: borntraeger@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, hca@linux.ibm.com, freude@linux.ibm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org References: Content-Language: de-DE From: Holger Dengler In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jISLAJNWvulb0UUZFACxiJDomZXIgCFj X-Proofpoint-ORIG-GUID: aqUcxu8K29swAtnzzdbpRUSbrsi2gEUv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_07,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405070095 On 06/05/2024 19:21, Jules Irenge wrote: > Replace memzero_expliocit() and kfree() with kvfree_sensitive() to fix > warnings reported by Coccinelle Thanks Jules for pointing that out. But instead of using kvfree_sensitive() I would recommend kfree_sensitive() here. We're not on a performance critical path so kfree_sensitive() would be in my opinion the better choice, because we don't need to take care about the right size. > WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1506) > WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1643) > WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1770) > > Signed-off-by: Jules Irenge > --- > Changes in v2: > - merges all patches that fixe same problem into one > > drivers/s390/crypto/pkey_api.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c > index dccf664a3d95..e1dd7e0bdfd4 100644 > --- a/drivers/s390/crypto/pkey_api.c > +++ b/drivers/s390/crypto/pkey_api.c > @@ -1503,8 +1503,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, > rc = pkey_keyblob2pkey(kkey, ktp.keylen, ktp.protkey.protkey, > &ktp.protkey.len, &ktp.protkey.type); > pr_debug("%s pkey_keyblob2pkey()=%d\n", __func__, rc); > - memzero_explicit(kkey, ktp.keylen); > - kfree(kkey); > + kvfree_sensitive(kkey, ktp.keylen); kfree_sensitive(kkey); > if (rc) > break; > if (copy_to_user(utp, &ktp, sizeof(ktp))) > @@ -1640,8 +1639,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, > &ktp.protkey.type); > pr_debug("%s pkey_keyblob2pkey2()=%d\n", __func__, rc); > kfree(apqns); > - memzero_explicit(kkey, ktp.keylen); > - kfree(kkey); > + kvfree_sensitive(kkey, ktp.keylen); kfree_sensitive(kkey); > if (rc) > break; > if (copy_to_user(utp, &ktp, sizeof(ktp))) > @@ -1767,8 +1765,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, > protkey, &protkeylen, &ktp.pkeytype); > pr_debug("%s pkey_keyblob2pkey3()=%d\n", __func__, rc); > kfree(apqns); > - memzero_explicit(kkey, ktp.keylen); > - kfree(kkey); > + kvfree_sensitive(kkey, ktp.keylen); kfree_sensitive(kkey); > if (rc) { > kfree(protkey); > break; -- Mit freundlichen Grüßen / Kind regards Holger Dengler -- IBM Systems, Linux on IBM Z Development dengler@linux.ibm.com