qga: set umask 0077 when daemonizing (CVE-2013-2007)

The qemu guest agent creates a bunch of files with insecure permissions
when started in daemon mode. For example:

  -rw-rw-rw- 1 root root /var/log/qemu-ga.log
  -rw-rw-rw- 1 root root /var/run/qga.state
  -rw-rw-rw- 1 root root /var/log/qga-fsfreeze-hook.log

In addition, at least all files created with the "guest-file-open" QMP
command, and all files created with shell output redirection (or
otherwise) by utilities invoked by the fsfreeze hook script are affected.

For now mask all file mode bits for "group" and "others" in
become_daemon().

Temporarily, for compatibility reasons, stick with the 0666 file-mode in
case of files newly created by the "guest-file-open" QMP call. Do so
without changing the umask temporarily.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2 files changed
tree: e9432502391143692a6400bf888b0ecbc52ea7fc
  1. audio/
  2. backends/
  3. block/
  4. bsd-user/
  5. default-configs/
  6. disas/
  7. docs/
  8. fpu/
  9. fsdev/
  10. gdb-xml/
  11. hw/
  12. include/
  13. ldscripts/
  14. libcacard/
  15. linux-headers/
  16. linux-user/
  17. net/
  18. pc-bios/
  19. po/
  20. qapi/
  21. qga/
  22. QMP/
  23. qobject/
  24. qom/
  25. roms/
  26. scripts/
  27. slirp/
  28. stubs/
  29. sysconfigs/
  30. target-alpha/
  31. target-arm/
  32. target-cris/
  33. target-i386/
  34. target-lm32/
  35. target-m68k/
  36. target-microblaze/
  37. target-mips/
  38. target-moxie/
  39. target-openrisc/
  40. target-ppc/
  41. target-s390x/
  42. target-sh4/
  43. target-sparc/
  44. target-unicore32/
  45. target-xtensa/
  46. tcg/
  47. tests/
  48. trace/
  49. ui/
  50. util/
  51. .exrc
  52. .gitignore
  53. .gitmodules
  54. .mailmap
  55. aio-posix.c
  56. aio-win32.c
  57. arch_init.c
  58. async.c
  59. balloon.c
  60. block-migration.c
  61. block.c
  62. blockdev-nbd.c
  63. blockdev.c
  64. blockjob.c
  65. bt-host.c
  66. bt-vhci.c
  67. Changelog
  68. cmd.c
  69. cmd.h
  70. CODING_STYLE
  71. configure
  72. COPYING
  73. COPYING.LIB
  74. coroutine-gthread.c
  75. coroutine-sigaltstack.c
  76. coroutine-ucontext.c
  77. coroutine-win32.c
  78. cpu-exec.c
  79. cpus.c
  80. cputlb.c
  81. device-hotplug.c
  82. device_tree.c
  83. disas.c
  84. dma-helpers.c
  85. dump-stub.c
  86. dump.c
  87. exec.c
  88. gdbstub.c
  89. HACKING
  90. hmp-commands.hx
  91. hmp.c
  92. hmp.h
  93. iohandler.c
  94. ioport.c
  95. kvm-all.c
  96. kvm-stub.c
  97. LICENSE
  98. main-loop.c
  99. MAINTAINERS
  100. Makefile
  101. Makefile.objs
  102. Makefile.target
  103. memory.c
  104. memory_mapping-stub.c
  105. memory_mapping.c
  106. migration-exec.c
  107. migration-fd.c
  108. migration-tcp.c
  109. migration-unix.c
  110. migration.c
  111. monitor.c
  112. nbd.c
  113. os-posix.c
  114. os-win32.c
  115. page_cache.c
  116. qapi-schema-test.json
  117. qapi-schema.json
  118. qdev-monitor.c
  119. qdict-test-data.txt
  120. qemu-bridge-helper.c
  121. qemu-char.c
  122. qemu-coroutine-io.c
  123. qemu-coroutine-lock.c
  124. qemu-coroutine-sleep.c
  125. qemu-coroutine.c
  126. qemu-doc.texi
  127. qemu-img-cmds.hx
  128. qemu-img.c
  129. qemu-img.texi
  130. qemu-io.c
  131. qemu-log.c
  132. qemu-nbd.c
  133. qemu-nbd.texi
  134. qemu-options-wrapper.h
  135. qemu-options.h
  136. qemu-options.hx
  137. qemu-seccomp.c
  138. qemu-tech.texi
  139. qemu-timer.c
  140. qemu.sasl
  141. qmp-commands.hx
  142. qmp.c
  143. qtest.c
  144. readline.c
  145. README
  146. rules.mak
  147. savevm.c
  148. spice-qemu-char.c
  149. tcg-runtime.c
  150. tci.c
  151. thread-pool.c
  152. thunk.c
  153. tpm.c
  154. trace-events
  155. translate-all.c
  156. translate-all.h
  157. user-exec.c
  158. VERSION
  159. version.rc
  160. vl.c
  161. xbzrle.c
  162. xen-all.c
  163. xen-mapcache.c
  164. xen-stub.c