Merge pull request #6 from vadorovsky/buffer-bounds

ebpf: Ensure the bounds of log buffer
Alessandro Decina 3 years ago committed by GitHub
commit edc8395fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
#![no_std] #![no_std]
pub const LOG_BUF_CAPACITY: usize = 1024; pub const LOG_BUF_CAPACITY: usize = 8192;
pub const LOG_FIELDS: usize = 7; pub const LOG_FIELDS: usize = 7;

@ -92,6 +92,9 @@ pub(crate) fn log(args: LogArgs, level: Option<TokenStream>) -> Result<TokenStre
let write_args = quote! {{ let write_args = quote! {{
use ::aya_log_ebpf::WriteToBuf; use ::aya_log_ebpf::WriteToBuf;
Ok::<_, ()>(record_len) #( .and_then(|record_len| { Ok::<_, ()>(record_len) #( .and_then(|record_len| {
if record_len >= buf.buf.len() {
return Err(());
}
{ #formatting_exprs }.write(&mut buf.buf[record_len..]).map(|len| record_len + len) { #formatting_exprs }.write(&mut buf.buf[record_len..]).map(|len| record_len + len)
}) )* }) )*
}}; }};

Loading…
Cancel
Save