public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux•org>
To: Linus Torvalds <torvalds@linux-foundation•org>
Cc: Eugene Syromiatnikov <esyr@redhat•com>,
	netdev@vger•kernel.org, linux-kernel@vger•kernel.org,
	Martin KaFai Lau <kafai@fb•com>,
	Daniel Borkmann <daniel@iogearbox•net>,
	Alexei Starovoitov <ast@kernel•org>,
	"David S. Miller" <davem@davemloft•net>,
	Jiri Olsa <jolsa@kernel•org>, Ingo Molnar <mingo@kernel•org>,
	Lawrence Brakmo <brakmo@fb•com>, Andrey Ignatov <rdna@fb•com>,
	Jakub Kicinski <jakub.kicinski@netronome•com>,
	John Fastabend <john.fastabend@gmail•com>
Subject: Re: [PATCH bpf 1/2] bpf: fix alignment of netns_dev/netns_ino fields in bpf_{map,prog}_info
Date: Fri, 1 Jun 2018 06:12:10 +0300	[thread overview]
Message-ID: <20180601031210.GA30533@altlinux.org> (raw)
In-Reply-To: <20180530181857.GA6744@altlinux.org>

[-- Attachment #1: Type: text/plain, Size: 3127 bytes --]

Hi,

Looks like the ABI bug in bpf_map_info and bpf_prog info introduced
in 4.16 is going to slip into 4.17, causing extra pain to 32-bit
userspace.  I'm adding Linus to this thread in hope it might help
to get a fix applied before 4.17 is released.

On Wed, May 30, 2018 at 09:18:58PM +0300, Dmitry V. Levin wrote:
> On Sun, May 27, 2018 at 01:28:42PM +0200, Eugene Syromiatnikov wrote:
> > Recent introduction of netns_dev/netns_ino to bpf_map_info/bpf_prog info
> > has broken compat, as offsets of these fields are different in 32-bit
> > and 64-bit ABIs.  One fix (other than implementing compat support in
> > syscall in order to handle this discrepancy) is to use __aligned_u64
> > instead of __u64 for these fields.
> > 
> > Reported-by: Dmitry V. Levin <ldv@altlinux•org>
> > Fixes: 52775b33bb507 ("bpf: offload: report device information about
> > offloaded maps")
> > Fixes: 675fc275a3a2d ("bpf: offload: report device information for
> > offloaded programs")
> > 
> > Signed-off-by: Eugene Syromiatnikov <esyr@redhat•com>
> 
> Reviewed-by: "Dmitry V. Levin" <ldv@altlinux•org>
> Cc: <stable@vger•kernel.org> # v4.16+
> 
> Thanks,
> 
> > ---
> >  include/uapi/linux/bpf.h       | 8 ++++----
> >  tools/include/uapi/linux/bpf.h | 8 ++++----
> >  2 files changed, 8 insertions(+), 8 deletions(-)
> > 
> > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> > index c5ec897..903010a 100644
> > --- a/include/uapi/linux/bpf.h
> > +++ b/include/uapi/linux/bpf.h
> > @@ -1017,8 +1017,8 @@ struct bpf_prog_info {
> >  	__aligned_u64 map_ids;
> >  	char name[BPF_OBJ_NAME_LEN];
> >  	__u32 ifindex;
> > -	__u64 netns_dev;
> > -	__u64 netns_ino;
> > +	__aligned_u64 netns_dev;
> > +	__aligned_u64 netns_ino;
> >  } __attribute__((aligned(8)));
> >  
> >  struct bpf_map_info {
> > @@ -1030,8 +1030,8 @@ struct bpf_map_info {
> >  	__u32 map_flags;
> >  	char  name[BPF_OBJ_NAME_LEN];
> >  	__u32 ifindex;
> > -	__u64 netns_dev;
> > -	__u64 netns_ino;
> > +	__aligned_u64 netns_dev;
> > +	__aligned_u64 netns_ino;
> >  } __attribute__((aligned(8)));
> >  
> >  /* User bpf_sock_addr struct to access socket fields and sockaddr struct passed
> > diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> > index c5ec897..903010a 100644
> > --- a/tools/include/uapi/linux/bpf.h
> > +++ b/tools/include/uapi/linux/bpf.h
> > @@ -1017,8 +1017,8 @@ struct bpf_prog_info {
> >  	__aligned_u64 map_ids;
> >  	char name[BPF_OBJ_NAME_LEN];
> >  	__u32 ifindex;
> > -	__u64 netns_dev;
> > -	__u64 netns_ino;
> > +	__aligned_u64 netns_dev;
> > +	__aligned_u64 netns_ino;
> >  } __attribute__((aligned(8)));
> >  
> >  struct bpf_map_info {
> > @@ -1030,8 +1030,8 @@ struct bpf_map_info {
> >  	__u32 map_flags;
> >  	char  name[BPF_OBJ_NAME_LEN];
> >  	__u32 ifindex;
> > -	__u64 netns_dev;
> > -	__u64 netns_ino;
> > +	__aligned_u64 netns_dev;
> > +	__aligned_u64 netns_ino;
> >  } __attribute__((aligned(8)));
> >  
> >  /* User bpf_sock_addr struct to access socket fields and sockaddr struct passed


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2018-06-01  3:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-27 11:28 [PATCH bpf 1/2] bpf: fix alignment of netns_dev/netns_ino fields in bpf_{map,prog}_info Eugene Syromiatnikov
2018-05-29 17:17 ` Song Liu
2018-06-02  3:28   ` Daniel Borkmann
2018-05-30 18:18 ` Dmitry V. Levin
2018-06-01  3:12   ` Dmitry V. Levin [this message]
2018-06-01  8:41     ` Alexei Starovoitov
2018-06-01 11:12       ` Dmitry V. Levin

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=20180601031210.GA30533@altlinux.org \
    --to=ldv@altlinux$(echo .)org \
    --cc=ast@kernel$(echo .)org \
    --cc=brakmo@fb$(echo .)com \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=esyr@redhat$(echo .)com \
    --cc=jakub.kicinski@netronome$(echo .)com \
    --cc=john.fastabend@gmail$(echo .)com \
    --cc=jolsa@kernel$(echo .)org \
    --cc=kafai@fb$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=mingo@kernel$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=rdna@fb$(echo .)com \
    --cc=torvalds@linux-foundation$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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