Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
cefbc615
Commit
cefbc615
authored
Feb 02, 2016
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #797 from brauner/2016-02-02/fix_execute_null_ptr_deref
Fix mount_entry_on_generic()
parents
5e75dea2
ec50007f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
29 deletions
+20
-29
lxcoverlay.c
src/lxc/bdev/lxcoverlay.c
+3
-0
conf.c
src/lxc/conf.c
+17
-29
No files found.
src/lxc/bdev/lxcoverlay.c
View file @
cefbc615
...
@@ -489,6 +489,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -489,6 +489,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
size_t
len
=
0
;
size_t
len
=
0
;
size_t
rootfslen
=
0
;
size_t
rootfslen
=
0
;
/* Since we use all of these to check whether the user has given us a
* sane absolute path to create the directories needed for overlay
* lxc.mount.entry entries we consider any of these missing fatal. */
if
(
!
rootfs
||
!
rootfs
->
path
||
!
lxc_name
||
!
lxc_path
)
if
(
!
rootfs
||
!
rootfs
->
path
||
!
lxc_name
||
!
lxc_path
)
goto
err
;
goto
err
;
...
...
src/lxc/conf.c
View file @
cefbc615
...
@@ -858,15 +858,10 @@ static int setup_dev_symlinks(const struct lxc_rootfs *rootfs)
...
@@ -858,15 +858,10 @@ static int setup_dev_symlinks(const struct lxc_rootfs *rootfs)
int
ret
,
i
;
int
ret
,
i
;
struct
stat
s
;
struct
stat
s
;
/* rootfs struct will be empty when container is created without rootfs. */
char
*
rootfs_path
=
NULL
;
if
(
rootfs
&&
rootfs
->
path
)
rootfs_path
=
rootfs
->
mount
;
for
(
i
=
0
;
i
<
sizeof
(
dev_symlinks
)
/
sizeof
(
dev_symlinks
[
0
]);
i
++
)
{
for
(
i
=
0
;
i
<
sizeof
(
dev_symlinks
)
/
sizeof
(
dev_symlinks
[
0
]);
i
++
)
{
const
struct
dev_symlinks
*
d
=
&
dev_symlinks
[
i
];
const
struct
dev_symlinks
*
d
=
&
dev_symlinks
[
i
];
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/%s"
,
rootfs
_path
?
rootfs_path
:
""
,
d
->
name
);
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/%s"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
d
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
return
-
1
;
...
@@ -1069,18 +1064,13 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, cons
...
@@ -1069,18 +1064,13 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, cons
size_t
clen
;
size_t
clen
;
char
*
path
;
char
*
path
;
/* rootfs struct will be empty when container is created without rootfs. */
char
*
rootfs_path
=
NULL
;
if
(
rootfs
&&
rootfs
->
path
)
rootfs_path
=
rootfs
->
mount
;
INFO
(
"Mounting container /dev"
);
INFO
(
"Mounting container /dev"
);
/* $(rootfs->mount) + "/dev/pts" + '\0' */
/* $(rootfs->mount) + "/dev/pts" + '\0' */
clen
=
(
rootfs
_path
?
strlen
(
rootfs_path
)
:
0
)
+
9
;
clen
=
(
rootfs
->
path
?
strlen
(
rootfs
->
mount
)
:
0
)
+
9
;
path
=
alloca
(
clen
);
path
=
alloca
(
clen
);
ret
=
snprintf
(
path
,
clen
,
"%s/dev"
,
rootfs
_path
?
rootfs_path
:
""
);
ret
=
snprintf
(
path
,
clen
,
"%s/dev"
,
rootfs
->
path
?
rootfs
->
mount
:
""
);
if
(
ret
<
0
||
ret
>=
clen
)
if
(
ret
<
0
||
ret
>=
clen
)
return
-
1
;
return
-
1
;
...
@@ -1091,7 +1081,7 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, cons
...
@@ -1091,7 +1081,7 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, cons
}
}
ret
=
safe_mount
(
"none"
,
path
,
"tmpfs"
,
0
,
"size=500000,mode=755"
,
ret
=
safe_mount
(
"none"
,
path
,
"tmpfs"
,
0
,
"size=500000,mode=755"
,
rootfs
_path
);
rootfs
->
path
?
rootfs
->
mount
:
NULL
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
SYSERROR
(
"Failed mounting tmpfs onto %s
\n
"
,
path
);
SYSERROR
(
"Failed mounting tmpfs onto %s
\n
"
,
path
);
return
-
1
;
return
-
1
;
...
@@ -1099,7 +1089,7 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, cons
...
@@ -1099,7 +1089,7 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, cons
INFO
(
"Mounted tmpfs onto %s"
,
path
);
INFO
(
"Mounted tmpfs onto %s"
,
path
);
ret
=
snprintf
(
path
,
clen
,
"%s/dev/pts"
,
rootfs
_path
?
rootfs_path
:
""
);
ret
=
snprintf
(
path
,
clen
,
"%s/dev/pts"
,
rootfs
->
path
?
rootfs
->
mount
:
""
);
if
(
ret
<
0
||
ret
>=
clen
)
if
(
ret
<
0
||
ret
>=
clen
)
return
-
1
;
return
-
1
;
...
@@ -1143,14 +1133,9 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
...
@@ -1143,14 +1133,9 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
int
i
;
int
i
;
mode_t
cmask
;
mode_t
cmask
;
/* rootfs struct will be empty when container is created without rootfs. */
char
*
rootfs_path
=
NULL
;
if
(
rootfs
&&
rootfs
->
path
)
rootfs_path
=
rootfs
->
mount
;
INFO
(
"Creating initial consoles under container /dev"
);
INFO
(
"Creating initial consoles under container /dev"
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev"
,
rootfs
_path
?
rootfs_path
:
""
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev"
,
rootfs
->
path
?
rootfs
->
mount
:
""
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
ERROR
(
"Error calculating container /dev location"
);
ERROR
(
"Error calculating container /dev location"
);
return
-
1
;
return
-
1
;
...
@@ -1163,7 +1148,7 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
...
@@ -1163,7 +1148,7 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
cmask
=
umask
(
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
cmask
=
umask
(
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
for
(
i
=
0
;
i
<
sizeof
(
lxc_devs
)
/
sizeof
(
lxc_devs
[
0
]);
i
++
)
{
for
(
i
=
0
;
i
<
sizeof
(
lxc_devs
)
/
sizeof
(
lxc_devs
[
0
]);
i
++
)
{
const
struct
lxc_devs
*
d
=
&
lxc_devs
[
i
];
const
struct
lxc_devs
*
d
=
&
lxc_devs
[
i
];
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev/%s"
,
rootfs
_path
?
rootfs_path
:
""
,
d
->
name
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev/%s"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
d
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
return
-
1
;
ret
=
mknod
(
path
,
d
->
mode
,
makedev
(
d
->
maj
,
d
->
min
));
ret
=
mknod
(
path
,
d
->
mode
,
makedev
(
d
->
maj
,
d
->
min
));
...
@@ -1183,7 +1168,7 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
...
@@ -1183,7 +1168,7 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
}
}
fclose
(
pathfile
);
fclose
(
pathfile
);
if
(
safe_mount
(
hostpath
,
path
,
0
,
MS_BIND
,
NULL
,
if
(
safe_mount
(
hostpath
,
path
,
0
,
MS_BIND
,
NULL
,
rootfs
_path
?
rootfs_path
:
NULL
)
!=
0
)
{
rootfs
->
path
?
rootfs
->
mount
:
NULL
)
!=
0
)
{
SYSERROR
(
"Failed bind mounting device %s from host into container"
,
SYSERROR
(
"Failed bind mounting device %s from host into container"
,
d
->
name
);
d
->
name
);
return
-
1
;
return
-
1
;
...
@@ -1759,6 +1744,9 @@ static int mount_entry_create_aufs_dirs(const struct mntent *mntent,
...
@@ -1759,6 +1744,9 @@ static int mount_entry_create_aufs_dirs(const struct mntent *mntent,
size_t
len
=
0
;
size_t
len
=
0
;
size_t
rootfslen
=
0
;
size_t
rootfslen
=
0
;
/* Since we use all of these to check whether the user has given us a
* sane absolute path to create the directories needed for overlay
* lxc.mount.entry entries we consider any of these missing fatal. */
if
(
!
rootfs
||
!
rootfs
->
path
||
!
lxc_name
||
!
lxc_path
)
if
(
!
rootfs
||
!
rootfs
->
path
||
!
lxc_name
||
!
lxc_path
)
goto
err
;
goto
err
;
...
@@ -1802,7 +1790,6 @@ err:
...
@@ -1802,7 +1790,6 @@ err:
return
fret
;
return
fret
;
}
}
static
int
mount_entry_create_dir_file
(
const
struct
mntent
*
mntent
,
static
int
mount_entry_create_dir_file
(
const
struct
mntent
*
mntent
,
const
char
*
path
,
const
struct
lxc_rootfs
*
rootfs
,
const
char
*
path
,
const
struct
lxc_rootfs
*
rootfs
,
const
char
*
lxc_name
,
const
char
*
lxc_path
)
const
char
*
lxc_name
,
const
char
*
lxc_path
)
...
@@ -1844,6 +1831,8 @@ static int mount_entry_create_dir_file(const struct mntent *mntent,
...
@@ -1844,6 +1831,8 @@ static int mount_entry_create_dir_file(const struct mntent *mntent,
return
ret
;
return
ret
;
}
}
/* rootfs, lxc_name, and lxc_path can be NULL when the container is created
* without a rootfs. */
static
inline
int
mount_entry_on_generic
(
struct
mntent
*
mntent
,
static
inline
int
mount_entry_on_generic
(
struct
mntent
*
mntent
,
const
char
*
path
,
const
struct
lxc_rootfs
*
rootfs
,
const
char
*
path
,
const
struct
lxc_rootfs
*
rootfs
,
const
char
*
lxc_name
,
const
char
*
lxc_path
)
const
char
*
lxc_name
,
const
char
*
lxc_path
)
...
@@ -1853,6 +1842,10 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
...
@@ -1853,6 +1842,10 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
int
ret
;
int
ret
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
char
*
rootfs_path
=
NULL
;
if
(
rootfs
&&
rootfs
->
path
)
rootfs_path
=
rootfs
->
mount
;
ret
=
mount_entry_create_dir_file
(
mntent
,
path
,
rootfs
,
lxc_name
,
lxc_path
);
ret
=
mount_entry_create_dir_file
(
mntent
,
path
,
rootfs
,
lxc_name
,
lxc_path
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -1865,11 +1858,6 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
...
@@ -1865,11 +1858,6 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
return
-
1
;
return
-
1
;
}
}
/* rootfs struct will be empty when container is created without rootfs. */
char
*
rootfs_path
=
NULL
;
if
(
rootfs
&&
rootfs
->
path
)
rootfs_path
=
rootfs
->
mount
;
ret
=
mount_entry
(
mntent
->
mnt_fsname
,
path
,
mntent
->
mnt_type
,
mntflags
,
ret
=
mount_entry
(
mntent
->
mnt_fsname
,
path
,
mntent
->
mnt_type
,
mntflags
,
mntdata
,
optional
,
rootfs_path
);
mntdata
,
optional
,
rootfs_path
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment