Skip to content

Commit

Permalink
Fix miscellaneous issues (torvalds#397)
Browse files Browse the repository at this point in the history
* lkl: Fix a crash issue when no configuration file is specified

When no env variables nor json files are configured, it sometimes
crashes due to uninitialized value of lkl_config->ifnum.  This patch
fixes this issue by simply zero-ing the values.

Fixes: 842d02f ("lkl: Support json configuration and multiple
interfaces")

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>

* lkl: fix typos on getsockopt/setsockopt

This typo was there since the first version.

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>

* lkl: let debug print disabled if 0 is specified.

Reported at https://goo.gl/WpdLjg

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
  • Loading branch information
thehajime authored Nov 18, 2017
1 parent 8fbd00d commit 8789227
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Documentation/lkl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ The following are the list of keys to describe a JSON file.
value type: string

Setting it causes some debug information (both from the kernel and the
LKL library) to be enabled.
LKL library) to be enabled. If zero' is specified it is disabled.
It is also used as a bit mask to turn on specific debugging facilities.
E.g., setting it to "0x100" will cause the LKL kernel to pause after
the hijack'ed app exits. This allows one to debug or collect info from
Expand Down
30 changes: 3 additions & 27 deletions tools/lkl/lib/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,35 +322,11 @@ int load_config_env(struct lkl_config *cfg)

int init_config(struct lkl_config *cfg)
{
int i;

if (!cfg)
return -1;
for (i = 0; i < LKL_IF_MAX; i++) {
cfg->iftap[i] = NULL;
cfg->iftype[i] = NULL;
cfg->ifparams[i] = NULL;
cfg->ifmtu_str[i] = NULL;
cfg->ifip[i] = NULL;
cfg->ifipv6[i] = NULL;
cfg->ifgateway[i] = NULL;
cfg->ifgateway6[i] = NULL;
cfg->ifmac_str[i] = NULL;
cfg->ifnetmask_len[i] = NULL;
cfg->ifnetmask6_len[i] = NULL;
cfg->ifoffload_str[i] = NULL;
cfg->ifneigh_entries[i] = NULL;
cfg->ifqdisc_entries[i] = NULL;
}
cfg->gateway = NULL;
cfg->gateway6 = NULL;
cfg->debug = NULL;
cfg->mount = NULL;
cfg->single_cpu = NULL;
cfg->sysctls = NULL;
cfg->boot_cmdline = NULL;
cfg->dump = NULL;
cfg->delay_main = NULL;

memset(cfg, 0, sizeof(struct lkl_config));

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/lkl/lib/hijack/hijack.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen)
{
CHECK_HOST_CALL(getsockopt);
if (!is_lklfd(fd))
return host_setsockopt(fd, level, optname, optval, optlen);
return host_getsockopt(fd, level, optname, optval, optlen);
return lkl_call(__lkl__NR_getsockopt, 5, fd, lkl_solevel_xlate(level),
lkl_soname_xlate(optname), optval, (int*)optlen);
}
Expand Down
8 changes: 5 additions & 3 deletions tools/lkl/lib/hijack/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,15 @@ hijack_init(void)
return;
for (i = 0; i < LKL_IF_MAX; i++)
nd_id[i] = -1;
if (!cfg->debug) {
lkl_host_ops.print = NULL;
} else {

if (cfg->debug) {
lkl_register_dbg_handler();
lkl_debug = strtol(cfg->debug, NULL, 0);
}

if (!cfg->debug || (lkl_debug == 0))
lkl_host_ops.print = NULL;

if (lkl_debug & 0x200) {
char c;

Expand Down

0 comments on commit 8789227

Please sign in to comment.