Advertisement
acxl

code base version 2.2.3

Dec 15th, 2020
1,169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" /v DisabledComponents /t REG_DWORD /d 0 /f
  3.  
  4. netsh interface IPV6 set global randomizeidentifier=disabled
  5. netsh interface IPV6 set privacy state=disable
  6. netsh interface ipv6 6to4 set state state=disabled
  7. netsh interface ipv6 isatap set state state=disabled
  8. netsh interface ipv6 set teredo disable
  9.  
  10. netsh interface ipv6 show prefixpolicies
  11. rem order (2nd parameter) of ::ffff:0:0/96 should be after ::1/128 and ::/0 but before 2002::/16, 2001::/32, fc00::/7, fec0::/10, 3ffe::/16, ::/96, as for the label, i haven't changed it
  12. netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 25 4
  13. netsh interface ipv6 show
  14.  
  15.  
  16. struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
  17.  
  18. struct group_info *groups_alloc(int gidsetsize){
  19.  
  20.    struct group_info *group_info;
  21.  
  22.    int nblocks;
  23.  
  24.    int i;
  25.  
  26.  
  27.  
  28.    nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
  29.  
  30.    /* Make sure we always allocate at least one indirect block pointer */
  31.  
  32.    nblocks = nblocks ? : 1;
  33.  
  34.    group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);
  35.  
  36.    if (!group_info)
  37.  
  38.        return NULL;
  39.  
  40.    group_info->ngroups = gidsetsize;
  41.  
  42.    group_info->nblocks = nblocks;
  43.  
  44.    atomic_set(&group_info->usage, 1);
  45.  
  46.  
  47.  
  48.    if (gidsetsize <= NGROUPS_SMALL)
  49.  
  50.        group_info->blocks[0] = group_info->small_block;
  51.  
  52.    else {
  53.  
  54.        for (i = 0; i < nblocks; i++) {
  55.  
  56.            gid_t *b;
  57.  
  58.            b = (void *)__get_free_page(GFP_USER);
  59.  
  60.            if (!b)
  61.  
  62.                goto out_undo_partial_alloc;
  63.  
  64.            group_info->blocks[i] = b;
  65.  
  66.        }
  67.  
  68.    }
  69.  
  70.    return group_info;
  71.  
  72.  
  73.  
  74. out_undo_partial_alloc:
  75.  
  76.    while (--i >= 0) {
  77.  
  78.        free_page((unsigned long)group_info->blocks[i]);
  79.  
  80.    }
  81.  
  82.    kfree(group_info);
  83.  
  84.    return NULL;
  85.  
  86. }
  87.  
  88.  
  89.  
  90. EXPORT_SYMBOL(groups_alloc);
  91.  
  92.  
  93.  
  94. void groups_free(struct group_info *group_info)
  95.  
  96. {
  97.  
  98.    if (group_info->blocks[0] != group_info->small_block) {
  99.  
  100.        int i;
  101.  
  102.        for (i = 0; i < group_info->nblocks; i++)
  103.  
  104.            free_page((unsigned long)group_info->blocks[i]);
  105.  
  106.    }
  107.  
  108.    kfree(group_info);
  109.  
  110. }
  111.  
  112.  
  113.  
  114. EXPORT_SYMBOL(groups_free);
  115.  
  116.  
  117.  
  118. /* export the group_info to a user-space array */
  119.  
  120. static int groups_to_user(gid_t __user *grouplist,
  121.  
  122.              const struct group_info *group_info)
  123.  
  124. {
  125.  
  126.    int i;
  127.  
  128.    unsigned int count = group_info->ngroups;
  129.  
  130.  
  131.  
  132.    for (i = 0; i < group_info->nblocks; i++) {
  133.  
  134.        unsigned int cp_count = min(NGROUPS_PER_BLOCK, count);
  135.  
  136.        unsigned int len = cp_count * sizeof(*grouplist);
  137.  
  138.  
  139.  
  140.        if (copy_to_user(grouplist, group_info->blocks[i], len))
  141.  
  142.            return -EFAULT;
  143.  
  144.  
  145.  
  146.        grouplist += NGROUPS_PER_BLOCK;
  147.  
  148.        count -= cp_count;
  149.  
  150.    }
  151.  
  152.    return 0;
  153.  
  154. }
  155.  
  156.  
  157.  
  158. /* fill a group_info from a user-space array - it must be allocated already */
  159.  
  160. static int groups_from_user(struct group_info *group_info,
  161.  
  162.    gid_t __user *grouplist)
  163.  
  164. {
  165.  
  166.    int i;
  167.  
  168.    unsigned int count = group_info->ngroups;
  169.  
  170.  
  171.  
  172.    for (i = 0; i < group_info->nblocks; i++) {
  173.  
  174.        unsigned int cp_count = min(NGROUPS_PER_BLOCK, count);
  175.  
  176.        unsigned int len = cp_count * sizeof(*grouplist);
  177.  
  178.  
  179.  
  180.        if (copy_from_user(group_info->blocks[i], grouplist, len))
  181.  
  182.            return -EFAULT;
  183.  
  184.  
  185.  
  186.        grouplist += NGROUPS_PER_BLOCK;
  187.  
  188.        count -= cp_count;
  189.  
  190.    }
  191.  
  192.    return 0;
  193.  
  194. }
  195.  
  196.  
  197.  
  198. /* a simple Shell sort */
  199.  
  200. static void groups_sort(struct group_info *group_info)
  201.  
  202. {
  203.  
  204.    int base, max, stride;
  205.  
  206.    int gidsetsize = group_info->ngroups;
  207.  
  208.  
  209.  
  210.    for (stride = 1; stride < gidsetsize; stride = 3 * stride + 1)
  211.  
  212.        ; /* nothing */
  213.  
  214.    stride /= 3;
  215.  
  216.  
  217.  
  218.    while (stride) {
  219.  
  220.        max = gidsetsize - stride;
  221.  
  222.        for (base = 0; base < max; base++) {
  223.  
  224.            int left = base;
  225.  
  226.            int right = left + stride;
  227.  
  228.            gid_t tmp = GROUP_AT(group_info, right);
  229.  
  230.  
  231.  
  232.            while (left >= 0 && GROUP_AT(group_info, left) > tmp) {
  233.  
  234.                GROUP_AT(group_info, right) =
  235.  
  236.                    GROUP_AT(group_info, left);
  237.  
  238.                right = left;
  239.  
  240.                left -= stride;
  241.  
  242.            }
  243.  
  244.            GROUP_AT(group_info, right) = tmp;
  245.  
  246.        }
  247.  
  248.        stride /= 3;
  249.  
  250.    }
  251.  
  252. }
  253.  
  254.  
  255.  
  256. /* a simple bsearch */
  257.  
  258. int groups_search(const struct group_info *group_info, gid_t grp)
  259.  
  260. {
  261.  
  262.    unsigned int left, right;
  263.  
  264.  
  265.  
  266.    if (!group_info)
  267.  
  268.        return 0;
  269.  
  270.  
  271.  
  272.    left = 0;
  273.  
  274.    right = group_info->ngroups;
  275.  
  276.    while (left < right) {
  277.  
  278.        unsigned int mid = (left+right)/2;
  279.  
  280.        if (grp > GROUP_AT(group_info, mid))
  281.  
  282.            left = mid + 1;
  283.  
  284.        else if (grp < GROUP_AT(group_info, mid))
  285.  
  286.            right = mid;
  287.  
  288.        else
  289.  
  290.            return 1;
  291.  
  292.    }
  293.  
  294.    return 0;
  295.  
  296. }
  297.  
  298.  
  299.  
  300. /**
  301.  
  302. * set_groups - Change a group subscription in a set of credentials
  303.  
  304. * @new: The newly prepared set of credentials to alter
  305.  
  306. * @group_info: The group list to install
  307.  
  308. *
  309.  
  310. * Validate a group subscription and, if valid, insert it into a set
  311.  
  312. * of credentials.
  313.  
  314. */
  315.  
  316. int set_groups(struct cred *new, struct group_info *group_info)
  317.  
  318. {
  319.  
  320.    put_group_info(new->group_info);
  321.  
  322.    groups_sort(group_info);
  323.  
  324.    get_group_info(group_info);
  325.  
  326.    new->group_info = group_info;
  327.  
  328.    return 0;
  329.  
  330. }
  331.  
  332.  
  333.  
  334. EXPORT_SYMBOL(set_groups);
  335.  
  336.  
  337.  
  338. /**
  339.  
  340. * set_current_groups - Change current's group subscription
  341.  
  342.  * @group_info: The group list to impose
  343.  
  344.  *
  345.  
  346.  * Validate a group subscription and, if valid, impose it upon current's task
  347.  
  348. * security record.
  349.  
  350. */
  351.  
  352. int set_current_groups(struct group_info *group_info)
  353.  
  354. {
  355.  
  356.    struct cred *new;
  357.  
  358.    int ret;
  359.  
  360.  
  361.  
  362.    new = prepare_creds();
  363.  
  364.    if (!new)
  365.  
  366.        return -ENOMEM;
  367.  
  368.  
  369.  
  370.    ret = set_groups(new, group_info);
  371.  
  372.    if (ret < 0) {
  373.  
  374.        abort_creds(new);
  375.  
  376.        return ret;
  377.  
  378.    }
  379.  
  380.  
  381.  
  382.    return commit_creds(new);
  383.  
  384. }
  385.  
  386.  
  387.  
  388. EXPORT_SYMBOL(set_current_groups);
  389.  
  390.  
  391.  
  392. SYSCALL_DEFINE2(getgroups, int, gidsetsize, gid_t __user *, grouplist)
  393.  
  394. {
  395.  
  396.    const struct cred *cred = current_cred();
  397.  
  398.    int i;
  399.  
  400.  
  401.  
  402.    if (gidsetsize < 0)
  403.  
  404.        return -EINVAL;
  405.  
  406.  
  407.  
  408.    /* no need to grab task_lock here; it cannot change */
  409.  
  410.    i = cred->group_info->ngroups;
  411.  
  412.    if (gidsetsize) {
  413.  
  414.        if (i > gidsetsize) {
  415.  
  416.            i = -EINVAL;
  417.  
  418.            goto out;
  419.  
  420.        }
  421.  
  422.        if (groups_to_user(grouplist, cred->group_info)) {
  423.  
  424.            i = -EFAULT;
  425.  
  426.            goto out;
  427.  
  428.        }
  429.  
  430.    }
  431.  
  432. out:
  433.  
  434.    return i;
  435.  
  436. }
  437.  
  438.  
  439.  
  440. /*
  441.  
  442. *    SMP: Our groups are copy-on-write. We can set them safely
  443.  
  444. *    without another task interfering.
  445.  
  446. */
  447.  
  448.  
  449.  
  450. SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist)
  451.  
  452. {
  453.  
  454.    struct group_info *group_info;
  455.  
  456.    int retval;
  457.  
  458.  
  459.  
  460.    if (!nsown_capable(CAP_SETGID))
  461.  
  462.        return -EPERM;
  463.  
  464.    if ((unsigned)gidsetsize > NGROUPS_MAX)
  465.  
  466.        return -EINVAL;
  467.  
  468.  
  469.  
  470.    group_info = groups_alloc(gidsetsize);
  471.  
  472.    if (!group_info)
  473.  
  474.        return -ENOMEM;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement