> Now I wonder about this software situation.

I can reduce my evolving SmPL script for another test.

* Using only simple strings for the constraints according to the two known
  function names in the implementation which should be found.
  
http://elixir.free-electrons.com/linux/v4.12.8/source/fs/ecryptfs/keystore.c#L2536
  
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/fs/ecryptfs/keystore.c?id=bb70832dd42b298d4303fd054bf18a78650ff04a#n2561

* Simplify a condition check


elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt 
delete_oom_message7b.cocci ../Probe/keystore-excerpt1.c
init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
…
@@ -28,8 +28,6 @@ ecryptfs_add_global_auth_tok(struct ecry
                                        GFP_KERNEL);
        if (!new_auth_tok) {
                rc = -ENOMEM;
-               printk(KERN_ERR "Error allocating from "
-                      "ecryptfs_global_auth_tok_cache\n");
                goto out;
        }
        memcpy(new_auth_tok->sig, sig, ECRYPTFS_SIG_SIZE_HEX);


Such an update suggestion shows the expected test result while
the following command variant points other source code places out
for further development considerations.

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt 
delete_oom_message7.cocci ~/Projekte/Linux/next-patched/fs/ecryptfs/keystore.c
…
@@ -2519,8 +2502,6 @@ int ecryptfs_add_keysig(struct ecryptfs_
…


How do you think about to clarify this software behaviour by reviewing
the attached source files?

Regards,
Markus
/**
 * eCryptfs: Linux filesystem encryption layer
 * In-kernel key management code.  Includes functions to parse and
 * write authentication token-related packets with the underlying
 * file.
 *
 * Copyright (C) 2004-2006 International Business Machines Corp.
 *   Author(s): Michael A. Halcrow <mhalc...@us.ibm.com>
 *              Michael C. Thompson <mctho...@us.ibm.com>
 *              Trevor S. Highland <trevor.highl...@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 */

struct kmem_cache *ecryptfs_global_auth_tok_cache;

int
ecryptfs_add_global_auth_tok(struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
			     char *sig, u32 global_auth_tok_flags)
{
	struct ecryptfs_global_auth_tok *new_auth_tok;
	int rc = 0;

	new_auth_tok = kmem_cache_zalloc(ecryptfs_global_auth_tok_cache,
					GFP_KERNEL);
	if (!new_auth_tok) {
		rc = -ENOMEM;
		printk(KERN_ERR "Error allocating from "
		       "ecryptfs_global_auth_tok_cache\n");
		goto out;
	}
	memcpy(new_auth_tok->sig, sig, ECRYPTFS_SIG_SIZE_HEX);
	new_auth_tok->flags = global_auth_tok_flags;
	new_auth_tok->sig[ECRYPTFS_SIG_SIZE_HEX] = '\0';
	mutex_lock(&mount_crypt_stat->global_auth_tok_list_mutex);
	list_add(&new_auth_tok->mount_crypt_stat_list,
		 &mount_crypt_stat->global_auth_tok_list);
	mutex_unlock(&mount_crypt_stat->global_auth_tok_list_mutex);
out:
	return rc;
}

@deletion1@
constant message;
expression code, code2, error_code, target, X;
identifier action =~ "^kmem_cache_zalloc",
           log =~ "^printk",
           label, release, release2, var, var2;
statement es;
@@
 target = action(...);
 ... when != target = X
 if (!target)
 {
 <...
(
  release(...);
|
  var = code;
)
 ...>
- log(..., message, ...);
 <...
(
  release2(...);
|
  var2 = code2;
)
 ...>
(
  return error_code;
|
  goto label;
)
 }
 else
 es
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to