On Wed, Apr 26, 2006 at 11:13:16PM +0200, Jonas Meurer wrote: > can you provide the relevant ltrace output?
Sure! Here's an example. I've attached the ltraces for a terminal-based stdin read vs a pipe stdin. As you can see from the hexdumps, the contents are very different, and from the ltrace you can see the broken one stops reading after 32 chars. mylar:~# lvcreate -n test -L1G datavg Logical volume "test" created mylar:~# ltrace cryptsetup create crypt-test /dev/mapper/datavg-test 2>/tmp/working.ltrace Enter passphrase: mylar:~# mkfs.xfs /dev/mapper/crypt-test meta-data=/dev/mapper/crypt-test isize=256 agcount=8, agsize=32768 blks = sectsz=512 attr=0 data = bsize=4096 blocks=262144, imaxpct=25 = sunit=0 swidth=0 blks, unwritten=1 naming =version 2 bsize=4096 log =internal log bsize=4096 blocks=2560, version=1 = sectsz=512 sunit=0 blks realtime =none extsz=65536 blocks=0, rtextents=0 mylar:~# hexdump -n 16 /dev/mapper/crypt-test 0000000 4658 4253 0000 0010 0000 0000 0400 0000 0000010 mylar:~# cryptsetup remove crypt-test mylar:~# echo abcdefghijklmnopqrstuvwxyz0123456789 | ltrace cryptsetup create crypt-test /dev/mapper/datavg-test 2>/tmp/busted.ltrace mylar:~# hexdump -n 16 /dev/mapper/crypt-test 0000000 ee42 a162 6ed6 4075 72d7 6cf8 4763 8e2f 0000010 -- Kees Cook @outflux.net
__libc_start_main(0x804def0, 4, 0xbfacda44, 0x808a3c0, 0x808a430 <unfinished ...> setlocale(6, "") = "C" bindtextdomain("cryptsetup-luks", "/usr/share/locale") = "/usr/share/locale" textdomain("cryptsetup-luks") = "cryptsetup-luks" poptGetContext(0x808af90, 4, 0xbfacda44, 0x80984c0, 0) = 0x809d080 poptSetOtherOptionHelp(0x809d080, 0x808b410, 0xbfacda44, 0x80984c0, 0) = 0x809d270 poptGetNextOpt(0x809d080, 0x808b410, 0xbfacda44, 0x80984c0, 0) = -1 poptGetArg(0x809d080, 0x808b410, 0xbfacda44, 0x80984c0, 0) = 0xbfacde90 strcmp("create", "create") = 0 poptGetArgs(0x809d080, 0xbfacde90, 0xbfacda44, 0x80984c0, 0) = 0x809d21c memset(0xbfacd898, '\000', 84) = 0xbfacd898 mlockall(3, 0xbfacd898, 0xbfacde90, 0, 0xbfacd8f8) = 0 dm_log_init(0x804a4e0, 0x8098108, 0xbfacd878, 0x804c4e9, 0) = 0xb7fa74e0 memset(0xbfacd7d0, '\000', 84) = 0xbfacd7d0 dm_task_create(10, 0, 0, 0, 0) = 0x809d2a0 dm_task_set_name(0x809d2a0, 0xbfacde97, 0, 0, 0) = 1 dm_task_run(0x809d2a0, 0xbfacde97, 0, 0, 0) = 1 dm_task_get_info(0x809d2a0, 0xbfacd748, 0, 0, 0) = 1 dm_task_destroy(0x809d2a0, 0xbfacd748, 0, 0, 0) = 177 open64("/dev/mapper/datavg-test", 0, 026776272554) = 4 ioctl(4, 4702, 0xbfacd790) = 0 ioctl(4, -2147216782, 0xbfacd788) = 0 close(4) = 0 signal(14, 0x804b140) = NULL alarm(0) = 0 isatty(0) = 1 getpass("Enter passphrase: ") = "abcdefghijklmnopqrstuvwxyz012345"... strlen("abcdefghijklmnopqrstuvwxyz012345"...) = 36 malloc(41) = 0x809d320 strcpy(0x809d324, "abcdefghijklmnopqrstuvwxyz012345"...) = 0x809d324 strlen("abcdefghijklmnopqrstuvwxyz012345"...) = 36 memset(0x809d2a0, '\000', 36) = 0x809d2a0 strlen("abcdefghijklmnopqrstuvwxyz012345"...) = 36 malloc(36) = 0x809d560 malloc(24) = 0x809d588 malloc(24) = 0x809d5a8 malloc(24) = 0x809d5c8 malloc(24) = 0x809d5e8 malloc(24) = 0x809d608 malloc(24) = 0x809d628 malloc(24) = 0x809d648 malloc(24) = 0x809d668 malloc(24) = 0x809d688 malloc(24) = 0x809d6a8 malloc(24) = 0x809d6c8 malloc(24) = 0x809d6e8 malloc(24) = 0x809d708 malloc(24) = 0x809d728 malloc(24) = 0x809d748 malloc(24) = 0x809d768 malloc(24) = 0x809d788 malloc(24) = 0x809d7a8 malloc(24) = 0x809d7c8 malloc(24) = 0x809d7e8 malloc(24) = 0x809d808 malloc(24) = 0x809d828 malloc(24) = 0x809d848 malloc(24) = 0x809d868 malloc(24) = 0x809d888 malloc(24) = 0x809d8a8 malloc(24) = 0x809d8c8 malloc(24) = 0x809d8e8 malloc(24) = 0x809d908 __ctype_b_loc() = 0xb7e026ac __ctype_b_loc() = 0xb7e026ac __ctype_b_loc() = 0xb7e026ac __ctype_b_loc() = 0xb7e026ac __ctype_b_loc() = 0xb7e026ac __ctype_b_loc() = 0xb7e026ac malloc(256) = 0x809d928 malloc(144) = 0x809da30 __strdup(0x80950f7, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809dac8 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094e20, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809dad8 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094e3e, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809dae8 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094cfb, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809daf8 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8095119, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809db08 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8095100, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809db18 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094ccf, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809db28 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094cb8, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809db38 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094c98, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809db48 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094ca5, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809db60 __ctype_tolower_loc() = 0xb7e026a4 __strdup(0x8094cb2, 0xbfacd768, 0xb7f908b8, 0xb7f90960, 5) = 0x809db78 __ctype_tolower_loc() = 0xb7e026a4 free(0x809d928) = <void> strcmp("tiger192", "ripemd160") = 1 strcmp("sha384", "ripemd160") = 1 strcmp("sha512", "ripemd160") = 1 strcmp("sha256", "ripemd160") = 1 strcmp("sha1", "ripemd160") = 1 strcmp("ripemd160", "ripemd160") = 0 malloc(1068) = 0x809db88 malloc(108) = 0x809d928 strlen("abcdefghijklmnopqrstuvwxyz012345"...) = 36 memcpy(0xbfacd64c, "abcdefghijklmnopqrstuvwxyz012345"..., 64) = 0xbfacd64c memcpy(0x809d564, "\255\231T\301"\250\237\357}.", 20) = 0x809d564 memset(0x809d938, '\000', 92) = 0x809d938 strlen("abcdefghijklmnopqrstuvwxyz012345"...) = 36 memcpy(0xbfacd64c, "Aabcdefghijklmnopqrstuvwxyz01234"..., 64) = 0xbfacd64c memcpy(0x809d578, "\213+\002Q\251/\331\337\016e\247\002", 12) = 0x809d578 free(0x809d928) = <void> free(0x809db88) = <void> free(0x809dac8) = <void> free(0x809dad8) = <void> free(0x809dae8) = <void> free(0x809daf8) = <void> free(0x809db08) = <void> free(0x809db18) = <void> free(0x809db28) = <void> free(0x809db38) = <void> free(0x809db48) = <void> free(0x809db60) = <void> free(0x809db78) = <void> free(0x809da30) = <void> memset(0x809d324, '\000', 37) = 0x809d324 free(0x809d320) = <void> malloc(69) = 0x809d928 sprintf("ad", "%02x", 0xad) = 2 sprintf("99", "%02x", 0x99) = 2 sprintf("54", "%02x", 0x54) = 2 sprintf("c1", "%02x", 0xc1) = 2 sprintf("22", "%02x", 0x22) = 2 sprintf("a8", "%02x", 0xa8) = 2 sprintf("9f", "%02x", 0x9f) = 2 sprintf("ef", "%02x", 0xef) = 2 sprintf("7d", "%02x", 0x7d) = 2 sprintf("2e", "%02x", 0x2e) = 2 sprintf("00", "%02x", 0) = 2 sprintf("da", "%02x", 0xda) = 2 sprintf("bf", "%02x", 0xbf) = 2 sprintf("26", "%02x", 0x26) = 2 sprintf("a7", "%02x", 0xa7) = 2 sprintf("16", "%02x", 0x16) = 2 sprintf("59", "%02x", 0x59) = 2 sprintf("f7", "%02x", 0xf7) = 2 sprintf("03", "%02x", 0x3) = 2 sprintf("d5", "%02x", 0xd5) = 2 sprintf("8b", "%02x", 0x8b) = 2 sprintf("2b", "%02x", 0x2b) = 2 sprintf("02", "%02x", 0x2) = 2 sprintf("51", "%02x", 0x51) = 2 sprintf("a9", "%02x", 0xa9) = 2 sprintf("2f", "%02x", 0x2f) = 2 sprintf("d9", "%02x", 0xd9) = 2 sprintf("df", "%02x", 0xdf) = 2 sprintf("0e", "%02x", 0xe) = 2 sprintf("65", "%02x", 0x65) = 2 sprintf("a7", "%02x", 0xa7) = 2 sprintf("02", "%02x", 0x2) = 2 strlen("ad9954c122a89fef7d2e00dabf26a716"...) = 64 strlen("aes") = 3 strlen("/dev/mapper/datavg-test") = 23 malloc(158) = 0x809d978 sprintf("aes ad9954c122a89fef7d2e00dabf26"..., "%s %s %llu %s %llu", "aes", "ad9954c122a89fef7d2e00dabf26a716"..., ...) = 96 memset(0x809d92c, '\000', 65) = 0x809d92c free(0x809d928) = <void> dm_task_create(0, 0x808a57c, 0x808ad35, 0x809d92c, 0) = 0x809da20 dm_task_set_name(0x809da20, 0xbfacde97, 0x808ad35, 0x809d92c, 0) = 1 dm_task_add_target(0x809da20, 0, 0, 0x200000, 0) = 1 dm_task_run(0x809da20, 0, 0, 0x200000, 0) = 1 dm_task_get_info(0x809da20, 0xbfacd774, 0, 0x200000, 0) = 1 memset(0x809d97c, '\000', 154) = 0x809d97c free(0x809d978) = <void> dm_task_destroy(0x809da20, 0xbfacd774, 0, 0x200000, 0) = 0 dm_log_init(0, 0x8098108, 0xbfacd728, 0x804a58b, 0x809da20) = 0xb7fa74e0 dm_lib_release(0, 0x8098108, 0xbfacd728, 0x804a58b, 0x809da20) = 0xb7fa74e4 dm_log_init(0x804a4e0, 0x8098108, 0xbfacd7a8, 0x804a8fc, 0x809da20) = 0xb7fa74e0 memset(0x809d564, '\000', 32) = 0x809d564 free(0x809d560) = <void> dm_log_init(0, 0x8098108, 0xbfacd878, 0x804c515, 0) = 0xb7fa74e0 dm_lib_release(0, 0x8098108, 0xbfacd878, 0x804c515, 0) = 0xb7fa74e4 +++ exited (status 0) +++
__libc_start_main(0x804def0, 4, 0xbf8a76e4, 0x808a3c0, 0x808a430 <unfinished ...> setlocale(6, "") = "C" bindtextdomain("cryptsetup-luks", "/usr/share/locale") = "/usr/share/locale" textdomain("cryptsetup-luks") = "cryptsetup-luks" poptGetContext(0x808af90, 4, 0xbf8a76e4, 0x80984c0, 0) = 0x809d080 poptSetOtherOptionHelp(0x809d080, 0x808b410, 0xbf8a76e4, 0x80984c0, 0) = 0x809d270 poptGetNextOpt(0x809d080, 0x808b410, 0xbf8a76e4, 0x80984c0, 0) = -1 poptGetArg(0x809d080, 0x808b410, 0xbf8a76e4, 0x80984c0, 0) = 0xbf8a7e90 strcmp("create", "create") = 0 poptGetArgs(0x809d080, 0xbf8a7e90, 0xbf8a76e4, 0x80984c0, 0) = 0x809d21c memset(0xbf8a7538, '\000', 84) = 0xbf8a7538 mlockall(3, 0xbf8a7538, 0xbf8a7e90, 0, 0xbf8a7598) = 0 dm_log_init(0x804a4e0, 0x8098108, 0xbf8a7518, 0x804c4e9, 0) = 0xb7f814e0 memset(0xbf8a7470, '\000', 84) = 0xbf8a7470 dm_task_create(10, 0, 0, 0, 0) = 0x809d2a0 dm_task_set_name(0x809d2a0, 0xbf8a7e97, 0, 0, 0) = 1 dm_task_run(0x809d2a0, 0xbf8a7e97, 0, 0, 0) = 1 dm_task_get_info(0x809d2a0, 0xbf8a73e8, 0, 0, 0) = 1 dm_task_destroy(0x809d2a0, 0xbf8a73e8, 0, 0, 0) = 177 open64("/dev/mapper/datavg-test", 0, 026775612554) = 4 ioctl(4, 4702, 0xbf8a7430) = 0 ioctl(4, -2147216782, 0xbf8a7428) = 0 close(4) = 0 signal(14, 0x804b140) = NULL alarm(0) = 0 isatty(0) = 0 malloc(132) = 0x809d2a0 read(0, "a", 1) = 1 read(0, "b", 1) = 1 read(0, "c", 1) = 1 read(0, "d", 1) = 1 read(0, "e", 1) = 1 read(0, "f", 1) = 1 read(0, "g", 1) = 1 read(0, "h", 1) = 1 read(0, "i", 1) = 1 read(0, "j", 1) = 1 read(0, "k", 1) = 1 read(0, "l", 1) = 1 read(0, "m", 1) = 1 read(0, "n", 1) = 1 read(0, "o", 1) = 1 read(0, "p", 1) = 1 read(0, "q", 1) = 1 read(0, "r", 1) = 1 read(0, "s", 1) = 1 read(0, "t", 1) = 1 read(0, "u", 1) = 1 read(0, "v", 1) = 1 read(0, "w", 1) = 1 read(0, "x", 1) = 1 read(0, "y", 1) = 1 read(0, "z", 1) = 1 read(0, "0", 1) = 1 read(0, "1", 1) = 1 read(0, "2", 1) = 1 read(0, "3", 1) = 1 read(0, "4", 1) = 1 read(0, "5", 1) = 1 alarm(0) = 0 malloc(36) = 0x809d328 malloc(24) = 0x809d560 malloc(24) = 0x809d580 malloc(24) = 0x809d5a0 malloc(24) = 0x809d5c0 malloc(24) = 0x809d5e0 malloc(24) = 0x809d600 malloc(24) = 0x809d620 malloc(24) = 0x809d640 malloc(24) = 0x809d660 malloc(24) = 0x809d680 malloc(24) = 0x809d6a0 malloc(24) = 0x809d6c0 malloc(24) = 0x809d6e0 malloc(24) = 0x809d700 malloc(24) = 0x809d720 malloc(24) = 0x809d740 malloc(24) = 0x809d760 malloc(24) = 0x809d780 malloc(24) = 0x809d7a0 malloc(24) = 0x809d7c0 malloc(24) = 0x809d7e0 malloc(24) = 0x809d800 malloc(24) = 0x809d820 malloc(24) = 0x809d840 malloc(24) = 0x809d860 malloc(24) = 0x809d880 malloc(24) = 0x809d8a0 malloc(24) = 0x809d8c0 malloc(24) = 0x809d8e0 __ctype_b_loc() = 0xb7ddc6ac __ctype_b_loc() = 0xb7ddc6ac __ctype_b_loc() = 0xb7ddc6ac __ctype_b_loc() = 0xb7ddc6ac __ctype_b_loc() = 0xb7ddc6ac __ctype_b_loc() = 0xb7ddc6ac malloc(256) = 0x809d900 malloc(144) = 0x809da08 __strdup(0x80950f7, 0xbf8a7408, 0x809d320, 1, 5) = 0x809daa0 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094e20, 0xbf8a7408, 0x809d320, 1, 5) = 0x809dab0 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094e3e, 0xbf8a7408, 0x809d320, 1, 5) = 0x809dac0 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094cfb, 0xbf8a7408, 0x809d320, 1, 5) = 0x809dad0 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8095119, 0xbf8a7408, 0x809d320, 1, 5) = 0x809dae0 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8095100, 0xbf8a7408, 0x809d320, 1, 5) = 0x809daf0 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094ccf, 0xbf8a7408, 0x809d320, 1, 5) = 0x809db00 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094cb8, 0xbf8a7408, 0x809d320, 1, 5) = 0x809db10 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094c98, 0xbf8a7408, 0x809d320, 1, 5) = 0x809db20 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094ca5, 0xbf8a7408, 0x809d320, 1, 5) = 0x809db38 __ctype_tolower_loc() = 0xb7ddc6a4 __strdup(0x8094cb2, 0xbf8a7408, 0x809d320, 1, 5) = 0x809db50 __ctype_tolower_loc() = 0xb7ddc6a4 free(0x809d900) = <void> strcmp("tiger192", "ripemd160") = 1 strcmp("sha384", "ripemd160") = 1 strcmp("sha512", "ripemd160") = 1 strcmp("sha256", "ripemd160") = 1 strcmp("sha1", "ripemd160") = 1 strcmp("ripemd160", "ripemd160") = 0 malloc(1068) = 0x809db60 malloc(108) = 0x809d900 strlen("abcdefghijklmnopqrstuvwxyz012345") = 32 memcpy(0xbf8a72ec, "abcdefghijklmnopqrstuvwxyz012345"..., 64) = 0xbf8a72ec memcpy(0x809d32c, "\2006u\212\374\177\304\213Y\3446\250\317\360\024*\t\310\276Y", 20) = 0x809d32c memset(0x809d910, '\000', 92) = 0x809d910 strlen("abcdefghijklmnopqrstuvwxyz012345") = 32 memcpy(0xbf8a72ec, "Aabcdefghijklmnopqrstuvwxyz01234"..., 64) = 0xbf8a72ec memcpy(0x809d340, "^\025\314\030\001\016;aF`\374H", 12) = 0x809d340 free(0x809d900) = <void> free(0x809db60) = <void> free(0x809daa0) = <void> free(0x809dab0) = <void> free(0x809dac0) = <void> free(0x809dad0) = <void> free(0x809dae0) = <void> free(0x809daf0) = <void> free(0x809db00) = <void> free(0x809db10) = <void> free(0x809db20) = <void> free(0x809db38) = <void> free(0x809db50) = <void> free(0x809da08) = <void> memset(0x809d2a4, '\000', 128) = 0x809d2a4 free(0x809d2a0) = <void> malloc(69) = 0x809d2a0 sprintf("80", "%02x", 0x80) = 2 sprintf("36", "%02x", 0x36) = 2 sprintf("75", "%02x", 0x75) = 2 sprintf("8a", "%02x", 0x8a) = 2 sprintf("fc", "%02x", 0xfc) = 2 sprintf("7f", "%02x", 0x7f) = 2 sprintf("c4", "%02x", 0xc4) = 2 sprintf("8b", "%02x", 0x8b) = 2 sprintf("59", "%02x", 0x59) = 2 sprintf("e4", "%02x", 0xe4) = 2 sprintf("36", "%02x", 0x36) = 2 sprintf("a8", "%02x", 0xa8) = 2 sprintf("cf", "%02x", 0xcf) = 2 sprintf("f0", "%02x", 0xf0) = 2 sprintf("14", "%02x", 0x14) = 2 sprintf("2a", "%02x", 0x2a) = 2 sprintf("09", "%02x", 0x9) = 2 sprintf("c8", "%02x", 0xc8) = 2 sprintf("be", "%02x", 0xbe) = 2 sprintf("59", "%02x", 0x59) = 2 sprintf("5e", "%02x", 0x5e) = 2 sprintf("15", "%02x", 0x15) = 2 sprintf("cc", "%02x", 0xcc) = 2 sprintf("18", "%02x", 0x18) = 2 sprintf("01", "%02x", 0x1) = 2 sprintf("0e", "%02x", 0xe) = 2 sprintf("3b", "%02x", 0x3b) = 2 sprintf("61", "%02x", 0x61) = 2 sprintf("46", "%02x", 0x46) = 2 sprintf("60", "%02x", 0x60) = 2 sprintf("fc", "%02x", 0xfc) = 2 sprintf("48", "%02x", 0x48) = 2 strlen("8036758afc7fc48b59e436a8cff0142a"...) = 64 strlen("aes") = 3 strlen("/dev/mapper/datavg-test") = 23 malloc(158) = 0x809d900 sprintf("aes 8036758afc7fc48b59e436a8cff0"..., "%s %s %llu %s %llu", "aes", "8036758afc7fc48b59e436a8cff0142a"..., ...) = 96 memset(0x809d2a4, '\000', 65) = 0x809d2a4 free(0x809d2a0) = <void> dm_task_create(0, 0x808a57c, 0x808ad35, 0x809d2a4, 0) = 0x809d2a0 dm_task_set_name(0x809d2a0, 0xbf8a7e97, 0x808ad35, 0x809d2a4, 0) = 1 dm_task_add_target(0x809d2a0, 0, 0, 0x200000, 0) = 1 dm_task_run(0x809d2a0, 0, 0, 0x200000, 0) = 1 dm_task_get_info(0x809d2a0, 0xbf8a7414, 0, 0x200000, 0) = 1 memset(0x809d904, '\000', 154) = 0x809d904 free(0x809d900) = <void> dm_task_destroy(0x809d2a0, 0xbf8a7414, 0, 0x200000, 0) = 137 dm_log_init(0, 0x8098108, 0xbf8a73c8, 0x804a58b, 0x809d2a0) = 0xb7f814e0 dm_lib_release(0, 0x8098108, 0xbf8a73c8, 0x804a58b, 0x809d2a0) = 0xb7f814e4 dm_log_init(0x804a4e0, 0x8098108, 0xbf8a7448, 0x804a8fc, 0x809d2a0) = 0xb7f814e0 memset(0x809d32c, '\000', 32) = 0x809d32c free(0x809d328) = <void> dm_log_init(0, 0x8098108, 0xbf8a7518, 0x804c515, 0) = 0xb7f814e0 dm_lib_release(0, 0x8098108, 0xbf8a7518, 0x804c515, 0) = 0xb7f814e4 +++ exited (status 0) +++