[flang] [flang-rt] Subscript overrun could occur in namelists during a READ command. - #176959
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
I realized that this is an executable test so it needs to go into llvm-test-suite.
|
I was looking over my open PRs. I realized this one has an executable test associated with it. I will remove that test and put it within the llvm-test-suite. A link to that PR to follow. Otherwise, I'd like to "Ping" this PR, as it's been open for a while. |
|
Here are the test artifacts for this change: check-flang: check-flang-rt: llvm-test-suite: |
|
PR for the new executable test: |
|
Is there an associated issue that demonstrates the buffer overflow? |
|
There was not an opened issue. This was my first fix and I never opened one. It was identified when we ran an internal cray test against flang. If I need to (or you'd just prefer), I will open one. The PR will end up being a description of a core/hanging and the test associated with this PR: llvm/llvm-test-suite#361. Please let me know how I should proceed and I'll be happy to. Thank you for looking. |
You don't strictly, but the title of the PR said "could occur", so I was wondering if there was a test that actually triggered it that others could use to reproduce. Might be worth opening an issue. |
|
I created an issue and added linking comments to this and the llvm-test-suite update: |
|
Ping. I'm not sure who the right reviewer would be. I do see that @klausler touched this code a number of years ago. Thank you for your time. |
| for (; ch && *ch != ')'; ++j) { | ||
|
|
||
| // Read subscripts, but don't exceed rank to prevent buffer overrun. | ||
| for (int Rank = source.rank(); ch && *ch != ')' && j <= Rank; ++j) { |
There was a problem hiding this comment.
The coding style for the modern C++ bits of flang-new always uses braced initialization and lower-case variable names.
There was a problem hiding this comment.
Thank you. I corrected the coding standard issues.
If you are satisfied with the changes, would you please also merge them for me? I don't have write permissions yet.
There was a problem hiding this comment.
Ok, but please apply for them soon!
|
@kwyatt-ext Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
|
@klausler Thank you. Will do. |
NOTE: This is a new pull request, as the prior didn't have labels properly applied.
If a bad subscript is provided in a namelisted record, the HandleSubscripts() routine can read off into infinity. This patch ensures that a read will not go beyond the rank of the expected variable.
The failure will then be captured in the return status (IOSTAT) of the READ.
The small test demonstrates the failure before and after the fix.