[PATCH v4 00/11] OCaml fixes

Edwin Török posted 11 patches 1 year, 4 months ago
Failed in applying to current master (apply log)
.editorconfig                                 |   20 +
tools/ocaml/.clang-format                     |    9 +
tools/ocaml/Makefile                          |    5 +
tools/ocaml/libs/eventchn/xeneventchn_stubs.c |  194 +-
tools/ocaml/libs/mmap/mmap_stubs.h            |    8 +-
tools/ocaml/libs/mmap/xenmmap.ml              |    2 +-
tools/ocaml/libs/mmap/xenmmap.mli             |    4 +-
tools/ocaml/libs/mmap/xenmmap_stubs.c         |  123 +-
tools/ocaml/libs/xb/op.ml                     |   76 +-
tools/ocaml/libs/xb/packet.ml                 |   30 +-
tools/ocaml/libs/xb/partial.ml                |   48 +-
tools/ocaml/libs/xb/xb.ml                     |  416 ++--
tools/ocaml/libs/xb/xb.mli                    |  106 +-
tools/ocaml/libs/xb/xenbus_stubs.c            |   50 +-
tools/ocaml/libs/xb/xs_ring.ml                |   31 +-
tools/ocaml/libs/xb/xs_ring_stubs.c           |  221 +-
tools/ocaml/libs/xc/xenctrl.ml                |  326 +--
tools/ocaml/libs/xc/xenctrl.mli               |   12 +-
tools/ocaml/libs/xc/xenctrl_stubs.c           | 1556 ++++++-------
tools/ocaml/libs/xentoollog/caml_xentoollog.h |    6 +-
.../ocaml/libs/xentoollog/xentoollog_stubs.c  |  196 +-
tools/ocaml/libs/xl/xenlight_stubs.c          | 2022 ++++++++---------
tools/ocaml/libs/xs/queueop.ml                |   48 +-
tools/ocaml/libs/xs/xs.ml                     |  220 +-
tools/ocaml/libs/xs/xs.mli                    |   46 +-
tools/ocaml/libs/xs/xsraw.ml                  |  300 +--
tools/ocaml/libs/xs/xst.ml                    |   76 +-
tools/ocaml/libs/xs/xst.mli                   |   20 +-
tools/ocaml/test/dmesg.ml                     |   26 +-
tools/ocaml/test/list_domains.ml              |    4 +-
tools/ocaml/test/raise_exception.ml           |    4 +-
tools/ocaml/test/xtl.ml                       |   28 +-
tools/ocaml/xenstored/Makefile                |    6 +-
tools/ocaml/xenstored/config.ml               |  156 +-
tools/ocaml/xenstored/connection.ml           |  578 ++---
tools/ocaml/xenstored/connections.ml          |  294 +--
tools/ocaml/xenstored/disk.ml                 |  218 +-
tools/ocaml/xenstored/domain.ml               |  116 +-
tools/ocaml/xenstored/domains.ml              |  298 +--
tools/ocaml/xenstored/event.ml                |   28 +-
tools/ocaml/xenstored/history.ml              |   62 +-
tools/ocaml/xenstored/logging.ml              |  478 ++--
tools/ocaml/xenstored/packet.ml               |   20 +-
tools/ocaml/xenstored/parse_arg.ml            |  132 +-
tools/ocaml/xenstored/perms.ml                |  216 +-
tools/ocaml/xenstored/poll.ml                 |   68 +-
tools/ocaml/xenstored/poll.mli                |    4 +-
tools/ocaml/xenstored/process.ml              | 1210 +++++-----
tools/ocaml/xenstored/quota.ml                |   74 +-
tools/ocaml/xenstored/select_stubs.c          |   62 +-
tools/ocaml/xenstored/stdext.ml               |  190 +-
tools/ocaml/xenstored/store.ml                |  752 +++---
tools/ocaml/xenstored/symbol.ml               |    2 +-
tools/ocaml/xenstored/syslog.ml               |   48 +-
tools/ocaml/xenstored/syslog_stubs.c          |   68 +-
tools/ocaml/xenstored/systemd_stubs.c         |   10 +-
tools/ocaml/xenstored/transaction.ml          |  352 +--
tools/ocaml/xenstored/trie.ml                 |  222 +-
tools/ocaml/xenstored/trie.mli                |   22 +-
tools/ocaml/xenstored/utils.ml                |  146 +-
tools/ocaml/xenstored/xenstored.ml            |  987 ++++----
61 files changed, 6569 insertions(+), 6483 deletions(-)
create mode 100644 .editorconfig
create mode 100644 tools/ocaml/.clang-format
[PATCH v4 00/11] OCaml fixes
Posted by Edwin Török 1 year, 4 months ago
From: Edwin Török <edwin.torok@cloud.com>

Various OCaml fixes, some of which got Acked already.

Note: the Data_abstract_val got Acked but not yet commited because we thought
there might be a better way with finalizers/etc.
It is not possible to use finalizers here but there is a new followup patch in
this series that detects use-after-free and raises an exception without
trigerring undefined behaviour or crashes (see 'xb: check for unmapped ring').

The formatting patch was controversial during the 4.17 freeze, but master is
open now, and both the maintainer and myself agree with it,
so I think we should be able to do it now.
I've split it up into 2: add the formatting rules, and the actual formatting,
so that it is easier to redo the formatting patch when this gets backported.

I think we should just commit it rather than worry that there might be more
bugfixes to come after and attempt to rebase the bugfixes without the
formatting patch (introducing bugs in the process), especially that one of the
patches not yet posted to fix use of enter/leave changes quite a significant
part of all C stubs, and I don't have a way of developing those patches without
the formatting patch.

The rest are various bugfixes to the C bindings, and I have more to send
after I've tested them
(almost all uses of enter/leave blocking section are
wrong because they access OCaml values in non-safe ways with _H,
but the GC may have already moved them which would cause a crash,
that changes a lot of bindings and needs more testing before sending out,
and I've got a few more OCaml 5 fixes too).

Edwin Török (11):
  tools/ocaml/libs/{xb, mmap}: use Data_abstract_val wrapper
  tools/ocaml/xenstored/Makefile: use ocamldep -sort for linking order
  CODING_STYLE(tools/ocaml): add 'make format' and remove tabs
  tools/ocaml: run "make format"
  CODING-STYLE(tools/ocaml): add .editorconfig to clarify indentation
    uses spaces
  tools/ocaml: add .clang-format
  fixup! tools/ocaml/xenctrl: OCaml 5 support, fix use-after-free
  tools/ocaml/libs/mmap: mark mmap/munmap as blocking and raise
    Unix_error on failure
  tools/ocaml/libs/xb: check for unmapped ring before accessing it
  tools/ocaml/xenstored: validate config file before live update
  tools/ocaml/libs/xb: drop Xs_ring.write

 .editorconfig                                 |   20 +
 tools/ocaml/.clang-format                     |    9 +
 tools/ocaml/Makefile                          |    5 +
 tools/ocaml/libs/eventchn/xeneventchn_stubs.c |  194 +-
 tools/ocaml/libs/mmap/mmap_stubs.h            |    8 +-
 tools/ocaml/libs/mmap/xenmmap.ml              |    2 +-
 tools/ocaml/libs/mmap/xenmmap.mli             |    4 +-
 tools/ocaml/libs/mmap/xenmmap_stubs.c         |  123 +-
 tools/ocaml/libs/xb/op.ml                     |   76 +-
 tools/ocaml/libs/xb/packet.ml                 |   30 +-
 tools/ocaml/libs/xb/partial.ml                |   48 +-
 tools/ocaml/libs/xb/xb.ml                     |  416 ++--
 tools/ocaml/libs/xb/xb.mli                    |  106 +-
 tools/ocaml/libs/xb/xenbus_stubs.c            |   50 +-
 tools/ocaml/libs/xb/xs_ring.ml                |   31 +-
 tools/ocaml/libs/xb/xs_ring_stubs.c           |  221 +-
 tools/ocaml/libs/xc/xenctrl.ml                |  326 +--
 tools/ocaml/libs/xc/xenctrl.mli               |   12 +-
 tools/ocaml/libs/xc/xenctrl_stubs.c           | 1556 ++++++-------
 tools/ocaml/libs/xentoollog/caml_xentoollog.h |    6 +-
 .../ocaml/libs/xentoollog/xentoollog_stubs.c  |  196 +-
 tools/ocaml/libs/xl/xenlight_stubs.c          | 2022 ++++++++---------
 tools/ocaml/libs/xs/queueop.ml                |   48 +-
 tools/ocaml/libs/xs/xs.ml                     |  220 +-
 tools/ocaml/libs/xs/xs.mli                    |   46 +-
 tools/ocaml/libs/xs/xsraw.ml                  |  300 +--
 tools/ocaml/libs/xs/xst.ml                    |   76 +-
 tools/ocaml/libs/xs/xst.mli                   |   20 +-
 tools/ocaml/test/dmesg.ml                     |   26 +-
 tools/ocaml/test/list_domains.ml              |    4 +-
 tools/ocaml/test/raise_exception.ml           |    4 +-
 tools/ocaml/test/xtl.ml                       |   28 +-
 tools/ocaml/xenstored/Makefile                |    6 +-
 tools/ocaml/xenstored/config.ml               |  156 +-
 tools/ocaml/xenstored/connection.ml           |  578 ++---
 tools/ocaml/xenstored/connections.ml          |  294 +--
 tools/ocaml/xenstored/disk.ml                 |  218 +-
 tools/ocaml/xenstored/domain.ml               |  116 +-
 tools/ocaml/xenstored/domains.ml              |  298 +--
 tools/ocaml/xenstored/event.ml                |   28 +-
 tools/ocaml/xenstored/history.ml              |   62 +-
 tools/ocaml/xenstored/logging.ml              |  478 ++--
 tools/ocaml/xenstored/packet.ml               |   20 +-
 tools/ocaml/xenstored/parse_arg.ml            |  132 +-
 tools/ocaml/xenstored/perms.ml                |  216 +-
 tools/ocaml/xenstored/poll.ml                 |   68 +-
 tools/ocaml/xenstored/poll.mli                |    4 +-
 tools/ocaml/xenstored/process.ml              | 1210 +++++-----
 tools/ocaml/xenstored/quota.ml                |   74 +-
 tools/ocaml/xenstored/select_stubs.c          |   62 +-
 tools/ocaml/xenstored/stdext.ml               |  190 +-
 tools/ocaml/xenstored/store.ml                |  752 +++---
 tools/ocaml/xenstored/symbol.ml               |    2 +-
 tools/ocaml/xenstored/syslog.ml               |   48 +-
 tools/ocaml/xenstored/syslog_stubs.c          |   68 +-
 tools/ocaml/xenstored/systemd_stubs.c         |   10 +-
 tools/ocaml/xenstored/transaction.ml          |  352 +--
 tools/ocaml/xenstored/trie.ml                 |  222 +-
 tools/ocaml/xenstored/trie.mli                |   22 +-
 tools/ocaml/xenstored/utils.ml                |  146 +-
 tools/ocaml/xenstored/xenstored.ml            |  987 ++++----
 61 files changed, 6569 insertions(+), 6483 deletions(-)
 create mode 100644 .editorconfig
 create mode 100644 tools/ocaml/.clang-format

--
2.34.1


Re: [PATCH v4 00/11] OCaml fixes
Posted by Christian Lindig 1 year, 4 months ago

> On 16 Dec 2022, at 18:25, Edwin Török <edvin.torok@citrix.com> wrote:
> 
> From: Edwin Török <edwin.torok@cloud.com>
> 
> Various OCaml fixes, some of which got Acked already.
> 
> Edwin Török (11):
>  tools/ocaml/libs/{xb, mmap}: use Data_abstract_val wrapper
>  tools/ocaml/xenstored/Makefile: use ocamldep -sort for linking order
>  CODING_STYLE(tools/ocaml): add 'make format' and remove tabs
>  tools/ocaml: run "make format"
>  CODING-STYLE(tools/ocaml): add .editorconfig to clarify indentation
>    uses spaces
>  tools/ocaml: add .clang-format
>  fixup! tools/ocaml/xenctrl: OCaml 5 support, fix use-after-free
>  tools/ocaml/libs/mmap: mark mmap/munmap as blocking and raise
>    Unix_error on failure
>  tools/ocaml/libs/xb: check for unmapped ring before accessing it
>  tools/ocaml/xenstored: validate config file before live update
>  tools/ocaml/libs/xb: drop Xs_ring.write

I’m going to Ack this whole sale and provide individual comments. 

Acked-by: Christian Lindig <christian.lindig@citrix.com>