Merge branch '2.9' into master - #4427
Conversation
…-path backport: hm2_modbus: Fix doc about absolute path
….9.8 chore: backport of PR LinuxCNC#4160
tool_mmap_creator() opens the file O_RDWR|O_CREAT|O_TRUNC
(tooldata_mmap.cc:33, used at :135) and sai calls it at driver.cc:570 --
before getopt() at :578. Every rs274 invocation therefore empties
$HOME/.tool.mmap, including `rs274 --help` and including one that supplies
-t, since -t is not read until :583.
That file is not scratch space: tool_mmap_fname() builds it from
secure_getenv("HOME") with a fixed name, and io, milltask, halui and the
Python bindings all map that same inode MAP_SHARED. An offline parse run
beside a live session therefore replaces the running machine's tool table
with the compiled-in sample table. O_TRUNC preserves the inode, so nothing
re-maps and nothing is notified: the session simply observes its tools
change. Observed on a machine using [EMCIO]DB_PROGRAM -- 15 tools became the
4 sample entries mid-session, G43 applied 0.0000 for a tool that was no
longer in the table, and the tool-number/drawbar guard inhibited jog and
feed. DB_PROGRAM neither prevents nor repairs it: ioControl.cc creates the
mmap before the DB_ACTIVE branch, and io does not re-read afterwards.
Give sai its own file and unlink it on exit. tool_mmap_close() already
unlinks and tool_mmap_fname() already honours a preset filename -- this only
adds the setter to reach it. io and milltask are untouched and remain the
only creators of the shared file.
Two points from review, both addressed here:
mkstemp(), not a name built from the pid (grandixximo). TMPDIR is
world-writable and a pid is guessable, and the creator opens without O_EXCL
or O_NOFOLLOW, so a predictable name can be pre-created as a symlink and the
victim's rs274 then truncates the attacker's chosen file -- and an attacker
can blanket a pid range in advance. mkstemp() creates it atomically with
O_EXCL and mode 0600, and TOOL_MMAP_CREATOR_OPEN_FLAGS gains O_NOFOLLOW so
the creator refuses a symlink at that path even if one appears in the gap.
tool_mmap_close() is now safe as an atexit handler (BsAtHome). It called
exit(EXIT_FAILURE) when munmap failed, and calling exit() from within an
atexit handler is undefined behaviour; _exit would skip the remaining
handlers, so that is not the answer either. It now reports the failure,
closes the fd and returns.
Reproduce before the change:
rm -rf /tmp/rsx && mkdir -p /tmp/rsx
HOME=/tmp/rsx rs274 -g /dev/null
# /tmp/rsx/.tool.mmap, last_index=4, holding
# T1 z0.511 d0.125 / T2 z0.100 d0.0625 / T3 z1.273 d0.201 / T99999 P123
After: rs274 writes $TMPDIR/rs274.tool.mmap.XXXXXX, removes it on exit, and
does not open $HOME/.tool.mmap. Verified on a live machine: an rs274 run with
the real $HOME left last_index=15 and every tool untouched.
Backport of the master deprecation with status adjusted for 2.9, per the PR LinuxCNC#4386 and LinuxCNC#4396 review discussions: mesa_modbus is superseded by the hm2_modbus driver and mesambccc-compiled MBCCB files. It remains available throughout the 2.9 series, while new configurations are encouraged to migrate. Only build-time and documentation notes in 2.9, no load-time warning: the driver is still fully supported in this series, so a nudge at modcompile time is enough. Add a stderr note to modcompile and notes in the README, the mesa_modbus driver doc, the modcompile man page and the docs index.
…te-2.9 mesa_modbus: mark as superseded by hm2_modbus (2.9 backport)
BsAtHome, review 2026-08-18: `(char*)0` is a hand-written null pointer. Both occurrences in tooldata_mmap.cc now use nullptr. No behaviour change.
Signed-off-by: Alec Ari <neotheuser@ymail.com>
Suggested-by: Luca Toniolo <luca@aitalmac.com> Signed-off-by: Alec Ari <neotheuser@ymail.com>
Drop the need for exporting TCLLIBPATH, use system path
Fix python site-packages dir
sai: give rs274 its own tool mmap instead of truncating $HOME/.tool.mmap
Carries LinuxCNC#4385 (rs274 private tool mmap) and the improved SITEPY detection from LinuxCNC#4413. Everything else on 2.9 was already in master.
|
This should be squashed, I guess. Or at least squashed when merged. |
|
Squash works content-wise, but it drops the ancestry link. With a real merge, 2.9's tip becomes a common ancestor and the next 2.9=>master merge-up only brings new commits. With a squash, git never learns these 2.9 commits were integrated, so the same conflicts (mesa_modbus wording, the #4160 backport overlaps, the SITEPY line) resurface on every future merge-up and need manual resolution again. No need to mandate one flow for everything: individual fixes can keep going master-first with backports as before. But when we do use a 2.9=>master merge-up like this one, it only works without squashing. The merge commit is what makes the flow repeatable. |
|
Right, no more comments then. |

Merge 2.9 into master. Net new content:
$HOME/.tool.mmapget_default_scheme()fallback is wrong for Debian pythons withoutdeb_system)Everything else on 2.9 was already in master (NTULINUX TCLLIBPATH fix 78da77a, #4160 backport #4161, hm2_modbus doc fix #4380, mesa_modbus deprecation #4396), so conflicts there were resolved keeping master's side.
tooldata_mmap.ccwas resolved manually keeping master's NULL style.Full RIP build and configure verified.