Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5560820imm; Mon, 23 Jul 2018 01:46:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdIwpJELZ4dP8JFHLTSpc64RCXVyrjJycn064mVpuX/3Iwvq7Nla/3aBpjAeuWnGOfm1UBe X-Received: by 2002:a65:5cc5:: with SMTP id b5-v6mr11240016pgt.425.1532335574826; Mon, 23 Jul 2018 01:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532335574; cv=none; d=google.com; s=arc-20160816; b=O/osXPvkZp2FXAOoQlbmeqShAoxKUz8kynZq4h1qXqKi64RNqn2jYhjKwoBjkKa54l 3+tEZ2tWdKe1QGUhWIPjDYTRvYhqyhCBtcJZt8AM5TmkuK1wq/vZvU3Qj7MfrgtWqrEm D4DFTwPTpuwbk7gaohJR4qU3dXU4YRF+uB2kvKPszhzl5gnv0fhVCcvy+IwM7JisfBKZ nX3wVbm53lLev5Oz8rm8Q7AUmIzBfll2rx4826GxkwvP1BjWdXGKpXpuJIm6/ANc6MkU kfm1iL/7rloSM//rSSmRPAWnRDPKBBlC2US9cOtwSVTveRx/TkHOngP65dTMV2op60OR jnvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XFsO39SPjj0EE/0cI9U1A70uJwOmOJzbqyIi7/g7uDo=; b=Rv3dMfnujHZiBBhLGwVOZ6OklISol+lBdDc6CGS0FWJC3xBI0o85+4Xfk7k9a2Ef4f Xfw1t+0qc1r2UsVwAyO8vLYHol6cc9+VBBi4PZKvl9BI6xbyx7M2mhrXEk+A/kKIyHp7 sgpC/taU0unRq7I1GBFUvsGdACV2INj4aX95MtJ+dRer7AZAPvd5OcgFD9d6BF3dF21p Dud0aBziSTGQz4TF67xVxyXBB1oHkPfZr8d9oLrgOJKqLcXaToXtoY80tFX+HMxcTXne dmbCzSj07Yi1YcG/OYG6SXHpbfNhsu3UprWmJLiSeFdThKcAoG4RvtRaK/pt42cUj37p W4Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="tkqAmba/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 190-v6si8992623pfu.343.2018.07.23.01.45.59; Mon, 23 Jul 2018 01:46:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="tkqAmba/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388101AbeGWJoJ (ORCPT + 99 others); Mon, 23 Jul 2018 05:44:09 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:39074 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387925AbeGWJoJ (ORCPT ); Mon, 23 Jul 2018 05:44:09 -0400 Received: by mail-io0-f196.google.com with SMTP id o22-v6so13818750ioh.6; Mon, 23 Jul 2018 01:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=XFsO39SPjj0EE/0cI9U1A70uJwOmOJzbqyIi7/g7uDo=; b=tkqAmba/s7vNYWjbgbzNKT0kwBOHVze9VUxqeTW9/7LSBn+OSArUqYGzS0VlVrvqu3 +4USCK7hppjmqPSBsp06pfB3TzBZSALleqd+UuVLzxCCUpTI51SVfE6cWc0cDUjakBJQ hYNHqyrLPaeJN374yyPFunSRkfnjF58mQYgRHjZdfCylSyxdCqvqBytFCfwLKpiVS2ml G9fQ2KFgZT9hHD23xscX/dbPBh2WMZYvWDP4+qO2fBCpZOZQJenBlbWY0BX69D1C8GFw 6HOzDW7OQneV3izhOXXu3s5uzK56ao0Xip0hlFAksjR1fIE+q66tc9rgfb6gTqk2YmQQ q1Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XFsO39SPjj0EE/0cI9U1A70uJwOmOJzbqyIi7/g7uDo=; b=iZXJpQsBLBlmDN+JAa4vncHNqXoAWwhfcbNBHxF6MuDa6K2Wq6VAFaf4b0+XpFdx2+ mCB2eh399ol0PyTEZ3y42FwlJaX6oMM1onXigUE8Ty32RmRXYk0uaI9jPRA/o3uhe8st 4Zk5fC9xNeZXn8ztHRENt/ii++Y5GccYdyURznTHw3n0XArClNwnkeaFexB4cAZj3t8X bojWBocE86ufK9KYCtvH1kJ1wA6qZd+CU9dmGm3/kbjDB46M95tzqon3YmiS71qOCMoY l8IDfpWCrIVyIulqivrjW9EFuEV/YHayqLFtHGiwae+sO05wxquNyxc/9dn3kjCIad37 RJIg== X-Gm-Message-State: AOUpUlGjuOvA+CmuB7vcfQyFnpr6YdDNFRVajhNpO/BAbaPZGsFyLZm6 yL2S+SxYD8JngyIXeFhHUN4= X-Received: by 2002:a5e:c90e:: with SMTP id z14-v6mr9631623iol.268.1532335441699; Mon, 23 Jul 2018 01:44:01 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:e422:450a:e730:728b]) by smtp.gmail.com with ESMTPSA id p25-v6sm4424124itf.42.2018.07.23.01.43.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 01:44:01 -0700 (PDT) From: Jia-Ju Bai To: mst@redhat.com, jasowang@redhat.com, arei.gonglei@huawei.com, herbert@gondor.apana.org.au, davem@davemloft.net Cc: virtualization@lists.linux-foundation.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] crypto: virtio: Replace GFP_ATOMIC with GFP_KERNEL in __virtio_crypto_ablkcipher_do_req() Date: Mon, 23 Jul 2018 16:43:46 +0800 Message-Id: <20180723084346.16488-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __virtio_crypto_ablkcipher_do_req() is never called in atomic context. __virtio_crypto_ablkcipher_do_req() is only called by virtio_crypto_ablkcipher_crypt_req(), which is only called by virtcrypto_find_vqs() that is never called in atomic context. __virtio_crypto_ablkcipher_do_req() calls kzalloc_node() with GFP_ATOMIC, which is not necessary. GFP_ATOMIC can be replaced with GFP_KERNEL. This is found by a static analysis tool named DCNS written by myself. I also manually check the kernel code before reporting it. Signed-off-by: Jia-Ju Bai --- drivers/crypto/virtio/virtio_crypto_algs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c index ba190cfa7aa1..83bcc83dae43 100644 --- a/drivers/crypto/virtio/virtio_crypto_algs.c +++ b/drivers/crypto/virtio/virtio_crypto_algs.c @@ -371,12 +371,12 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, /* Why 3? outhdr + iv + inhdr */ sg_total = src_nents + dst_nents + 3; - sgs = kzalloc_node(sg_total * sizeof(*sgs), GFP_ATOMIC, + sgs = kzalloc_node(sg_total * sizeof(*sgs), GFP_KERNEL, dev_to_node(&vcrypto->vdev->dev)); if (!sgs) return -ENOMEM; - req_data = kzalloc_node(sizeof(*req_data), GFP_ATOMIC, + req_data = kzalloc_node(sizeof(*req_data), GFP_KERNEL, dev_to_node(&vcrypto->vdev->dev)); if (!req_data) { kfree(sgs); @@ -432,7 +432,7 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, * Avoid to do DMA from the stack, switch to using * dynamically-allocated for the IV */ - iv = kzalloc_node(ivsize, GFP_ATOMIC, + iv = kzalloc_node(ivsize, GFP_KERNEL, dev_to_node(&vcrypto->vdev->dev)); if (!iv) { err = -ENOMEM; -- 2.17.0