Skip to content
Snippets Groups Projects
Select Git revision
  • f1f0f330b1d0ac1bcc38d7c84d439f4fde341a9c
  • master default
  • b4/thermal-rockchip-grf-warning
  • rockchip-devel
  • b4/usbc-for-rock5bp
  • b4/arm64-defconfig
  • b4/sige5-network-phy-clock
  • b4/fusb302-unthreaded-irq
  • radxa-v6.1-vendor-kernel
  • b4/phy-realtek-clock-fix
  • b4/rk3576-rock4d-phy-timings
  • b4/dw-wdt-fix-initial-timeout
  • b4/fusb302-race-condition-fix
  • b4/rk3576-rock4d-phy-handling-fixes
  • b4/rk3588-evb1-hdmi-rx
  • b4/rk3576-fix-fspi-pmdomain
  • b4/rock5bp-for-upstream
  • rk3588-test
  • rk3588-test-vendor-cam
  • lf-6.6.y_6.6.23-2.0.0_var01-panfrost
  • rk3588-linked-clk-gate-for-upstream
  • v5.17
  • v5.17-rc8
  • v5.17-rc7
  • v5.17-rc6
  • v5.17-rc5
  • v5.17-rc4
  • v5.17-rc3
  • v5.17-rc2
  • v5.17-rc1
  • v5.16
  • v5.16-rc8
  • v5.16-rc7
  • v5.16-rc6
  • v5.16-rc5
  • v5.16-rc4
  • v5.16-rc3
  • v5.16-rc2
  • v5.16-rc1
  • v5.15
  • v5.15-rc7
41 results

makelst

Blame
  • structleak_plugin.c 7.25 KiB
    /*
     * Copyright 2013-2017 by PaX Team <pageexec@freemail.hu>
     * Licensed under the GPL v2
     *
     * Note: the choice of the license means that the compilation process is
     *       NOT 'eligible' as defined by gcc's library exception to the GPL v3,
     *       but for the kernel it doesn't matter since it doesn't link against
     *       any of the gcc libraries
     *
     * gcc plugin to forcibly initialize certain local variables that could
     * otherwise leak kernel stack to userland if they aren't properly initialized
     * by later code
     *
     * Homepage: https://pax.grsecurity.net/
     *
     * Options:
     * -fplugin-arg-structleak_plugin-disable
     * -fplugin-arg-structleak_plugin-verbose
     * -fplugin-arg-structleak_plugin-byref
     * -fplugin-arg-structleak_plugin-byref-all
     *
     * Usage:
     * $ # for 4.5/4.6/C based 4.7
     * $ gcc -I`gcc -print-file-name=plugin`/include -I`gcc -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
     * $ # for C++ based 4.7/4.8+
     * $ g++ -I`g++ -print-file-name=plugin`/include -I`g++ -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
     * $ gcc -fplugin=./structleak_plugin.so test.c -O2
     *
     * TODO: eliminate redundant initializers
     */
    
    #include "gcc-common.h"
    
    /* unused C type flag in all versions 4.5-6 */
    #define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_5(TYPE)
    
    __visible int plugin_is_GPL_compatible;
    
    static struct plugin_info structleak_plugin_info = {
    	.version	= "20190125vanilla",
    	.help		= "disable\tdo not activate plugin\n"
    			  "byref\tinit structs passed by reference\n"
    			  "byref-all\tinit anything passed by reference\n"
    			  "verbose\tprint all initialized variables\n",
    };
    
    #define BYREF_STRUCT	1
    #define BYREF_ALL	2
    
    static bool verbose;
    static int byref;
    
    static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
    {
    	*no_add_attrs = true;
    
    	/* check for types? for now accept everything linux has to offer */
    	if (TREE_CODE(*node) != FIELD_DECL)
    		return NULL_TREE;
    
    	*no_add_attrs = false;
    	return NULL_TREE;
    }
    
    static struct attribute_spec user_attr = { };
    
    static void register_attributes(void *event_data, void *data)
    {
    	user_attr.name			= "user";
    	user_attr.handler		= handle_user_attribute;