hw/9pfs: replace iovec manipulation with QEMUIOVector

The v9fs_read() and v9fs_write() functions rely on iovec[] manipulation
code should be replaced with QEMUIOVector to avoid duplicating code.
In the future it may be possible to make the code even more concise by
using QEMUIOVector consistently across virtio and 9pfs.

The "v" format specifier for pdu_marshal() and pdu_unmarshal() is
dropped since it does not actually pack/unpack anything.  The specifier
was also not implemented to update the offset variable and could only be
used at the end of a format string, another sign that this shouldn't
really be a format specifier.  Instead, see the new
v9fs_init_qiov_from_pdu() function.

This change avoids a possible iovec[] buffer overflow when indirect
vrings are used since the number of vectors is now limited by the
underlying VirtQueueElement and cannot be out-of-bounds.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
1 file changed
tree: d8b168af72641484a578bb2b16be4e2c0fb5273f
  1. audio/
  2. block/
  3. bsd-user/
  4. darwin-user/
  5. default-configs/
  6. docs/
  7. fpu/
  8. fsdev/
  9. gdb-xml/
  10. hw/
  11. libcacard/
  12. linux-headers/
  13. linux-user/
  14. net/
  15. pc-bios/
  16. qapi/
  17. qga/
  18. QMP/
  19. roms/
  20. scripts/
  21. slirp/
  22. sysconfigs/
  23. target-alpha/
  24. target-arm/
  25. target-cris/
  26. target-i386/
  27. target-lm32/
  28. target-m68k/
  29. target-microblaze/
  30. target-mips/
  31. target-ppc/
  32. target-s390x/
  33. target-sh4/
  34. target-sparc/
  35. target-unicore32/
  36. target-xtensa/
  37. tcg/
  38. tests/
  39. trace/
  40. ui/
  41. .gitignore
  42. .gitmodules
  43. .mailmap
  44. a.out.h
  45. acl.c
  46. acl.h
  47. aes.c
  48. aes.h
  49. aio.c
  50. alpha-dis.c
  51. alpha.ld
  52. arch_init.c
  53. arch_init.h
  54. arm-dis.c
  55. arm-semi.c
  56. arm.ld
  57. async.c
  58. balloon.c
  59. balloon.h
  60. bitmap.c
  61. bitmap.h
  62. bitops.c
  63. bitops.h
  64. block-migration.c
  65. block-migration.h
  66. block.c
  67. block.h
  68. block_int.h
  69. blockdev.c
  70. blockdev.h
  71. bswap.h
  72. bt-host.c
  73. bt-host.h
  74. bt-vhci.c
  75. buffered_file.c
  76. buffered_file.h
  77. cache-utils.c
  78. cache-utils.h
  79. Changelog
  80. check-qdict.c
  81. check-qfloat.c
  82. check-qint.c
  83. check-qjson.c
  84. check-qlist.c
  85. check-qstring.c
  86. cmd.c
  87. cmd.h
  88. CODING_STYLE
  89. compatfd.c
  90. compatfd.h
  91. compiler.h
  92. config.h
  93. configure
  94. console.c
  95. console.h
  96. COPYING
  97. COPYING.LIB
  98. coroutine-gthread.c
  99. coroutine-ucontext.c
  100. coroutine-win32.c
  101. cpu-all.h
  102. cpu-common.h
  103. cpu-defs.h
  104. cpu-exec.c
  105. cpus.c
  106. cpus.h
  107. cris-dis.c
  108. cursor.c
  109. cursor_hidden.xpm
  110. cursor_left_ptr.xpm
  111. cutils.c
  112. def-helper.h
  113. device_tree.c
  114. device_tree.h
  115. dis-asm.h
  116. disas.c
  117. disas.h
  118. dma-helpers.c
  119. dma.h
  120. dyngen-exec.h
  121. elf.h
  122. envlist.c
  123. envlist.h
  124. error.c
  125. error.h
  126. error_int.h
  127. event_notifier.c
  128. event_notifier.h
  129. exec-all.h
  130. exec-memory.h
  131. exec-obsolete.h
  132. exec.c
  133. gdbstub.c
  134. gdbstub.h
  135. gen-icount.h
  136. HACKING
  137. hmp-commands.hx
  138. hmp.c
  139. hmp.h
  140. host-utils.c
  141. host-utils.h
  142. hppa-dis.c
  143. hppa.ld
  144. i386-dis.c
  145. i386.ld
  146. ia64-dis.c
  147. ia64.ld
  148. input.c
  149. int128.h
  150. iohandler.c
  151. ioport-user.c
  152. ioport.c
  153. ioport.h
  154. iorange.h
  155. iov.c
  156. iov.h
  157. json-lexer.c
  158. json-lexer.h
  159. json-parser.c
  160. json-parser.h
  161. json-streamer.c
  162. json-streamer.h
  163. kvm-all.c
  164. kvm-stub.c
  165. kvm.h
  166. libfdt_env.h
  167. LICENSE
  168. linux-aio.c
  169. m68k-dis.c
  170. m68k-semi.c
  171. m68k.ld
  172. main-loop.c
  173. main-loop.h
  174. MAINTAINERS
  175. Makefile
  176. Makefile.dis
  177. Makefile.hw
  178. Makefile.objs
  179. Makefile.target
  180. Makefile.user
  181. memory.c
  182. memory.h
  183. microblaze-dis.c
  184. migration-exec.c
  185. migration-fd.c
  186. migration-tcp.c
  187. migration-unix.c
  188. migration.c
  189. migration.h
  190. mips-dis.c
  191. mips.ld
  192. module.c
  193. module.h
  194. monitor.c
  195. monitor.h
  196. nbd.c
  197. nbd.h
  198. net.c
  199. net.h
  200. notify.c
  201. notify.h
  202. os-posix.c
  203. os-win32.c
  204. osdep.c
  205. osdep.h
  206. oslib-posix.c
  207. oslib-win32.c
  208. path.c
  209. pci-ids.txt
  210. pflib.c
  211. pflib.h
  212. poison.h
  213. posix-aio-compat.c
  214. ppc-dis.c
  215. ppc.ld
  216. ppc64.ld
  217. qapi-schema-guest.json
  218. qapi-schema-test.json
  219. qapi-schema.json
  220. qbool.c
  221. qbool.h
  222. qdict-test-data.txt
  223. qdict.c
  224. qdict.h
  225. qemu-aio.h
  226. qemu-barrier.h
  227. qemu-char.c
  228. qemu-char.h
  229. qemu-common.h
  230. qemu-config.c
  231. qemu-config.h
  232. qemu-coroutine-int.h
  233. qemu-coroutine-lock.c
  234. qemu-coroutine.c
  235. qemu-coroutine.h
  236. qemu-doc.texi
  237. qemu-error.c
  238. qemu-error.h
  239. qemu-ga.c
  240. qemu-img-cmds.hx
  241. qemu-img.c
  242. qemu-img.texi
  243. qemu-io.c
  244. qemu-lock.h
  245. qemu-log.h
  246. qemu-nbd.c
  247. qemu-nbd.texi
  248. qemu-objects.h
  249. qemu-option.c
  250. qemu-option.h
  251. qemu-options-wrapper.h
  252. qemu-options.h
  253. qemu-options.hx
  254. qemu-os-posix.h
  255. qemu-os-win32.h
  256. qemu-progress.c
  257. qemu-queue.h
  258. qemu-sockets.c
  259. qemu-tech.texi
  260. qemu-thread-posix.c
  261. qemu-thread-posix.h
  262. qemu-thread-win32.c
  263. qemu-thread-win32.h
  264. qemu-thread.h
  265. qemu-timer-common.c
  266. qemu-timer.c
  267. qemu-timer.h
  268. qemu-tls.h
  269. qemu-tool.c
  270. qemu-x509.h
  271. qemu-xattr.h
  272. qemu.sasl
  273. qemu_socket.h
  274. qerror.c
  275. qerror.h
  276. qfloat.c
  277. qfloat.h
  278. qint.c
  279. qint.h
  280. qjson.c
  281. qjson.h
  282. qlist.c
  283. qlist.h
  284. qmp-commands.hx
  285. qmp.c
  286. qobject.h
  287. qstring.c
  288. qstring.h
  289. range.h
  290. readline.c
  291. readline.h
  292. README
  293. rules.mak
  294. s390-dis.c
  295. s390.ld
  296. savevm.c
  297. sh4-dis.c
  298. softmmu-semi.h
  299. softmmu_defs.h
  300. softmmu_exec.h
  301. softmmu_header.h
  302. softmmu_template.h
  303. sparc-dis.c
  304. sparc.ld
  305. sparc64.ld
  306. spice-qemu-char.c
  307. sysemu.h
  308. targphys.h
  309. tcg-runtime.c
  310. tci-dis.c
  311. tci.c
  312. test-coroutine.c
  313. test-qmp-commands.c
  314. test-qmp-input-visitor.c
  315. test-qmp-output-visitor.c
  316. thunk.c
  317. thunk.h
  318. TODO
  319. trace-events
  320. translate-all.c
  321. uboot_image.h
  322. usb-bsd.c
  323. usb-linux.c
  324. usb-redir.c
  325. usb-stub.c
  326. user-exec.c
  327. VERSION
  328. version.rc
  329. vgafont.h
  330. vl.c
  331. x86_64.ld
  332. xen-all.c
  333. xen-mapcache.c
  334. xen-mapcache.h
  335. xen-stub.c
  336. xtensa-semi.c