Skip to content

Conversation

@s1awwhy
Copy link

@s1awwhy s1awwhy commented Aug 24, 2025

Solve issue #19471

When the command debug ospf packet all send/recv detail is enabled in the OSPF configuration, ospfd will dump detailed information of any received or sent OSPF packets, either via VTY or through the zlog. However, The original Opaque LSA handling code failed to check whether the VTY context and show_opaque_info were available, resulting in NULL pointer dereference and crashes in ospfd. This patch addresses the issue by adding security checks for the vty and pointers related to Opaque LSAs dumping. If the vty context is unavailable, the patch ensures that the packet details are logged using zlog instead.

Copy link
Member

@Jafaral Jafaral left a comment

Choose a reason for hiding this comment

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

Please refer to this section for more info on how to organize your commits and how to format your commits/PR messages. In particular, please:

  1. Squash all commit with the same title to one commit
  2. Use a short title for the new squashed commit, and copy the description you have for the PR to the commit message. You know your title is too long when it looks like the following (wrapped lines and dots) when you browse the commit on github, example
Fix the Null Pointer Deference Vulnerability in show_vty_ext_link_lan…
…_adj_sid. Add security check for vty_out. Specifically, Check NULL for vty. If vty is not available, dump info via zlog.

Signed-off-by: s1awwhy <seawwhy@163.com>
  1. Fix the commit messages of the other commits to adhere to the guidelines referenced above.
  2. Fix code formatting, see frrbot

Thank you very much for your contributions!

void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa,
json_object *json)
{
{
Copy link
Member

Choose a reason for hiding this comment

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

drop whitespace change

Copy link
Member

Choose a reason for hiding this comment

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

This is clearly not resolved.

ospfd/ospf_ext.c Outdated
zlog_debug(" Wrong %s TLV size: %d(%d). Abort!", msg, ntohs(tlvh->length), size); \
return size + TLV_HDR_SIZE; \
} \
} \
Copy link
Member

Choose a reason for hiding this comment

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

drop whitespace change

json_object_string_addf(json, "remoteInterfaceAddress", "%pI4",
&top->value);

}
Copy link
Member

Choose a reason for hiding this comment

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

drop whitespace change

@s1awwhy s1awwhy changed the title Fix NULL Pointer Deference when dumping opaque lsa. ospfd: Fix NULL Pointer Deference when dumping opaque lsa. Aug 25, 2025
@s1awwhy s1awwhy changed the title ospfd: Fix NULL Pointer Deference when dumping opaque lsa. ospfd: Fix NULL Pointer Deference when dumping opaque lsa Aug 25, 2025
When the command debug ospf packet all send/recv detail is enabled
in the OSPF configuration, ospfd will dump detailed information of
any received or sent OSPF packets, either via VTY or through the zlog.
However, the original show_opaque_info_detail failed to check lsa.data.
The patch adds security check for lsa.data to prevent null pointer
dereferencing in show_opaque_info_detail when parsing the LSA.

Signed-off-by: s1awwhy <seawwhy@163.com>
When the command debug ospf packet all send/recv detail is enabled
in the OSPF configuration,  ospfd will dump detailed information
of any received or sent OSPF packets, either via VTY or through the
zlog. However, the check for functab->show_opaque_info is not valid
in original show_opaque_info_detail.The patch adds proper null check
for functab and functab->show_opaque_info.

Signed-off-by: s1awwhy <seawwhy@163.com>
Add security check for vty_out. Specifically,  Check NULL for vty. If vty is not available, dump info via zlog.

Signed-off-by: s1awwhy <seawwhy@163.com>
@s1awwhy s1awwhy force-pushed the fix_dump_opaque_lsa branch from dc27b83 to 1f17653 Compare August 25, 2025 04:06
@frrbot frrbot bot added the ospf label Aug 25, 2025
When the command debug ospf packet all send/recv detail is enabled in the OSPF
configuration,  ospfd will dump detailed information of any received or sent
OSPF packets, either via VTY or through the zlog. However, the original Opaque
LSA handling code failed to check whether the VTY context and show_opaque_info
were available, resulting in NULL pointer dereference and crashes in ospfd.
The patch fixes the Null Pointer Deference Vulnerability in
show_vty_ext_link_rmt_itf_addr, show_vty_ext_link_adj_sid,
show_vty_ext_link_lan_adj_sid, show_vty_unknown_tlv,
show_vty_link_info, show_vty_ext_pref_pref_sid, show_vtY_pref_info.
Specifically, add NULL check for vty. If vty is not available, dump details
via zlog.

Signed-off-by: s1awwhy <seawwhy@163.com>
@s1awwhy s1awwhy force-pushed the fix_dump_opaque_lsa branch from 1f17653 to fdd9574 Compare August 25, 2025 06:41
@s1awwhy
Copy link
Author

s1awwhy commented Aug 25, 2025

Please refer to this section for more info on how to organize your commits and how to format your commits/PR messages. In particular, please:

  1. Squash all commit with the same title to one commit
  2. Use a short title for the new squashed commit, and copy the description you have for the PR to the commit message. You know your title is too long when it looks like the following (wrapped lines and dots) when you browse the commit on github, example
Fix the Null Pointer Deference Vulnerability in show_vty_ext_link_lan…
…_adj_sid. Add security check for vty_out. Specifically, Check NULL for vty. If vty is not available, dump info via zlog.

Signed-off-by: s1awwhy <seawwhy@163.com>
  1. Fix the commit messages of the other commits to adhere to the guidelines referenced above.
  2. Fix code formatting, see frrbot

Thank you very much for your contributions!

Thank you very much for your guidance! I've revised the commits and code style.

@s1awwhy s1awwhy requested a review from Jafaral August 25, 2025 08:36
Copy link
Contributor

@mjstapp mjstapp left a comment

Choose a reason for hiding this comment

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

wouldn't it be better to fix this in the "opaque" callback mechanism directly? that is, there's a "show" callback that appears to be called in two different paths, and that's a ... problem isn't it?

@louis-6wind
Copy link
Contributor

@s1awwhy Kindly remove the whitespace changes.

@louis-6wind
Copy link
Contributor

@s1awwhy Normally you have to fix the styling of each commit separately. You cannot fix that in the last commit.
Use git rebase --interactive to do so
Revised version of the styling only
https://github.com/louis-6wind/frr/commits/fix_dump_opaque_lsa/

Copy link
Contributor

@louis-6wind louis-6wind left a comment

Choose a reason for hiding this comment

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

please fix out of bounds that you introduce with your patch

if (TLV_SIZE(tlvh) > buf_size) {
vty_out(vty, " TLV size %d exceeds buffer size. Abort!",
TLV_SIZE(tlvh));
return buf_size;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you removing this line ? It seems to be a mistake.

vty_out(vty,
" Extended Link TLV size %d exceeds buffer size. Abort!\n",
length);
return buf_size;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you removing this line ? It seems to be a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants