Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp22623ybh; Mon, 20 Jul 2020 09:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyqFBA4QEw0OUjgDvM7Cgo+tM2gYLF8TI4ZEif7d8XPtHs9aTzGUlgf+5Msdm4HJtQ17Mw X-Received: by 2002:a17:906:b217:: with SMTP id p23mr22131750ejz.98.1595262302826; Mon, 20 Jul 2020 09:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595262302; cv=none; d=google.com; s=arc-20160816; b=MT4fN8wko3HJdjqkji5ynsK4TzXmXTFVuRtM22C5nBjqGD0qYNwUfuLQevDrBgUU4M 7Ygu7cnFxVojpNXKpRBDPigOu3mk9WYzPpLC9+I22tYGqFfjuwd585TJCYXgCre49tOo 5+3YrgmUZDPWJi8V4svRFMd96OoE3T/A8HZPlpBESgNV6otS/DOngHxGEyGw6hry9P7h E3s19R3Gq5gwWAwKX6rQNDNQlfPiD/FFyMGYHNJ1XpP4i1YwGeMTghtwKylh4FYR6/Tc IIzsnUDAu9BkvyOJMz8nf0bvFSVl63ksb8RinxM5OSl9Pv8px5uHcIyD4Ek55sz0sXMR W2CA== 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=+wuyYMorTCCTA+H9Rs20Q97XbYGdbTwxjgGpl65WNYw=; b=sbAfevoIY+yuGA9jeNPdcCv+PSgk1cvAZctwca2aZqPTucCIlP0+VZ8IgdW/PAlwD5 uY9+ReaBzpOdcFuEFRDmUAm07tR6MQaTPWwoS/vSynObVEbedH7+87hMmBXLLSSEwK6/ u5DEBzrZ1FgVUtogvKWUc0c88spILGcU1pe+sJuI/FlsGDaECgsyOHW3QeYmHjG7geYb 9v4Bj/D4U/ByVAlI3bhveGjxTYBuky6TaONlICOsdGZMoBrnr9RI20yCVZxpRgzSw0hv gfgCpTlvy8qNizhwZNxLyraNWpqifv5S3FbBo1BGYFzcyZGQNLE9WMW+18bSpZYfgb9p xOvA== 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 fx23si10510232ejb.273.2020.07.20.09.24.39; Mon, 20 Jul 2020 09:25:02 -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 S2388375AbgGTQXE (ORCPT + 99 others); Mon, 20 Jul 2020 12:23:04 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35007 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387905AbgGTQXC (ORCPT ); Mon, 20 Jul 2020 12:23:02 -0400 Received: by mail-lj1-f193.google.com with SMTP id q4so20959929lji.2 for ; Mon, 20 Jul 2020 09:23:01 -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=+wuyYMorTCCTA+H9Rs20Q97XbYGdbTwxjgGpl65WNYw=; b=qetmZYaXoFQKnCswkBxDV/Q4hu+2x72N5BXjmFcBj2S1dOHIds4vBR5aEn1WAhIbp5 NCw78JH73x/U9aTXCugUaHCDhuzJAR0JlsJGIdQV5fDayR5YvCpf/fjZOemDlIPyiQFf 78dB1aHnG0+aijD5I/wokk0Vphl9rUyCGd+eAW6iIY8ZPh8paYts2IuFqnzwC10z+hci x2XZoLxPkUVm6joAk3BEdZeNi57VkogB2H4aaMuhNPTMNGuhzQTlNFD3TKoWzxulspb3 uzYkW5WyH5Irw6PkEraCkywtvKIFLmNCiIgPDA3Jh0o7chTlavwwbDgc00auerQf8QEo O7Xw== X-Gm-Message-State: AOAM532vl8ZMiNpSJxxyTiZxTlBi4rUtT4uiHh6Jmxaqk2i45ox1L4MJ PuExJ2rmX1L16r0UzcJt4OY= X-Received: by 2002:a2e:7a03:: with SMTP id v3mr11527773ljc.141.1595262180283; Mon, 20 Jul 2020 09:23:00 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-38-130.ip.moscow.rt.ru. [37.110.38.130]) by smtp.googlemail.com with ESMTPSA id a19sm925855lff.25.2020.07.20.09.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 09:22:59 -0700 (PDT) From: Denis Efremov To: Julia Lawall Cc: Denis Efremov , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] coccinelle: api: extend memdup_user transformation with GFP_USER Date: Mon, 20 Jul 2020 19:22:14 +0300 Message-Id: <20200720162216.13248-2-efremov@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200720162216.13248-1-efremov@linux.com> References: <20200720162216.13248-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 and optional __GFP_NOWARN allocations with memdup_user.cocci rule. Commit 6c2c97a24f09 ("memdup_user(): switch to GFP_USER") switched memdup_user() from GFP_KERNEL to GFP_USER. In almost all cases it is still a good idea to recommend memdup_user() for GFP_KERNEL allocations. The motivation behind altering memdup_user() to GFP_USER: https://lkml.org/lkml/2018/1/6/333 Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.cocci | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci index c809ab10bbce..0e29d41ecab8 100644 --- a/scripts/coccinelle/api/memdup_user.cocci +++ b/scripts/coccinelle/api/memdup_user.cocci @@ -20,7 +20,9 @@ expression from,to,size; identifier l1,l2; @@ -- to = \(kmalloc\|kzalloc\)(size,GFP_KERNEL); +- to = \(kmalloc\|kzalloc\) +- (size,\(GFP_KERNEL\|GFP_USER\| +- \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\)); + to = memdup_user(from,size); if ( - to==NULL @@ -43,7 +45,9 @@ position p; statement S1,S2; @@ -* to = \(kmalloc@p\|kzalloc@p\)(size,GFP_KERNEL); +* to = \(kmalloc@p\|kzalloc@p\) + (size,\(GFP_KERNEL\|GFP_USER\| + \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\)); if (to==NULL || ...) S1 if (copy_from_user(to, from, size) != 0) S2 -- 2.26.2