1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib
Peter Rajnoha 2f61478436 workaround: gcc v4.8 on 32 bit param. passing bug when -02 opimization used
gcc -O2 v4.8 on 32 bit architecture is causing a bug in parameter
passing. It does not happen with -01 nor -O0.

The problematic part of the code was strlen use in config.c in
the config_def_check fn and the call for _config_def_check_tree in it:

<snip>
  rplen = strlen(rp);
  if (!_config_def_check_tree(handle, vp, vp + strlen(vp), rp, rp + rplen, CFG_PATH_MAX_LEN - rplen, cn, cmd->cft_def_hash)) ...
</snip>

If compiled with -O0 (correct):

Breakpoint 1, config_def_check (cmd=0x819b050, handle=0x81a04f8) at config/config.c:775
(gdb) p	vp
$1 = 0x8189ee0 <_cfg_path> "config"
(gdb) p	strlen(vp)
$2 = 6
(gdb)
_config_def_check_tree (handle=0x81a04f8, vp=0x8189ee0 <_cfg_path>
"config", pvp=0x8189ee6 <_cfg_path+6> "", rp=0xbfffe1e8 "config",
prp=0xbfffe1ee "", buf_size=58, root=0x81a2568, ht=0x81a65
48) at config/config.c:680
(gdb) p	vp
$4 = 0x8189ee0 <_cfg_path> "config"
(gdb) p	pvp
$5 = 0x8189ee6 <_cfg_path+6> ""

If compiled with -O2 (incorrect):

Breakpoint 1, config_def_check (cmd=cmd@entry=0x8183050, handle=0x81884f8) at config/config.c:775
(gdb) p	vp
$1 = 0x8172fc0 <_cfg_path> "config"
(gdb) p strlen(vp)
$2 = 6
(gdb) p	vp + strlen(vp)
$3 = 0x8172fc6 <_cfg_path+6> ""
(gdb)
_config_def_check_tree (handle=handle@entry=0x81884f8, pvp=0x8172fc7
<_cfg_path+7> "host_list", rp=rp@entry=0xbffff190 "config",
prp=prp@entry=0xbffff196 "", buf_size=buf_size@entry=58, ht=0x
818e548, root=0x818a568, vp=0x8172fc0 <_cfg_path> "config") at
config/config.c:674
(gdb) p	pvp
$4 = 0x8172fc7 <_cfg_path+7> "host_list"

The difference is in passing the "pvp" arg for _config_def_check_tree.
While in the correct case, the value of _cfg_path+6 is passed
(the result of vp + strlen(vp) - see the snippet of the code above),
in the incorrect case, this value is increased by 1 to _cfg_path+7,
hence totally malforming the string that is being processed.

This ends up with incorrect validation check and incorrect warning
messages are issued like:

 "Configuration setting "config/checks" has invalid type. Found integer, expected section."

To workaround this issue, remove the "static" qualifier from the
"static char _cfg_path[CFG_PATH_MAX_LEN]". This causes the optimalizer
to be less aggressive (also shuffling the arg list for
_config_def_check_tree call helps).
2013-08-09 13:24:50 +02:00
..
activate Mirror: Fix issue preventing PV creation on mirror LVs 2013-08-07 17:42:26 -05:00
cache cleanup: simplier string reset 2013-07-22 12:41:21 +02:00
commands filters: fix segfault on incorrect global_filter 2013-07-26 13:04:53 +02:00
config workaround: gcc v4.8 on 32 bit param. passing bug when -02 opimization used 2013-08-09 13:24:50 +02:00
datastruct Switch to return void 2012-02-08 12:52:58 +00:00
device dev-type: dev_get_primary_dev default error code 0, not -1 2013-07-19 15:26:53 +02:00
display display: fix units for sizes <1k 2013-07-18 17:55:58 +01:00
error cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
filters config: add config_source_t type to identify configuration source 2013-07-02 15:19:08 +02:00
format1 cleanup: drop unused headers 2013-06-16 00:07:32 +02:00
format_pool cleanup: drop unused headers 2013-06-16 00:07:32 +02:00
format_text lvmetad: fix mda offset/size overflow if >= 4g (32bit) 2013-08-06 13:37:42 +02:00
freeseg cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
label logging: classify log_debug messages 2013-01-07 22:30:29 +00:00
locking locking: unlock memory on error path 2013-07-08 14:02:49 +02:00
log cleanup: use compile time strlen 2013-07-31 15:24:45 +02:00
metadata thin: fix commit e195b5227e 2013-08-06 16:28:12 +02:00
mirror config: add profile arg to find_config_tree_str 2013-07-02 15:19:09 +02:00
misc exec: pipe open 2013-08-06 16:18:43 +02:00
mm config: add profile arg to find_config_tree_bool 2013-07-02 15:19:09 +02:00
properties lvm2app: Add thin and thin pool lv creation 2013-07-12 16:52:16 -05:00
raid config: add profile arg to find_config_tree_str 2013-07-02 15:19:09 +02:00
replicator cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
report reporting: tidy recent new fields 2013-07-19 01:30:02 +01:00
snapshot config: add profile arg to find_config_tree_str 2013-07-02 15:19:09 +02:00
striped Add activation/use_linear_target enabled by default. (prajnoha) 2011-11-28 20:37:51 +00:00
thin thin: metadata resize needs 1.9 version 2013-07-31 15:29:27 +02:00
unknown cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
uuid Revert the #include changes. Need to fix this at the #include site for now, and 2011-07-18 14:34:33 +00:00
zero cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
Makefile.in lib/properties: Common code for handling properties. 2013-07-12 16:52:16 -05:00