Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4446030ybg; Mon, 8 Jun 2020 08:03:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhzutCZ+WKfA/r7s10E+y/tWCpQ3VRZgCIU05M6QvYc2ncDRqKfkgSIzMM5E1ojj8Y2I46 X-Received: by 2002:a17:906:2507:: with SMTP id i7mr13453430ejb.419.1591628629667; Mon, 08 Jun 2020 08:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591628629; cv=none; d=google.com; s=arc-20160816; b=Mlg0Bo9g01zWhe6ZFNf/8XjjS8vKiP9WaX5diIbBKxkwRHvsb3vEwCzOvQCzbuODp2 MMocDyxO4SJkC9zkEMMZoXcztjKth/ijXosw7FwyLFLX2pWL8E1eBIcygPyW5CLZ3Naw TSRY2tcqIV+dhdZpLm5hwc/ur6B6DgFDecvh3Wqa6bggMUfOC43pYzSF3ne6sCdWif7u /EeyuLHJf6drVamLDKXMuCWFlmDiiNKWbnofj6g6WRWZCykyM18azSReZ+3AFqcNaITr R+qgDw67yL5qzHcxH6PlraD/+7fL96v8oQ6X1U+0Fb6u0js3bblLa93B0G0VejM6izw/ 3iQg== 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=vbJ+Z5OJLPEUwZaiWYpSggd91RUgnOqEf/ZiRyDdXKM=; b=o9PbOfKcrC4nhHs85d+85MotYj1UOvf+jFUjNVK8PnfMAtTohPXZ2Iz1QzgxXncK8d fFGO2E4F1Ucs8lKHKgHuEN3l6rq8s1o5oNuDnnLKnULDKx1s/yGOyTvsaA7VGdyoRUYz SxmH/4fgKfbLmbjeObLXukN0JZfEKPNHLEX5FYA0b7Dysah3Nj9x1WntQDk5XkFWm54h 5qgQtcNnjWwntQBL+O4bgvrEBsxNKMbWGVDbgdXH/lnwjpuYdfGDQVBZS2JQDq8/VyV3 bYrF7SnuR7BkoUQYtF3Z4sQ7ZTVdimrtNn0uj2uBjDu/2GqDA/f4BwNaJU8POkQePkBu vWag== 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 x22si7366192eje.542.2020.06.08.08.03.25; Mon, 08 Jun 2020 08:03:49 -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 S1730166AbgFHPBT (ORCPT + 99 others); Mon, 8 Jun 2020 11:01:19 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41133 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729612AbgFHPBR (ORCPT ); Mon, 8 Jun 2020 11:01:17 -0400 Received: by mail-lj1-f195.google.com with SMTP id 9so20896041ljc.8 for ; Mon, 08 Jun 2020 08:01:15 -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=vbJ+Z5OJLPEUwZaiWYpSggd91RUgnOqEf/ZiRyDdXKM=; b=Gs1lhqSM6Z1ctvkxJZatUKUr2GW3HCgI+wrQ+Q5CmvYYlEsHOB9paC6HoqWs8TUYm6 E+qhDPZwaCJbxHuN3oLr9Kp9TjyrXa3YNsZqpumVDnr0ncQjOAsIZLyd94ooMi1pBPlZ wxkVS+CqJd5Q1dk+tvQKxkPossFk+qvfx2Rk3EsacwGwgOM/xZtRKJIQ5yv3l+ZTZJPb XtQOjzU0rq5w4hrS5f9M9qfQvAAWi/FNKcDV8YccMmmd1aZwgdipWAJkSp884Qagop4F /OKL8Yv1SaBgwgj2xFtO8Yq4i2CZJxIQb1mHYqUdLxHEow5JwWKS0xtUcDffqSYGnJoy Omag== X-Gm-Message-State: AOAM533oyT7GSFfBxzYOavQwxySLCja2ZDOstthy8zk2UMJmgXS4CmGl se4dcHBeI61duO2ubVo+LwQ= X-Received: by 2002:a2e:978a:: with SMTP id y10mr9281752lji.115.1591628474737; Mon, 08 Jun 2020 08:01:14 -0700 (PDT) Received: from localhost.localdomain ([213.87.137.116]) by smtp.googlemail.com with ESMTPSA id r16sm279228ljn.106.2020.06.08.08.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2020 08:01:14 -0700 (PDT) From: Denis Efremov To: Julia Lawall Cc: Denis Efremov , linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr Subject: [PATCH v2 1/4] coccinelle: api: extend memdup_user transformation with GFP_USER Date: Mon, 8 Jun 2020 18:00:35 +0300 Message-Id: <20200608150038.223747-2-efremov@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200608150038.223747-1-efremov@linux.com> References: <20200608150038.223747-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..cadcc2e87881 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