net/bpfilter: initialize pos in __bpfilter_process_sockopt
Subsystems (3)
PATCH 1/1 net/bpfilter: initialize pos in __bpfilter_process_sockopt
__bpfilter_process_sockopt never initialized the pos variable passed to the pipe write. This has been mostly harmless in the past as pipes ignore the offset, but the switch to kernel_write no verified the position, which can lead to a failure depending on the exact stack initialization patter. Initialize the variable to zero to make rw_verify_area happy.
--- net/bpfilter/bpfilter_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpfilter/bpfilter_kern.c +1 -1
@@ -39,7 +39,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, {struct mbox_request req;struct mbox_reply reply; -loff_t pos; +loff_t pos =0 ;ssize_t n;int ret = -EFAULT ;
Signature · 1 line
2.27.0
Quoted 3 lines · Christoph Hellwig
__bpfilter_process_sockoptnever initialized the pos variable passed to the pipe write. This has been mostly harmless in the past as pipes ignore the offset, but the switch tokernel_writeno verified the
s/no/now/
Quoted 2 lines
position, which can lead to a failure depending on the exact stack initialization patter. Initialize the variable to zero to make
s/patter/pattern/
Quoted 8 lines
rw_verify_areahappy.Fixes 6955a76fbcd5 ("bpfilter: switch to kernel_write")Reported-by Christian Brauner <[email protected]>Reported-by Rodrigo Madera <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by Rodrigo Madera <[email protected]>---
Thanks for tracking this down, Christoph! This fixes the logging issue for me.
Quoted 19 lines
net/bpfilter/bpfilter_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/bpfilter/bpfilter_kern.c +1
-1@@ -39,7 +39,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, {struct mbox_request req;struct mbox_reply reply; -loff_t pos; +loff_t pos =0 ;ssize_t n;int ret = -EFAULT ;Signature · 1 line
2.27.0
Quoted 21 lines · Christian Brauner
Quoted 3 lines · Christoph Hellwig
__bpfilter_process_sockoptnever initialized the pos variable passed to the pipe write. This has been mostly harmless in the past as pipes ignore the offset, but the switch tokernel_writeno verified thes/no/now/
Quoted 2 lines
position, which can lead to a failure depending on the exact stack initialization patter. Initialize the variable to zero to make
s/patter/pattern/
Quoted 8 lines
rw_verify_areahappy.Fixes 6955a76fbcd5 ("bpfilter: switch to kernel_write")Reported-by Christian Brauner <[email protected]>Reported-by Rodrigo Madera <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by Rodrigo Madera <[email protected]>---
Quoted 4 lines
Thanks for tracking this down, Christoph! This fixes the logging issue for me.
Tested-by Christian Brauner <[email protected]>Reviewed-by Christian Brauner <[email protected]>
Applied to bpf & fixed up the typos in the commit msg, thanks everyone!
Quoted 22 lines · Daniel Borkmann
Quoted 21 lines · Christian Brauner
Quoted 3 lines · Christoph Hellwig
__bpfilter_process_sockoptnever initialized the pos variable passed to the pipe write. This has been mostly harmless in the past as pipes ignore the offset, but the switch tokernel_writeno verified thes/no/now/
Quoted 2 lines
position, which can lead to a failure depending on the exact stack initialization patter. Initialize the variable to zero to make
s/patter/pattern/
Quoted 8 lines
rw_verify_areahappy.Fixes 6955a76fbcd5 ("bpfilter: switch to kernel_write")Reported-by Christian Brauner <[email protected]>Reported-by Rodrigo Madera <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by Rodrigo Madera <[email protected]>---
Quoted 6 lines
Quoted 4 lines
Thanks for tracking this down, Christoph! This fixes the logging issue for me.
Tested-by Christian Brauner <[email protected]>Reviewed-by Christian Brauner <[email protected]>Applied to bpf & fixed up the typos in the commit msg, thanks everyone!
Daniel,
why is it necessary in bpf tree?
I fixed it already in bpf-next in commit a4fa458950b4 ("bpfilter: Initialize pos variable") two weeks ago...
Daniel Borkmann
maintainerQuoted 28 lines · Alexei Starovoitov
Quoted 27 lines · Daniel Borkmann
Quoted 25 lines · Christian Brauner
Quoted 3 lines · Christoph Hellwig
__bpfilter_process_sockoptnever initialized the pos variable passed to the pipe write. This has been mostly harmless in the past as pipes ignore the offset, but the switch tokernel_writeno verified thes/no/now/
Quoted 2 lines
position, which can lead to a failure depending on the exact stack initialization patter. Initialize the variable to zero to make
s/patter/pattern/
Quoted 8 lines
rw_verify_areahappy.Fixes 6955a76fbcd5 ("bpfilter: switch to kernel_write")Reported-by Christian Brauner <[email protected]>Reported-by Rodrigo Madera <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by Rodrigo Madera <[email protected]>---
Thanks for tracking this down, Christoph! This fixes the logging issue for me.
Tested-by Christian Brauner <[email protected]>Reviewed-by Christian Brauner <[email protected]>
Quoted 7 lines
Quoted 1 line
Applied to bpf & fixed up the typos in the commit msg, thanks everyone!
Daniel,
why is it necessary in bpf tree?I fixed it already in bpf-next in commit
a4fa458950b4("bpfilter: Initialize pos variable") two weeks ago...
Several folks reported that with v5.8-rc kernels their console is spammed with 'bpfilter: write fail' messages [0]. Given this affected the 5.8 release and the fix was a one-line change, it felt appropriate to route it there. Why was a4fa458950b4 not pushed into bpf tree given it was affected there too? Either way, we can undo the double pos assignment upon tree sync..
[0] https://lore.kernel.org/lkml/20200727104636.nuz3u4xb7ba7ue5a@wittgenstein/
Quoted 7 lines · Daniel Borkmann
On 8/1/20 9:48 PM, Alexei Starovoitov wrote:
Several folks reported that with v5.8-rc kernels their console is spammed with 'bpfilter: write fail' messages [0]. Given this affected the 5.8 release and the fix was a one-line change, it felt appropriate to route it there. Why was
a4fa458950b4not pushed into bpf tree given it was affected there too? Either way, we can undo the double pos assignment upon tree sync..
Just as a side note, please note it was more than spamming on the console.
It prevented the subsystem from working at all.
Best regards,
Madera