Page MenuHomeFreeBSD

Merge from vendor: fix potential infinite loop in when executing -c command
ClosedPublic

Authored by sobomax on Oct 21 2019, 4:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 1:58 PM
Unknown Object (File)
Mar 15 2024, 1:58 PM
Unknown Object (File)
Mar 10 2024, 7:19 PM
Unknown Object (File)
Mar 10 2024, 7:15 PM
Unknown Object (File)
Mar 10 2024, 7:15 PM
Unknown Object (File)
Mar 10 2024, 7:15 PM
Unknown Object (File)
Mar 10 2024, 7:15 PM
Unknown Object (File)
Mar 7 2024, 9:22 PM
Subscribers

Details

Summary

There is a serious issue in the current tcsh code which causes -c command to go into infinite loop. The original issue was reported here:

https://bugs.astron.com/view.php?id=113

And fixed here:

https://github.com/tcsh-org/tcsh/commit/83c5be028419b3f27c3cc707b88fb21bfa4e1b11

Test Plan
#include <assert.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>

int main(void)
{
  int devnull;

  assert(signal(SIGINT, SIG_IGN) != SIG_ERR);
  devnull = open("/dev/null", O_WRONLY);
  assert(devnull >= 0);
  assert(dup2(devnull, STDOUT_FILENO) >= 0);
  assert(close(devnull) == 0);
  execl("/bin/tcsh", "/bin/tcsh", "-c", "kill -TERM 99999", NULL);

  return (255);
}

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I believe the correct way to handle this is to update the vendor tree and then merge. I'm happy to do that.

Is this only in the new version I imported on the 8th or do we need to MFC as well? If the latter, I suspect it makes sense to direct commit this patch to 12.1 rather than doing a full update this late in the release process.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 21 2019, 9:21 PM
This revision was automatically updated to reflect the committed changes.

I believe the correct way to handle this is to update the vendor tree and then merge. I'm happy to do that.

Is this only in the new version I imported on the 8th or do we need to MFC as well? If the latter, I suspect it makes sense to direct commit this patch to 12.1 rather than doing a full update this late in the release process.

Well, this affects anything since 11.2 at least onwards. I have not tested with 10.x, though. I suspect this specific fix would need to go into all currently supported releases. infinite_loop() implementation in one of two system shells in basic use-case scenario IS BAD, IMHO. You have a test code at hand BTW. :)

-Max

Might need ("partial?") MFC into stable/11 stable/12.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 23 2020, 1:21 AM
Closed by commit rS354191: MFC r353325, r353875 (authored by brooks). · Explain Why
This revision was automatically updated to reflect the committed changes.