Merge in SNORT/snort3 from ~KATHARVE/snort3:abort_issues to master
Squashed commit of the following:
commit
3a43d1e4887d820be2886edaa3185a5c8975fa5d
Author: Katura Harvey <katharve@cisco.com>
Date: Mon Nov 15 11:32:41 2021 -0500
http_inspect: update comments for asserts in eval and clear
commit
3ccf3b7e0f9c4b453f56015b52aeb16c1ed747c0
Author: Katura Harvey <katharve@cisco.com>
Date: Mon Nov 15 11:27:37 2021 -0500
stream_tcp: only fallback if stream splitter aborted and don't keep processing fragments after MagicSplitter returned STOP
commit
6731a11f9bf7b5de9c5e348d0f1311dd6a376ba9
Author: Katura Harvey <katharve@cisco.com>
Date: Wed Oct 27 20:05:38 2021 -0400
framework: don't call a gadget's eval() or clear() after its stream splitter aborted
commit
3c60508fca0b13f14f55632b35d1ca84ea134e57
Author: Katura Harvey <katharve@cisco.com>
Date: Mon Nov 15 11:22:41 2021 -0500
http_inspect: fix total_bytes peg count
&& !(ssn_state.session_flags & SSNFLAG_MIDSTREAM));
}
+bool Flow::is_direction_aborted(bool from_client) const
+{
+ const uint32_t session_flags = get_session_flags();
+
+ if (from_client)
+ return (session_flags & SSNFLAG_ABORT_SERVER);
+
+ return (session_flags & SSNFLAG_ABORT_CLIENT);
+}
+
void Flow::set_service(Packet* pkt, const char* new_service)
{
service = new_service;
uint32_t set_session_flags(uint32_t ssn_flags)
{ return ssn_state.session_flags |= ssn_flags; }
- uint32_t get_session_flags()
+ uint32_t get_session_flags() const
{ return ssn_state.session_flags; }
uint32_t clear_session_flags(uint32_t ssn_flags)
bool is_pdu_inorder(uint8_t dir);
+ bool is_direction_aborted(bool from_client) const;
+
void set_proxied()
{ ssn_state.session_flags |= SSNFLAG_PROXIED; }
if ( !(BIT((uint16_t)p->type()) & api->proto_bits) )
return false;
+ if ( p->flow and p->flow->is_direction_aborted(p->is_from_client()) )
+ return false;
+
if ( p->is_tcp() && api->type == IT_SERVICE )
return p->has_paf_payload();
}
// Things that are set prior to PDU creation and used after PDU creation
-static inline uint32_t get_session_flags(Packet& p)
+static inline uint32_t get_session_flags(const Packet& p)
{
if ( p.ptrs.get_pkt_type() == PktType::PDU )
return p.context->get_session_flags();
return;
}
- if (!session_data->for_http2)
- HttpModule::increment_peg_counts(PEG_TOTAL_BYTES, p->dsize);
-
- // FIXIT-M Workaround for unexpected eval() calls. Convert to asserts when possible.
+ // FIXIT-M Workaround for unexpected eval() calls. Currently asserting when stream_user is in
+ // use due to calls to HttpInspect::eval on the raw stream_user packet
if ((session_data->section_type[source_id] == SEC__NOT_COMPUTE) ||
(session_data->type_expected[source_id] == SEC_ABORT) ||
(session_data->octets_reassembled[source_id] != p->dsize))
{
- // assert(session_data->type_expected[source_id] != SEC_ABORT);
- // assert(session_data->section_type[source_id] != SEC__NOT_COMPUTE);
- // assert(session_data->octets_reassembled[source_id] == p->dsize);
+ //assert(session_data->type_expected[source_id] != SEC_ABORT);
+ //assert(session_data->section_type[source_id] != SEC__NOT_COMPUTE);
+ //assert(session_data->octets_reassembled[source_id] == p->dsize);
session_data->type_expected[source_id] = SEC_ABORT;
return;
}
+
+ if (!session_data->for_http2)
+ HttpModule::increment_peg_counts(PEG_TOTAL_BYTES, p->dsize);
+
session_data->octets_reassembled[source_id] = STAT_NOT_PRESENT;
// Don't make pkt_data for headers available to detection
if ( current_section == nullptr )
{
- // assert(false); // FIXIT-M this happens a lot
+ //assert(false); //FIXIT-M This happens with stream_user
return;
}
return flush_pt;
}
- if ( !next_no_gap(*tsn) )
+ if (!next_no_gap(*tsn) || (trs.paf_state.paf == StreamSplitter::STOP))
break;
tsn = tsn->next;
return flush_pt;
}
- if ( flush_len < tsn->c_len || ( splitter->is_paf() and !next_no_gap(*tsn) ) )
+ if (flush_len < tsn->c_len || (splitter->is_paf() and !next_no_gap(*tsn)) ||
+ (trs.paf_state.paf == StreamSplitter::STOP))
break;
tsn = tsn->next;
}
while ( trs.sos.seglist.head and !p->flow->is_inspection_disabled() );
- if ( !flags && trs.tracker->is_splitter_paf() )
+ if ( (trs.paf_state.paf == StreamSplitter::ABORT) && trs.tracker->is_splitter_paf() )
{
fallback(*trs.tracker, trs.server_side);
return flush_on_data_policy(trs, p);