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

rtrlib/rtr: Ensure shadow tables are only freed when initialized #204

Merged
merged 1 commit into from Dec 14, 2018

Conversation

mroethke
Copy link
Member

@mroethke mroethke commented Dec 7, 2018

This patch ensures the cleanup code can check whether the shadow tables
have been initialized and only frees them if they are.

Fix #202

@mroethke mroethke requested a review from nbars December 7, 2018 13:46
@codecov-io
Copy link

codecov-io commented Dec 7, 2018

Codecov Report

Merging #204 into master will decrease coverage by 0.26%.
The diff coverage is 7.69%.

@@            Coverage Diff            @@
##           master    #204      +/-   ##
=========================================
- Coverage   69.07%   68.8%   -0.27%     
=========================================
  Files          15      15              
  Lines        2231    2247      +16     
=========================================
+ Hits         1541    1546       +5     
- Misses        690     701      +11

@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/RPKI-RTRLIBPR-57/

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.

Warnings Generated during build:

Ubuntu 14.04 amd64: Successful with additional warnings

Debian Package lintian failed for Ubuntu 14.04 amd64:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-57/artifact/UBUNTU1404AMD64/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 16.04 arm8: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 arm8:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-57/artifact/UBUNTU1604ARM8/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 16.04 arm7: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 arm7:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-57/artifact/UBUNTU1604ARM7/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 18.04 amd64: Successful with additional warnings

Debian Package lintian failed for Ubuntu 18.04 amd64:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-57/artifact/U1804AMD64/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
W: rtr-tools-dbg: priority-extra-is-replaced-by-priority-optional
W: librtr-dbg: priority-extra-is-replaced-by-priority-optional
Ubuntu 16.04 amd64: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 amd64:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-57/artifact/UBUNTU1604AMD64/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 16.04 i386: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 i386:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-57/artifact/UBUNTU1604I386/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable

@nbars
Copy link
Member

nbars commented Dec 7, 2018

pfx_shadow_table and spki_shadow_table are still handeled as they where allocated on the stack

/home/nils/git/rtrlib/rtrlib/rtr/packets.c:1197:55: warning: incompatible pointer types passing 'struct pfx_table **' to parameter of type 'struct pfx_table *'; remove & [-Wincompatible-pointer-types]
                pfx_table_swap(rtr_socket->pfx_table, &pfx_shadow_table);
                                                      ^~~~~~~~~~~~~~~~~
/home/nils/git/rtrlib/./rtrlib/pfx/pfx_private.h:36:60: note: passing argument to parameter 'b' here
void pfx_table_swap(struct pfx_table *a, struct pfx_table *b);
                                                           ^
/home/nils/git/rtrlib/rtrlib/rtr/packets.c:1198:57: warning: incompatible pointer types passing 'struct spki_table **' to parameter of type 'struct spki_table *'; remove & [-Wincompatible-pointer-types]
                spki_table_swap(rtr_socket->spki_table, &spki_shadow_table);
                                                        ^~~~~~~~~~~~~~~~~~
/home/nils/git/rtrlib/./rtrlib/spki/spkitable_private.h:144:63: note: passing argument to parameter 'b' here
void spki_table_swap(struct spki_table *a, struct spki_table *b);
                                                              ^
/home/nils/git/rtrlib/rtrlib/rtr/packets.c:1202:66: warning: incompatible pointer types passing 'struct pfx_table **' to parameter of type 'struct pfx_table *'; remove & [-Wincompatible-pointer-types]
                    pfx_table_notify_diff(rtr_socket->pfx_table, &pfx_shadow_table, rtr_socket);
                                                                 ^~~~~~~~~~~~~~~~~
/home/nils/git/rtrlib/./rtrlib/pfx/pfx_private.h:54:75: note: passing argument to parameter 'old_table' here
void pfx_table_notify_diff(struct pfx_table *new_table, struct pfx_table *old_table, const struct rtr_socket *socket);
                                                                          ^
/home/nils/git/rtrlib/rtrlib/rtr/packets.c:1209:68: warning: incompatible pointer types passing 'struct spki_table **' to parameter of type 'struct spki_table *'; remove & [-Wincompatible-pointer-types]
                    spki_table_notify_diff(rtr_socket->spki_table, &spki_shadow_table, rtr_socket);
                                                                   ^~~~~~~~~~~~~~~~~~
/home/nils/git/rtrlib/./rtrlib/spki/spkitable_private.h:137:78: note: passing argument to parameter 'old_table' here
void spki_table_notify_diff(struct spki_table *new_table, struct spki_table *old_table, const struct rtr_socket *socket);

From the Bug report:
> If rtr_receive_pdu returns an error code, the execution flow is
> redirected to the cleanup label. If ->is_resetting is now true (e.g.,
> because it was set by a CACHE_RESPONSE PDU processed by
> rtr_handle_cache_response_pdu), pfx_table_free_without_notify and
> spki_table_free_without_notify are executing multiple operations on this
> uninitialized data.

This patch ensures the cleanup code can check whether the shadow tables
have been initialized and only frees them if they are.
@mroethke
Copy link
Member Author

mroethke commented Dec 7, 2018

That is embarrassing …

Fixed.

@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/RPKI-RTRLIBPR-60/

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.

Warnings Generated during build:

Ubuntu 18.04 amd64: Successful with additional warnings

Debian Package lintian failed for Ubuntu 18.04 amd64:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-60/artifact/U1804AMD64/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
W: librtr-dbg: priority-extra-is-replaced-by-priority-optional
W: rtr-tools-dbg: priority-extra-is-replaced-by-priority-optional
Ubuntu 16.04 arm7: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 arm7:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-60/artifact/UBUNTU1604ARM7/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 14.04 amd64: Successful with additional warnings

Debian Package lintian failed for Ubuntu 14.04 amd64:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-60/artifact/UBUNTU1404AMD64/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 16.04 arm8: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 arm8:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-60/artifact/UBUNTU1604ARM8/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 16.04 amd64: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 amd64:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-60/artifact/UBUNTU1604AMD64/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable
Ubuntu 16.04 i386: Successful with additional warnings

Debian Package lintian failed for Ubuntu 16.04 i386:
(see full package build log at https://ci1.netdef.org/browse/RPKI-RTRLIBPR-60/artifact/UBUNTU1604I386/ErrorLog/log_lintian.txt)

E: librtr0 changes: bad-distribution-in-changes-file stable

Copy link
Member

@nbars nbars left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@waehlisch waehlisch merged commit db2d254 into rtrlib:master Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants