~ubuntu-branches/ubuntu/quantal/linux-lowlatency/quantal

« back to all changes in this revision

Viewing changes to security/apparmor/policy_unpack.c

  • Committer: Package Import Robot
  • Author(s): Alessio Igor Bogani
  • Date: 2011-10-26 11:13:05 UTC
  • Revision ID: package-import@ubuntu.com-20111026111305-04kado7d1u2er2rl
Tags: 3.2.0-16.25
Add new lowlatency kernel flavour

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
        return 0;
191
191
}
192
192
 
 
193
static bool unpack_u16(struct aa_ext *e, u16 *data, const char *name)
 
194
{
 
195
        if (unpack_nameX(e, AA_U16, name)) {
 
196
                if (!inbounds(e, sizeof(u16)))
 
197
                        return 0;
 
198
                if (data)
 
199
                        *data = le16_to_cpu(get_unaligned((u16 *) e->pos));
 
200
                e->pos += sizeof(u16);
 
201
                return 1;
 
202
        }
 
203
        return 0;
 
204
}
 
205
 
193
206
static bool unpack_u32(struct aa_ext *e, u32 *data, const char *name)
194
207
{
195
208
        if (unpack_nameX(e, AA_U32, name)) {
468
481
{
469
482
        struct aa_profile *profile = NULL;
470
483
        const char *name = NULL;
471
 
        int error = -EPROTO;
 
484
        size_t size = 0;
 
485
        int i, error = -EPROTO;
472
486
        kernel_cap_t tmpcap;
473
487
        u32 tmp;
474
488
 
559
573
        if (!unpack_rlimits(e, profile))
560
574
                goto fail;
561
575
 
 
576
        size = unpack_array(e, "net_allowed_af");
 
577
        if (size) {
 
578
 
 
579
                for (i = 0; i < size; i++) {
 
580
                        /* discard extraneous rules that this kernel will
 
581
                         * never request
 
582
                         */
 
583
                        if (i >= AF_MAX) {
 
584
                                u16 tmp;
 
585
                                if (!unpack_u16(e, &tmp, NULL) ||
 
586
                                    !unpack_u16(e, &tmp, NULL) ||
 
587
                                    !unpack_u16(e, &tmp, NULL))
 
588
                                        goto fail;
 
589
                                continue;
 
590
                        }
 
591
                        if (!unpack_u16(e, &profile->net.allow[i], NULL))
 
592
                                goto fail;
 
593
                        if (!unpack_u16(e, &profile->net.audit[i], NULL))
 
594
                                goto fail;
 
595
                        if (!unpack_u16(e, &profile->net.quiet[i], NULL))
 
596
                                goto fail;
 
597
                }
 
598
                if (!unpack_nameX(e, AA_ARRAYEND, NULL))
 
599
                        goto fail;
 
600
                /*
 
601
                 * allow unix domain and netlink sockets they are handled
 
602
                 * by IPC
 
603
                 */
 
604
        }
 
605
        profile->net.allow[AF_UNIX] = 0xffff;
 
606
        profile->net.allow[AF_NETLINK] = 0xffff;
 
607
 
562
608
        /* get file rules */
563
609
        profile->file.dfa = unpack_dfa(e);
564
610
        if (IS_ERR(profile->file.dfa)) {