Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1589263ybm; Sat, 30 May 2020 13:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBOB6ynY8HMX19/uMBYsh/fLpYVZ9I9vH/dRcyGev7CVxEO4JQ+s8STBWf0bpoOiGAAh3G X-Received: by 2002:a50:f18f:: with SMTP id x15mr14841749edl.228.1590872194322; Sat, 30 May 2020 13:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590872194; cv=none; d=google.com; s=arc-20160816; b=VD+gkJzeQ8YJTtdLdbZSLaRiz3IPa+k0WrPCYxC1tFqFH9PF1gDE/Ejj8qUVBOhBMz Kpcu4S82J1pTFbx715zQqMwQpwfCDPICuXzLdpHaAqMhTXmHoMt+OEfEsTT4SuMZ4vHu 7yRTAzCB7fM+3WLXghheHCFGsVLu8F/M/MjaHm1vDaSF4HvjPzkUHbv8lvuWjJekkC+a R/KQ5eD1hIWByWvN7FHc+fWhy+/pDucXwqDxI6DiV6gcVHNLkZcaFeJEuSd2UmQTAAQg JC/bFj9agd/z70TS5aqb9L9Q9WvmZKzBc4EMVl93Hi8ZEDSxmmR6deOlKlX/+WQkOmbp DGig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=x1LVz2RKLdTewPVi7JzuKq6wTk2wWGIzWE4uj9Rz3Oo=; b=HBb9CvxldFwv5RdcPyshyA5fqWFD1pGxjdIqvGlsF/KuUJhZYuJAIl59dxGfC/CU2K marxl7Xcoi49kI/5ya4r4yssCo53ugREYdub300M43cd+pSpw479zczvCuHGJRGLVQhS lT+7bYTMN/BLWRRWSBeFCsRDHyrn0pV4mva0/lKcqqQmyKQ8pqodBDFfxQNoOui9DIjS 6CtNoPQ9SYIWpq0QKuo3NOaKBFHIWKGoP5a9LuYIgbQfQzUgUS7koERKO6y8rgaO9L8A wIyNnlSXmrDtQBOODzRQxIbPsNp+wM0VVEiCke7WhKJPh5gE2goMoxDggkuNCqsAoNYn 3poQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds3si10839321ejc.545.2020.05.30.13.56.11; Sat, 30 May 2020 13:56:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729345AbgE3Uyb (ORCPT + 99 others); Sat, 30 May 2020 16:54:31 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41495 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728741AbgE3Uyb (ORCPT ); Sat, 30 May 2020 16:54:31 -0400 Received: by mail-lf1-f66.google.com with SMTP id u16so1710398lfl.8 for ; Sat, 30 May 2020 13:54:29 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=x1LVz2RKLdTewPVi7JzuKq6wTk2wWGIzWE4uj9Rz3Oo=; b=DxtupwfB7ZacQZz5oqXJI4KqRKhaPRtbiWp1cYTNJI+ebvkd3crdcF9JYxpAzWE78N WQ+j01tD79rrpwN/LUt7725KWiEQsIbrOkl38Hdy54hTEvk26cPci1JjiwqS02HKmoE4 GvKD7GfiPHIzYgXkx2lzZGjtvQs7EGBAizynO7fjbOSykHwpnNAzaZBAs8ktV/KgGhwt YriI0LL9GjpkHC7Ivn4PoTsrXZO8OE5E+2UXlhFCxLnUW73LjtP9lLrpcGw4wMKXsQqY 8/kffhgtUIxF9K0QzRbfV7pkxBNWdkZ1IF04G6fvpHUsAL2G1xe8MqKutJgmcReMdvu0 yPbw== X-Gm-Message-State: AOAM533IgSMgJ2Dfm/uh8I04bnKiU8szOCCvLd2e8LIVOBlU6K0+8b+4 oXrWG/ZuAJyxLjh5RbWWMBX1iLTU X-Received: by 2002:ac2:48a3:: with SMTP id u3mr7595076lfg.115.1590872068706; Sat, 30 May 2020 13:54:28 -0700 (PDT) Received: from localhost.localdomain ([213.87.147.196]) by smtp.googlemail.com with ESMTPSA id f6sm2816670ljn.91.2020.05.30.13.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 13:54:28 -0700 (PDT) From: Denis Efremov To: Julia Lawall , Joe Perches Cc: Denis Efremov , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER Date: Sat, 30 May 2020 23:53:47 +0300 Message-Id: <20200530205348.5812-2-efremov@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200530205348.5812-1-efremov@linux.com> References: <20200530205348.5812-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Match GFP_USER allocations with memdup_user.cocci rule. Commit 6c2c97a24f09 ("memdup_user(): switch to GFP_USER") switched memdup_user() from GFP_KERNEL to GFP_USER. In most cases it is still a good idea to use memdup_user() for GFP_KERNEL allocations. The motivation behind altering memdup_user() to GFP_USER is here: https://lkml.org/lkml/2018/1/6/333 Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.cocci | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci index c809ab10bbce..49f487e6a5c8 100644 --- a/scripts/coccinelle/api/memdup_user.cocci +++ b/scripts/coccinelle/api/memdup_user.cocci @@ -20,7 +20,7 @@ expression from,to,size; identifier l1,l2; @@ -- to = \(kmalloc\|kzalloc\)(size,GFP_KERNEL); +- to = \(kmalloc\|kzalloc\)(size,\(GFP_KERNEL\|GFP_USER\)); + to = memdup_user(from,size); if ( - to==NULL @@ -43,7 +43,7 @@ position p; statement S1,S2; @@ -* to = \(kmalloc@p\|kzalloc@p\)(size,GFP_KERNEL); +* to = \(kmalloc@p\|kzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\)); if (to==NULL || ...) S1 if (copy_from_user(to, from, size) != 0) S2 -- 2.26.2