{"push_id":2342864162,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"376ae4279128e6871e75caec2563bfe773c03698","before":"c73e4c9608d26b669d0d7c0abbc9f4e9db237007","commits":[{"sha":"376ae4279128e6871e75caec2563bfe773c03698","author":{"name":"mancha security","email":"8c657955bc196da39ca4ec90edf740bb075e97f7@zoho.com"},"message":"lib: memzero_explicit: use barrier instead of OPTIMIZER_HIDE_VAR\n\ncommit 0b053c9518292705736329a8fe20ef4686ffc8e9 upstream.\n\nOPTIMIZER_HIDE_VAR(), as defined when using gcc, is insufficient to\nensure protection from dead store optimization.\n\nFor the random driver and crypto drivers, calls are emitted ...\n\n  $ gdb vmlinux\n  (gdb) disassemble memzero_explicit\n  Dump of assembler code for function memzero_explicit:\n    0xffffffff813a18b0 <+0>:\tpush   %rbp\n    0xffffffff813a18b1 <+1>:\tmov    %rsi,%rdx\n    0xffffffff813a18b4 <+4>:\txor    %esi,%esi\n    0xffffffff813a18b6 <+6>:\tmov    %rsp,%rbp\n    0xffffffff813a18b9 <+9>:\tcallq  0xffffffff813a7120 <memset>\n    0xffffffff813a18be <+14>:\tpop    %rbp\n    0xffffffff813a18bf <+15>:\tretq\n  End of assembler dump.\n\n  (gdb) disassemble extract_entropy\n  [...]\n    0xffffffff814a5009 <+313>:\tmov    %r12,%rdi\n    0xffffffff814a500c <+316>:\tmov    $0xa,%esi\n    0xffffffff814a5011 <+321>:\tcallq  0xffffffff813a18b0 <memzero_explicit>\n    0xffffffff814a5016 <+326>:\tmov    -0x48(%rbp),%rax\n  [...]\n\n... but in case in future we might use facilities such as LTO, then\nOPTIMIZER_HIDE_VAR() is not sufficient to protect gcc from a possible\neviction of the memset(). We have to use a compiler barrier instead.\n\nMinimal test example when we assume memzero_explicit() would *not* be\na call, but would have been *inlined* instead:\n\n  static inline void memzero_explicit(void *s, size_t count)\n  {\n    memset(s, 0, count);\n    <foo>\n  }\n\n  int main(void)\n  {\n    char buff[20];\n\n    snprintf(buff, sizeof(buff) - 1, \"test\");\n    printf(\"%s\", buff);\n\n    memzero_explicit(buff, sizeof(buff));\n    return 0;\n  }\n\nWith <foo> := OPTIMIZER_HIDE_VAR():\n\n  (gdb) disassemble main\n  Dump of assembler code for function main:\n  [...]\n   0x0000000000400464 <+36>:\tcallq  0x400410 <printf@plt>\n   0x0000000000400469 <+41>:\txor    %eax,%eax\n   0x000000000040046b <+43>:\tadd    $0x28,%rsp\n   0x000000000040046f <+47>:\tretq\n  End of assembler dump.\n\nWith <foo> := barrier():\n\n  (gdb) disassemble main\n  Dump of assembler code for function main:\n  [...]\n   0x0000000000400464 <+36>:\tcallq  0x400410 <printf@plt>\n   0x0000000000400469 <+41>:\tmovq   $0x0,(%rsp)\n   0x0000000000400471 <+49>:\tmovq   $0x0,0x8(%rsp)\n   0x000000000040047a <+58>:\tmovl   $0x0,0x10(%rsp)\n   0x0000000000400482 <+66>:\txor    %eax,%eax\n   0x0000000000400484 <+68>:\tadd    $0x28,%rsp\n   0x0000000000400488 <+72>:\tretq\n  End of assembler dump.\n\nAs can be seen, movq, movq, movl are being emitted inlined\nvia memset().\n\nReference: http://thread.gmane.org/gmane.linux.kernel.cryptoapi/13764/\nFixes: d4c5efdb9777 (\"random: add and use memzero_explicit() for clearing data\")\nCc: Theodore Ts'o <tytso@mit.edu>\nSigned-off-by: mancha security <mancha1@zoho.com>\nSigned-off-by: Daniel Borkmann <daniel@iogearbox.net>\nAcked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>\nAcked-by: Stephan Mueller <smueller@chronox.de>\nSigned-off-by: Herbert Xu <herbert@gondor.apana.org.au>\nSigned-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>","distinct":true,"url":"https://api.github.com/repos/ZERONATE/kernel_samsung_grandmaxltekx/commits/376ae4279128e6871e75caec2563bfe773c03698"}]}
{"actor":{"display_login":"DY3413"}}