~ubuntu-branches/ubuntu/vivid/shadow/vivid-proposed

« back to all changes in this revision

Viewing changes to debian/patches/userns/16_add-argument-sanity-checking.patch

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs, Serge Hallyn
  • Date: 2013-06-28 11:31:51 UTC
  • Revision ID: package-import@ubuntu.com-20130628113151-9uapv6rwwj08whr7
Tags: 1:4.1.5.1-1ubuntu5
[ Serge Hallyn ]
* debian/patches/userns: patches from Eric Biederman to enable use of
  subuids, plus some bugfix patches on top of them. (LP: #1192864)
* passwd.install: add new manpages
* debian/control, debian/uidmap.install: create new uidmap package
  containing the new setuid-root binaries newuidmap and newgidmap 
* debian/subuid, debian/rules: install a default /etc/subuid and /etc/subgid
* debian/patches/userns/16_add-argument-sanity-checking.patch: address
  three sanity checking concerns brought up by sarnold at
  http://lists.alioth.debian.org/pipermail/pkg-shadow-devel/2013-June/ \
  009752.html.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From df3c8c1f7f47ceff607595067458f1d8e53eaab8 Mon Sep 17 00:00:00 2001
 
2
From: Serge Hallyn <serge.hallyn@ubuntu.com>
 
3
Date: Fri, 21 Jun 2013 11:47:36 -0500
 
4
Subject: [PATCH 1/1] userns: add argument sanity checking
 
5
 
 
6
In find_new_sub_{u,g}ids, check for min, count and max values.
 
7
 
 
8
In idmapping.c:get_map_ranges(), make sure that the value passed
 
9
in for ranges did not overflow.  Couldn't happen with the current
 
10
code, but this is a sanity check for any future potential mis-uses.
 
11
 
 
12
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
 
13
---
 
14
 libmisc/find_new_sub_gids.c |  8 ++++++++
 
15
 libmisc/find_new_sub_uids.c |  8 ++++++++
 
16
 libmisc/idmapping.c         | 10 ++++++++++
 
17
 3 files changed, 26 insertions(+)
 
18
 
 
19
diff --git a/libmisc/find_new_sub_gids.c b/libmisc/find_new_sub_gids.c
 
20
index 68046ac..fd44978 100644
 
21
--- a/libmisc/find_new_sub_gids.c
 
22
+++ b/libmisc/find_new_sub_gids.c
 
23
@@ -58,6 +58,14 @@ int find_new_sub_gids (const char *owner,
 
24
        max = getdef_ulong ("SUB_GID_MAX", 600100000UL);
 
25
        count = getdef_ulong ("SUB_GID_COUNT", 10000);
 
26
 
 
27
+       if (min >= max || count >= max || (min + count) >= max) {
 
28
+               (void) fprintf (stderr,
 
29
+                               _("%s: Invalid configuration: SUB_GID_MIN (%lu),"
 
30
+                                 " SUB_GID_MAX (%lu), SUB_GID_COUNT (%lu)\n"),
 
31
+                       Prog, min, max, count);
 
32
+               return -1;
 
33
+       }
 
34
+
 
35
        /* Is there a preferred range that works? */
 
36
        if ((*range_count != 0) &&
 
37
            (*range_start >= min) &&
 
38
diff --git a/libmisc/find_new_sub_uids.c b/libmisc/find_new_sub_uids.c
 
39
index f1720f9..b608c59 100644
 
40
--- a/libmisc/find_new_sub_uids.c
 
41
+++ b/libmisc/find_new_sub_uids.c
 
42
@@ -58,6 +58,14 @@ int find_new_sub_uids (const char *owner,
 
43
        max = getdef_ulong ("SUB_UID_MAX", 600100000UL);
 
44
        count = getdef_ulong ("SUB_UID_COUNT", 10000);
 
45
 
 
46
+       if (min >= max || count >= max || (min + count) >= max) {
 
47
+               (void) fprintf (stderr,
 
48
+                               _("%s: Invalid configuration: SUB_UID_MIN (%lu),"
 
49
+                                 " SUB_UID_MAX (%lu), SUB_UID_COUNT (%lu)\n"),
 
50
+                       Prog, min, max, count);
 
51
+               return -1;
 
52
+       }
 
53
+
 
54
        /* Is there a preferred range that works? */
 
55
        if ((*range_count != 0) &&
 
56
            (*range_start >= min) &&
 
57
diff --git a/libmisc/idmapping.c b/libmisc/idmapping.c
 
58
index cb9e898..4147796 100644
 
59
--- a/libmisc/idmapping.c
 
60
+++ b/libmisc/idmapping.c
 
61
@@ -41,6 +41,16 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
 
62
        struct map_range *mappings, *mapping;
 
63
        int idx, argidx;
 
64
 
 
65
+       if (ranges < 0 || argc < 0) {
 
66
+               fprintf(stderr, "%s: error calculating number of arguments\n", Prog);
 
67
+               return NULL;
 
68
+       }
 
69
+
 
70
+       if (ranges != ((argc - 2) + 2) / 3) {
 
71
+               fprintf(stderr, "%s: ranges: %u is wrong for argc: %d\n", Prog, ranges, argc);
 
72
+               return NULL;
 
73
+       }
 
74
+
 
75
        if ((ranges * 3) > argc) {
 
76
                fprintf(stderr, "ranges: %u argc: %d\n",
 
77
                        ranges, argc);
 
78
-- 
 
79
1.8.1.2
 
80