Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455AbaK3RF2 (ORCPT ); Sun, 30 Nov 2014 12:05:28 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:13407 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbaK3RF0 (ORCPT ); Sun, 30 Nov 2014 12:05:26 -0500 X-IronPort-AV: E=Sophos;i="5.07,488,1413237600"; d="scan'208";a="91114600" From: Julia Lawall To: linux-arm-kernel@lists.infradead.org Cc: dborkman@redhat.com, herbert@gondor.apana.org.au, kernel-janitors@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, sparclinux@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linuxppc-dev@lists.ozlabs.org, linux-usb@vger.kernel.org Subject: [PATCH 0/8] replace memset by memzero_explicit Date: Sun, 30 Nov 2014 17:59:26 +0100 Message-Id: <1417366774-32412-1-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.8.3.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memset on a local variable may be removed when it is called just before the variable goes out of scope. Using memzero_explicit defeats this optimization. The complete semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ identifier x; local idexpression e; type T,T1; @@ { ... when any T x[...]; ... when any when exists ( e = (T1)x | e = (T1)&x[0] ) ... when any when exists - memset + memzero_explicit (x, -0, ...) ... when != x when != e when strict } @@ identifier i,x; local idexpression e; type T; @@ { ... when any struct i x; ... when any when exists e = (T)&x ... when any when exists - memset + memzero_explicit (&x, -0, ...) ... when != x when != e when strict } // ------------------------------------------------------------------------ @@ identifier x; type T,T1; expression e; @@ { ... when any T x[...]; ... when any when exists when != e = (T1)x when != e = (T1)&x[0] - memset + memzero_explicit (x, -0, ...) ... when != x when strict } @@ identifier i,x; expression e; type T; @@ { ... when any struct i x; ... when any when exists when != e = (T)&x - memset + memzero_explicit (&x, -0, ...) ... when != x when strict } // -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/