~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to kernel/trace/trace_kprobe.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
353
353
        kfree(data);
354
354
}
355
355
 
 
356
/* Bitfield fetch function */
 
357
struct bitfield_fetch_param {
 
358
        struct fetch_param orig;
 
359
        unsigned char hi_shift;
 
360
        unsigned char low_shift;
 
361
};
 
362
 
 
363
#define DEFINE_FETCH_bitfield(type)                                     \
 
364
static __kprobes void FETCH_FUNC_NAME(bitfield, type)(struct pt_regs *regs,\
 
365
                                            void *data, void *dest)     \
 
366
{                                                                       \
 
367
        struct bitfield_fetch_param *bprm = data;                       \
 
368
        type buf = 0;                                                   \
 
369
        call_fetch(&bprm->orig, regs, &buf);                            \
 
370
        if (buf) {                                                      \
 
371
                buf <<= bprm->hi_shift;                                 \
 
372
                buf >>= bprm->low_shift;                                \
 
373
        }                                                               \
 
374
        *(type *)dest = buf;                                            \
 
375
}
 
376
DEFINE_BASIC_FETCH_FUNCS(bitfield)
 
377
#define fetch_bitfield_string NULL
 
378
#define fetch_bitfield_string_size NULL
 
379
 
 
380
static __kprobes void
 
381
free_bitfield_fetch_param(struct bitfield_fetch_param *data)
 
382
{
 
383
        /*
 
384
         * Don't check the bitfield itself, because this must be the
 
385
         * last fetch function.
 
386
         */
 
387
        if (CHECK_FETCH_FUNCS(deref, data->orig.fn))
 
388
                free_deref_fetch_param(data->orig.data);
 
389
        else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn))
 
390
                free_symbol_cache(data->orig.data);
 
391
        kfree(data);
 
392
}
356
393
/* Default (unsigned long) fetch type */
357
394
#define __DEFAULT_FETCH_TYPE(t) u##t
358
395
#define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t)
367
404
        FETCH_MTD_memory,
368
405
        FETCH_MTD_symbol,
369
406
        FETCH_MTD_deref,
 
407
        FETCH_MTD_bitfield,
370
408
        FETCH_MTD_END,
371
409
};
372
410
 
387
425
ASSIGN_FETCH_FUNC(memory, ftype),                       \
388
426
ASSIGN_FETCH_FUNC(symbol, ftype),                       \
389
427
ASSIGN_FETCH_FUNC(deref, ftype),                        \
 
428
ASSIGN_FETCH_FUNC(bitfield, ftype),                     \
390
429
          }                                             \
391
430
        }
392
431
 
430
469
        if (!type)
431
470
                type = DEFAULT_FETCH_TYPE_STR;
432
471
 
 
472
        /* Special case: bitfield */
 
473
        if (*type == 'b') {
 
474
                unsigned long bs;
 
475
                type = strchr(type, '/');
 
476
                if (!type)
 
477
                        goto fail;
 
478
                type++;
 
479
                if (strict_strtoul(type, 0, &bs))
 
480
                        goto fail;
 
481
                switch (bs) {
 
482
                case 8:
 
483
                        return find_fetch_type("u8");
 
484
                case 16:
 
485
                        return find_fetch_type("u16");
 
486
                case 32:
 
487
                        return find_fetch_type("u32");
 
488
                case 64:
 
489
                        return find_fetch_type("u64");
 
490
                default:
 
491
                        goto fail;
 
492
                }
 
493
        }
 
494
 
433
495
        for (i = 0; i < ARRAY_SIZE(fetch_type_table); i++)
434
496
                if (strcmp(type, fetch_type_table[i].name) == 0)
435
497
                        return &fetch_type_table[i];
 
498
fail:
436
499
        return NULL;
437
500
}
438
501
 
586
649
 
587
650
static void free_probe_arg(struct probe_arg *arg)
588
651
{
589
 
        if (CHECK_FETCH_FUNCS(deref, arg->fetch.fn))
 
652
        if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn))
 
653
                free_bitfield_fetch_param(arg->fetch.data);
 
654
        else if (CHECK_FETCH_FUNCS(deref, arg->fetch.fn))
590
655
                free_deref_fetch_param(arg->fetch.data);
591
656
        else if (CHECK_FETCH_FUNCS(symbol, arg->fetch.fn))
592
657
                free_symbol_cache(arg->fetch.data);
767
832
                }
768
833
                break;
769
834
        case '+':       /* deref memory */
 
835
                arg++;  /* Skip '+', because strict_strtol() rejects it. */
770
836
        case '-':
771
837
                tmp = strchr(arg, '(');
772
838
                if (!tmp)
773
839
                        break;
774
840
                *tmp = '\0';
775
 
                ret = strict_strtol(arg + 1, 0, &offset);
 
841
                ret = strict_strtol(arg, 0, &offset);
776
842
                if (ret)
777
843
                        break;
778
 
                if (arg[0] == '-')
779
 
                        offset = -offset;
780
844
                arg = tmp + 1;
781
845
                tmp = strrchr(arg, ')');
782
846
                if (tmp) {
807
871
        return ret;
808
872
}
809
873
 
 
874
#define BYTES_TO_BITS(nb)       ((BITS_PER_LONG * (nb)) / sizeof(long))
 
875
 
 
876
/* Bitfield type needs to be parsed into a fetch function */
 
877
static int __parse_bitfield_probe_arg(const char *bf,
 
878
                                      const struct fetch_type *t,
 
879
                                      struct fetch_param *f)
 
880
{
 
881
        struct bitfield_fetch_param *bprm;
 
882
        unsigned long bw, bo;
 
883
        char *tail;
 
884
 
 
885
        if (*bf != 'b')
 
886
                return 0;
 
887
 
 
888
        bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
 
889
        if (!bprm)
 
890
                return -ENOMEM;
 
891
        bprm->orig = *f;
 
892
        f->fn = t->fetch[FETCH_MTD_bitfield];
 
893
        f->data = (void *)bprm;
 
894
 
 
895
        bw = simple_strtoul(bf + 1, &tail, 0);  /* Use simple one */
 
896
        if (bw == 0 || *tail != '@')
 
897
                return -EINVAL;
 
898
 
 
899
        bf = tail + 1;
 
900
        bo = simple_strtoul(bf, &tail, 0);
 
901
        if (tail == bf || *tail != '/')
 
902
                return -EINVAL;
 
903
 
 
904
        bprm->hi_shift = BYTES_TO_BITS(t->size) - (bw + bo);
 
905
        bprm->low_shift = bprm->hi_shift + bo;
 
906
        return (BYTES_TO_BITS(t->size) < (bw + bo)) ? -EINVAL : 0;
 
907
}
 
908
 
810
909
/* String length checking wrapper */
811
910
static int parse_probe_arg(char *arg, struct trace_probe *tp,
812
911
                           struct probe_arg *parg, int is_return)
836
935
        parg->offset = tp->size;
837
936
        tp->size += parg->type->size;
838
937
        ret = __parse_probe_arg(arg, parg->type, &parg->fetch, is_return);
 
938
        if (ret >= 0 && t != NULL)
 
939
                ret = __parse_bitfield_probe_arg(t, parg->type, &parg->fetch);
839
940
        if (ret >= 0) {
840
941
                parg->fetch_size.fn = get_fetch_size_function(parg->type,
841
942
                                                              parg->fetch.fn);
1130
1231
        return ret;
1131
1232
}
1132
1233
 
1133
 
#define WRITE_BUFSIZE 128
 
1234
#define WRITE_BUFSIZE 4096
1134
1235
 
1135
1236
static ssize_t probes_write(struct file *file, const char __user *buffer,
1136
1237
                            size_t count, loff_t *ppos)
1738
1839
        kfree(tp->call.print_fmt);
1739
1840
}
1740
1841
 
1741
 
/* Make a debugfs interface for controling probe points */
 
1842
/* Make a debugfs interface for controlling probe points */
1742
1843
static __init int init_kprobe_trace(void)
1743
1844
{
1744
1845
        struct dentry *d_tracer;