Re: [lxc-devel] [PATCH] lxc_start: report error message when config is not a regular file
On 10/18/2015 7:10 PM, Serge Hallyn wrote: Quoting Shi, Yang (yang@linaro.org): On 10/15/2015 7:31 AM, Serge Hallyn wrote: Quoting Yang Shi (yang@linaro.org): When run the below command: lxc-start -n name -f /path/to/config If config is not a regular file, lxc-start will be killed by SEG FAULT directly. What exactly was the file to get a segfault? When I try with a device or a directory I do not get a segfault. I'm using lxc 1.1.3 stable release on armv8 target, when I run the below command I got segment fault. # lxc-start -n test -f /var/lib/lxc/test/ lxc-start[309]: unhandled level 2 translation fault (11) at 0x, esr 0x9206 pgd = 80834780e000 [] *pgd=0083cb385003, *pud=0083c99e3003, *pmd= CPU: 2 PID: 309 Comm: lxc-start Not tainted 4.1.10 #25 Hardware name: Freescale Layerscape 2085a RDB Board (DT) task: 80007b944d00 ti: 808347874000 task.ti: 808347874000 PC is at 0x9d1ff2d0 LR is at 0x9d1bc0d0 pc : [<9d1ff2d0>] lr : [<9d1bc0d0>] pstate: 8000 sp : fd9f3af0 x29: fd9f3af0 x28: 00413000 x27: x26: 0001 x25: x24: 00414370 x23: fd9f3be0 x22: 9d35d3b0 x21: 000f x20: 9d37c000 x19: 004166d0 x18: 0001 x17: 9d1bc1e8 x16: 9d37a458 x15: 12010011 x14: 004167e0 x13: x12: 0023 x11: 0023 x10: 0101010101010101 x9 : 7f7f7f7f7f7f7f7f x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : ff4753404f5e5245 x5 : 8000 x4 : x3 : 00485441505f5346 x2 : 544f4f525f43584c x1 : x0 : Exit with some error message to improve user experience. This is not the place to put that check (if it is needed). It should go into either lxc_container_new or load_config, wherever it is failing. Thanks. If you think the segment fault error sounds valid, I will try to move the check to the right place. Could you run that in gdb with lxc debug symbols and show a stack trace? Yes, sure. But, it may need take some time since I have some other urgent tasks right now. Thanks, Yang ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
Re: [lxc-devel] [PATCH] lxc_start: report error message when config is not a regular file
Quoting Shi, Yang (yang@linaro.org): > On 10/15/2015 7:31 AM, Serge Hallyn wrote: > >Quoting Yang Shi (yang@linaro.org): > >>When run the below command: > >>lxc-start -n name -f /path/to/config > >> > >>If config is not a regular file, lxc-start will be killed by SEG FAULT > >>directly. > > > >What exactly was the file to get a segfault? When I try with a device > >or a directory I do not get a segfault. > > I'm using lxc 1.1.3 stable release on armv8 target, when I run the > below command I got segment fault. > > # lxc-start -n test -f /var/lib/lxc/test/ > lxc-start[309]: unhandled level 2 translation fault (11) at > 0x, esr 0x9206 > pgd = 80834780e000 > [] *pgd=0083cb385003, *pud=0083c99e3003, > *pmd= > > CPU: 2 PID: 309 Comm: lxc-start Not tainted 4.1.10 #25 > Hardware name: Freescale Layerscape 2085a RDB Board (DT) > task: 80007b944d00 ti: 808347874000 task.ti: 808347874000 > PC is at 0x9d1ff2d0 > LR is at 0x9d1bc0d0 > pc : [<9d1ff2d0>] lr : [<9d1bc0d0>] pstate: 8000 > sp : fd9f3af0 > x29: fd9f3af0 x28: 00413000 > x27: x26: 0001 > x25: x24: 00414370 > x23: fd9f3be0 x22: 9d35d3b0 > x21: 000f x20: 9d37c000 > x19: 004166d0 x18: 0001 > x17: 9d1bc1e8 x16: 9d37a458 > x15: 12010011 x14: 004167e0 > x13: x12: 0023 > x11: 0023 x10: 0101010101010101 > x9 : 7f7f7f7f7f7f7f7f x8 : 0101010101010101 > x7 : 7f7f7f7f7f7f7f7f x6 : ff4753404f5e5245 > x5 : 8000 x4 : > x3 : 00485441505f5346 x2 : 544f4f525f43584c > x1 : x0 : > > > > >>Exit with some error message to improve user experience. > > > >This is not the place to put that check (if it is needed). It should go > >into either lxc_container_new or load_config, wherever it is failing. > > Thanks. If you think the segment fault error sounds valid, I will > try to move the check to the right place. Could you run that in gdb with lxc debug symbols and show a stack trace? ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
Re: [lxc-devel] [PATCH] lxc_start: report error message when config is not a regular file
Quoting Yang Shi (yang@linaro.org): > When run the below command: > lxc-start -n name -f /path/to/config > > If config is not a regular file, lxc-start will be killed by SEG FAULT > directly. What exactly was the file to get a segfault? When I try with a device or a directory I do not get a segfault. > Exit with some error message to improve user experience. This is not the place to put that check (if it is needed). It should go into either lxc_container_new or load_config, wherever it is failing. > Signed-off-by: Yang Shi> --- > src/lxc/lxc_start.c | 13 + > 1 file changed, 13 insertions(+) > > diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c > index 6b942ac..d1cf779 100644 > --- a/src/lxc/lxc_start.c > +++ b/src/lxc/lxc_start.c > @@ -212,6 +212,7 @@ int main(int argc, char *argv[]) > NULL, > }; > struct lxc_container *c; > + struct stat st_stat = {0}; > > lxc_list_init(); > > @@ -242,6 +243,18 @@ int main(int argc, char *argv[]) > /* rcfile is specified in the cli option */ > if (my_args.rcfile) { > rcfile = (char *)my_args.rcfile; > + tmp = stat(rcfile, _stat); > + > + if (tmp && errno == ENOENT) { > + ERROR("The config path doesn't exist.\n"); > + return err; > + } > + > + if (!tmp && !S_ISREG(st_stat.st_mode)) { > + ERROR("The config is not a regular file.\n"); > + return err; > + } > + > c = lxc_container_new(my_args.name, lxcpath); > if (!c) { > ERROR("Failed to create lxc_container"); > -- > 2.0.2 > > ___ > lxc-devel mailing list > lxc-devel@lists.linuxcontainers.org > http://lists.linuxcontainers.org/listinfo/lxc-devel ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
Re: [lxc-devel] [PATCH] lxc_start: report error message when config is not a regular file
On 10/15/2015 7:31 AM, Serge Hallyn wrote: Quoting Yang Shi (yang@linaro.org): When run the below command: lxc-start -n name -f /path/to/config If config is not a regular file, lxc-start will be killed by SEG FAULT directly. What exactly was the file to get a segfault? When I try with a device or a directory I do not get a segfault. I'm using lxc 1.1.3 stable release on armv8 target, when I run the below command I got segment fault. # lxc-start -n test -f /var/lib/lxc/test/ lxc-start[309]: unhandled level 2 translation fault (11) at 0x, esr 0x9206 pgd = 80834780e000 [] *pgd=0083cb385003, *pud=0083c99e3003, *pmd= CPU: 2 PID: 309 Comm: lxc-start Not tainted 4.1.10 #25 Hardware name: Freescale Layerscape 2085a RDB Board (DT) task: 80007b944d00 ti: 808347874000 task.ti: 808347874000 PC is at 0x9d1ff2d0 LR is at 0x9d1bc0d0 pc : [<9d1ff2d0>] lr : [<9d1bc0d0>] pstate: 8000 sp : fd9f3af0 x29: fd9f3af0 x28: 00413000 x27: x26: 0001 x25: x24: 00414370 x23: fd9f3be0 x22: 9d35d3b0 x21: 000f x20: 9d37c000 x19: 004166d0 x18: 0001 x17: 9d1bc1e8 x16: 9d37a458 x15: 12010011 x14: 004167e0 x13: x12: 0023 x11: 0023 x10: 0101010101010101 x9 : 7f7f7f7f7f7f7f7f x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : ff4753404f5e5245 x5 : 8000 x4 : x3 : 00485441505f5346 x2 : 544f4f525f43584c x1 : x0 : Exit with some error message to improve user experience. This is not the place to put that check (if it is needed). It should go into either lxc_container_new or load_config, wherever it is failing. Thanks. If you think the segment fault error sounds valid, I will try to move the check to the right place. Regards, Yang Signed-off-by: Yang Shi--- src/lxc/lxc_start.c | 13 + 1 file changed, 13 insertions(+) diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c index 6b942ac..d1cf779 100644 --- a/src/lxc/lxc_start.c +++ b/src/lxc/lxc_start.c @@ -212,6 +212,7 @@ int main(int argc, char *argv[]) NULL, }; struct lxc_container *c; + struct stat st_stat = {0}; lxc_list_init(); @@ -242,6 +243,18 @@ int main(int argc, char *argv[]) /* rcfile is specified in the cli option */ if (my_args.rcfile) { rcfile = (char *)my_args.rcfile; + tmp = stat(rcfile, _stat); + + if (tmp && errno == ENOENT) { + ERROR("The config path doesn't exist.\n"); + return err; + } + + if (!tmp && !S_ISREG(st_stat.st_mode)) { + ERROR("The config is not a regular file.\n"); + return err; + } + c = lxc_container_new(my_args.name, lxcpath); if (!c) { ERROR("Failed to create lxc_container"); -- 2.0.2 ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel