# Re: \[PATCH net-next\] net: Implement fault injection forcing skb reallocation

- From: Breno Leitao \<leitao@debian.org\>
- Date: 2024-10-07 16:20:19 
- List: netdev
- Page: https://ratatoskr.run/netdev/2024/10/2772075
- Thread: https://ratatoskr.run/netdev/2024/10/2765931/t.md

```text
On Sat, Oct 05, 2024 at 01:38:59PM +0900, Akinobu Mita wrote:
> 2024年10月2日(水) 20:37 Breno Leitao [ref]:
> >
> > Introduce a fault injection mechanism to force skb reallocation. The
> > primary goal is to catch bugs related to pointer invalidation after
> > potential skb reallocation.
> >
> > The fault injection mechanism aims to identify scenarios where callers
> > retain pointers to various headers in the skb but fail to reload these
> > pointers after calling a function that may reallocate the data. This
> > type of bug can lead to memory corruption or crashes if the old,
> > now-invalid pointers are used.
> >
> > By forcing reallocation through fault injection, we can stress-test code
> > paths and ensure proper pointer management after potential skb
> > reallocations.
> >
> > Add a hook for fault injection in the following functions:
> >
> >  * pskb_trim_rcsum()
> >  * pskb_may_pull_reason()
> >  * pskb_trim()
> >
> > As the other fault injection mechanism, protect it under a debug Kconfig
> > called CONFIG_FAIL_SKB_FORCE_REALLOC.
> >
> > This patch was *heavily* inspired by Jakub's proposal from:
> > https://lore.kernel.org/all/20240719174140.47a868e6@kernel.org/
> >
> > CC: Akinobu Mita <akinobu.mita@gmail.com>
> > Suggested-by: Jakub Kicinski <kuba@kernel.org>
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> 
> This new addition seems sensible.  It might be more useful to have a filter
> that allows you to specify things like protocol family.

I think it might make more sense to be network interface specific. For
instance, only fault inject in interface `ethx`.

Let me spend some time and have this done.

Thanks for the feedback.
--breno
```
