Skip to content
Snippets Groups Projects
Select Git revision
  • bd2f55361f18347e890d52ff9cfd8895455ec11b
  • master default protected
  • android-msm-bullhead-3.10-nougat_kgdb_less_changes
  • android-msm-bullhead-3.10-nougat_kgdb
  • android-msm-bullhead-3.10-nougat_klist
  • android-4.4
  • android-msm-vega-4.4-oreo-daydream
  • android-msm-wahoo-4.4-p-preview-5
  • android-msm-wahoo-4.4-pie
  • android-msm-marlin-3.18-p-preview-5
  • android-msm-marlin-3.18-pie
  • android-msm-wahoo-2018.07-oreo-m2
  • android-msm-wahoo-2018.07-oreo-m4
  • android-msm-wahoo-4.4-p-preview-4
  • android-msm-bullhead-3.10-oreo-m6
  • android-msm-angler-3.10-oreo-m6
  • android-msm-marlin-3.18-p-preview-4
  • android-msm-stargazer-3.18-oreo-wear-dr
  • android-msm-catshark-3.18-oreo-wear-dr
  • android-msm-wahoo-4.4-oreo-m2
  • android-msm-wahoo-4.4-oreo-m4
  • android-daydreamos-8.0.0_r0.5
  • android-8.1.0_r0.92
  • android-8.1.0_r0.91
  • android-daydreamos-8.0.0_r0.4
  • android-p-preview-5_r0.2
  • android-p-preview-5_r0.1
  • android-9.0.0_r0.5
  • android-9.0.0_r0.4
  • android-9.0.0_r0.2
  • android-9.0.0_r0.1
  • android-8.1.0_r0.81
  • android-8.1.0_r0.80
  • android-8.1.0_r0.78
  • android-8.1.0_r0.76
  • android-8.1.0_r0.75
  • android-8.1.0_r0.72
  • android-8.1.0_r0.70
  • android-p-preview-4_r0.2
  • android-p-preview-4_r0.1
  • android-wear-8.0.0_r0.30
41 results

binfmt_misc.c

Blame
  • binfmt_misc.c 15.13 KiB
    /*
     *  binfmt_misc.c
     *
     *  Copyright (C) 1997 Richard Günther
     *
     *  binfmt_misc detects binaries via a magic or filename extension and invokes
     *  a specified wrapper. This should obsolete binfmt_java, binfmt_em86 and
     *  binfmt_mz.
     *
     *  1997-04-25 first version
     *  [...]
     *  1997-05-19 cleanup
     *  1997-06-26 hpa: pass the real filename rather than argv[0]
     *  1997-06-30 minor cleanup
     *  1997-08-09 removed extension stripping, locking cleanup
     *  2001-02-28 AV: rewritten into something that resembles C. Original didn't.
     */
    
    #include <linux/module.h>
    #include <linux/init.h>
    #include <linux/sched.h>
    #include <linux/binfmts.h>
    #include <linux/slab.h>
    #include <linux/ctype.h>
    #include <linux/file.h>
    #include <linux/pagemap.h>
    #include <linux/namei.h>
    #include <linux/mount.h>
    #include <linux/syscalls.h>
    #include <linux/fs.h>
    
    #include <asm/uaccess.h>
    
    enum {
    	VERBOSE_STATUS = 1 /* make it zero to save 400 bytes kernel memory */
    };
    
    static LIST_HEAD(entries);
    static int enabled = 1;
    
    enum {Enabled, Magic};
    #define MISC_FMT_PRESERVE_ARGV0 (1<<31)
    #define MISC_FMT_OPEN_BINARY (1<<30)
    #define MISC_FMT_CREDENTIALS (1<<29)
    
    typedef struct {
    	struct list_head list;
    	unsigned long flags;		/* type, status, etc. */
    	int offset;			/* offset of magic */
    	int size;			/* size of magic/mask */
    	char *magic;			/* magic or filename extension */
    	char *mask;			/* mask, NULL for exact match */
    	char *interpreter;		/* filename of interpreter */
    	char *name;
    	struct dentry *dentry;
    } Node;
    
    static DEFINE_RWLOCK(entries_lock);
    static struct file_system_type bm_fs_type;
    static struct vfsmount *bm_mnt;
    static int entry_count;
    
    /* 
     * Check if we support the binfmt
     * if we do, return the node, else NULL
     * locking is done in load_misc_binary
     */
    static Node *check_file(struct linux_binprm *bprm)
    {
    	char *p = strrchr(bprm->interp, '.');