Netdev List
 help / color / mirror / Atom feed
From: Daniel Borkmann via iovisor-dev <iovisor-dev-9jONkmmOlFHEE9lA1F8Ukti2O/JbrIOy@public.gmane.org>
To: Jesper Dangaard Brouer
	<brouer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	iovisor-dev
	<iovisor-dev-9jONkmmOlFHEE9lA1F8Ukti2O/JbrIOy@public.gmane.org>,
	Daniel Borkmann
	<borkmann-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org>
Cc: "netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: bpf_redirect_map not working after tail call
Date: Mon, 4 Jun 2018 14:21:22 +0200	[thread overview]
Message-ID: <45943cf5-07cb-66e2-dce4-9193ee118d6e@iogearbox.net> (raw)
In-Reply-To: <20180604130435.27d29431-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On 06/04/2018 01:04 PM, Jesper Dangaard Brouer via iovisor-dev wrote:
> On Fri, 1 Jun 2018 14:15:58 +0200
> Sebastiano Miano via iovisor-dev <iovisor-dev-9jONkmmOlFHEE9lA1F8Ukti2O/JbrIOy@public.gmane.org> wrote:
> 
>> Dear all,
>>
>> We have noticed that the bpf_redirect_map returns an error when it is
>> called after a tail call.
>> The xdp_redirect_map program (under sample/bpf) works fine, but if we
>> modify it as shown in the following diff, it doesn't work anymore.
>> I have debugged it with the xdp_monitor application and the error
>> returned is EFAULT.
>> Is this a known issue? Am I doing something wrong?
> 
> Argh, this is likely an issue/bug due to the check xdp_map_invalid(),
> that was introduced in commit 7c3001313396 ("bpf: fix ri->map_owner
> pointer on bpf_prog_realloc").
> 
> To Daniel, I don't know how to solve this, could you give some advice?
> 
> 
> 
>  static inline bool xdp_map_invalid(const struct bpf_prog *xdp_prog,
> 				   unsigned long aux)
>  {
> 	return (unsigned long)xdp_prog->aux != aux;
>  }
> 
>  static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
> 			       struct bpf_prog *xdp_prog)
>  {
> 	struct redirect_info *ri = this_cpu_ptr(&redirect_info);
> 	unsigned long map_owner = ri->map_owner;
> 	struct bpf_map *map = ri->map;
> 	u32 index = ri->ifindex;
> 	void *fwd = NULL;
> 	int err;
> 
> 	[...]
> 	if (unlikely(xdp_map_invalid(xdp_prog, map_owner))) {
> 		err = -EFAULT;
> 		map = NULL;
> 		goto err;
> 	}
> 	[...]

Argh, I see the issue. Working on a fix after checking the syzkaller reports.

Thanks for the report!

      parent reply	other threads:[~2018-06-04 12:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <319a775a-4913-1e58-c0dd-f3d6e3f56d9e@polito.it>
     [not found] ` <319a775a-4913-1e58-c0dd-f3d6e3f56d9e-8RLafaVCWuNeoWH0uzbU5w@public.gmane.org>
2018-06-04 11:04   ` bpf_redirect_map not working after tail call Jesper Dangaard Brouer via iovisor-dev
     [not found]     ` <20180604130435.27d29431-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-06-04 12:21       ` Daniel Borkmann via iovisor-dev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45943cf5-07cb-66e2-dce4-9193ee118d6e@iogearbox.net \
    --to=iovisor-dev-9jonkmmolfhee9la1f8ukti2o/jbrioy@public.gmane.org \
    --cc=borkmann-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org \
    --cc=brouer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=daniel-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox