Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: bgp_packet_process_error can access peer after deletion (backport #9328) #9356

Merged
merged 1 commit into from
Aug 13, 2021

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Aug 10, 2021

This is an automatic backport of pull request #9328 done by Mergify.


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.io/

in bgp_io.c upon packet read of some error we are storing
the peer pointer on a thread to call bgp_packet_process_error.
In this case an event is generated that is not guaranteed to be
run immediately.  It could come in *after* the peer data structure
is deleted and as such we now are writing into memory that we
no longer possibly own as a peer data structure.

Modify the code so that the peer can track the thread associated
with the read error and then it can wisely kill that thread
when deleting the peer data structure.

Signed-off-by: Donald Sharp <[email protected]>
(cherry picked from commit 1fae5c8)
Copy link

@polychaeta polychaeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution to FRR!

Click for style suggestions

To apply these suggestions:

curl -s https://gist.githubusercontent.com/polychaeta/60506be1ebabe594ea6425ad67c0e495/raw/5990b0f8b7bb360845195d615b24089d99ad0f17/cr_9356_1628602664.diff | git apply

diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c
index 9b5a31f289..ae79594b0f 100644
--- a/bgpd/bgp_io.c
+++ b/bgpd/bgp_io.c
@@ -208,8 +208,8 @@ static int bgp_process_reads(struct thread *thread)
 		/* Handle the error in the main pthread, include the
 		 * specific state change from 'bgp_read'.
 		 */
-		thread_add_event(bm->master, bgp_packet_process_error,
-				 peer, code, &peer->t_process_packet_error);
+		thread_add_event(bm->master, bgp_packet_process_error, peer,
+				 code, &peer->t_process_packet_error);
 	}
 
 	while (more) {

If you are a new contributor to FRR, please see our contributing guidelines.

After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Aug 10, 2021

🚧 Basic BGPD CI results: Partial FAILURE, autoscript-2021-08-10-13:41:48.log.bz2 tests failed, has VALGRIND issues

Results table
_ _
Result SUCCESS git merge/9356 4e21262
Date 08/10/2021
Start 13:40:33
Finish 14:06:11
Run-Time 25:38
Total 1813
Pass 1813
Fail 0
Details vncregress-2021-08-10-13:40:33.txt
Log autoscript-2021-08-10-13:41:48.log.bz2
Memory 497 493 427

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-20970/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Aug 13, 2021

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/9356 4e21262
Date 08/10/2021
Start 13:40:33
Finish 14:06:11
Run-Time 25:38
Total 1813
Pass 1813
Fail 0
Valgrind-Errors
Valgrind-Loss
Details vncregress-2021-08-10-13:40:33.txt
Log autoscript-2021-08-10-13:41:48.log.bz2
Memory 497 493 427

For details, please contact louberger

@idryzhov idryzhov merged commit e8389e5 into stable/8.0 Aug 13, 2021
@mergify mergify bot deleted the mergify/bp/stable/8.0/pr-9328 branch August 13, 2021 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants