Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3620672imm; Tue, 29 May 2018 10:19:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqTI3k1FxbW4YSoFzOutuYRTUgzcUCtYTk5xokTdhvtn005KNaZcjECavhlpcpKpQ3T8Frl X-Received: by 2002:a62:303:: with SMTP id 3-v6mr18128708pfd.255.1527614379097; Tue, 29 May 2018 10:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527614379; cv=none; d=google.com; s=arc-20160816; b=WHQaaV5ZQbLoDRPclsJoIgMvYfiiQ72vpyS1zdiejnjJBwtAMDFE3RHJlJ86udXjiC o+JneIP+AnDCBYa9uvG+mSJ12O9oYpA4DkH7fJ32kcarcbVC546oS+oGSbW7nDjXUyh/ X26f11I2bpF7I5KNHHvZcpKboBIlsNORupIGJKb9ka2h3H/hePWddPxeZWBpd29axLHD 9QO4AglRkBQGL4pA5XPgLtCPyXHDxEA9oNG9aLGzGdA1CAZhE3VpNfjnqztc3F/VyqhB Q2k574By33cIXeIyS2nJCxUncVf97FflGtNKk2LGp0489fg02vknBEauh+H/dfo5Jw1D uIkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=0WWaWz1krJ8iJOjbuy13ddCixXWbmSWt3zldj+4PIX8=; b=VMupsEe/Uoalbj3RPgqDzNi/DtBmcoy6SUJhYI/EGssfJ3jf7jFl1grN7LFzq9poLm 25kAR4zvHJhQ9is6WTRGcNrT6aU6fvwTHoH5uvpG/UT602YLaGWd9fntNp9TjWfGAnsE tf7NYcOnoTWfLHu3+eMl1TKRMSamShwaUPwICKaXX3iwb62geSubraimkPduCVHvNuUu 7G/AL/RxyuXUvOswK/Bi4sXpHgzxDA7jH8GIPjQztbDCzYZEnAGa4wkj6Vw6OSDFLZFz 4+8Tzv0DilrjQInMiabVaqeLDkXbAqrWiPXP68o6rXHerjq3iEqE/7+p+nMHOP20xJ7l xyJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=h+5SNDDw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w23-v6si32900021plq.214.2018.05.29.10.19.24; Tue, 29 May 2018 10:19:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=h+5SNDDw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965361AbeE2RRi (ORCPT + 99 others); Tue, 29 May 2018 13:17:38 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:38644 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965010AbeE2RRf (ORCPT ); Tue, 29 May 2018 13:17:35 -0400 Received: by mail-qt0-f193.google.com with SMTP id x34-v6so6302199qtk.5; Tue, 29 May 2018 10:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0WWaWz1krJ8iJOjbuy13ddCixXWbmSWt3zldj+4PIX8=; b=h+5SNDDwmzzMKfv6kZ17gLFYUtbBbbYIo3fYm1fpXXoKDo87E3aOSHZfmpXOknXhx6 99FlXLLYshCcobm1Tn/DuGeHhUfJa8lWASEeAjIoAsiWvdwpFUGvkR/hRhSuyzmCbz8O UZX0LaaaVsidQgjx/D66wPHpaKHJuxXs26HER3uYlrcr5bcafPlTMphdoxcoqAnnYffD RiUcelQkskRAbYdxrelyBeigsYDJxodE1PeRI4FGd5O/QjE6NxUsm7u+w5UDwDNd6V7/ NPn6kflfX0UvVN7zQTZpusaMRd8WjK9TsPEjCMfiEqYwAXtRMav01XhoHYzD008Jcglh WH1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0WWaWz1krJ8iJOjbuy13ddCixXWbmSWt3zldj+4PIX8=; b=iIYefle9ZeS23C6Ve+2BFuU9+hmCDXhk8SZvocDGJJGjLKY8WzISMb654NgA+HXb6O lLmSfiWlLOn+Ruq7bHNh1rMbqIPBf0NnduDcAuHaH83aLlHYoJS8Qsnl3l61XpcD8K28 wFRxsK0zGgCCDCRAbVj+ivMiYVLZyf7XEQLAuI3hxRVvf5dvFMcf/aqLZRaAazFtQcUQ xVHBA4Dr4UYcxqDnLMh3wbLij5Dn4kWnV4DqCUUp3AR29vNZIqh6z4+yyyMPTZKSbnM4 YGao6hTFezqf7lWoXmBsA6tVR/RuIVX1f4OtPr4+FTYBqhSTA6jX12mbeqERvREBUC/9 AN1w== X-Gm-Message-State: ALKqPwem60oM4TiXjScGYbA8WPlQGKFoOumFlqti/0IqBw1KMgFQeF81 DgrfSBHjPk2akCK7O+w9mF6mvOXzPRViIK39qy8= X-Received: by 2002:ac8:22c9:: with SMTP id g9-v6mr7563708qta.53.1527614255095; Tue, 29 May 2018 10:17:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:9e10:0:0:0:0:0 with HTTP; Tue, 29 May 2018 10:17:34 -0700 (PDT) In-Reply-To: <20180527112842.GA18204@asgard.redhat.com> References: <20180527112842.GA18204@asgard.redhat.com> From: Song Liu Date: Tue, 29 May 2018 10:17:34 -0700 Message-ID: Subject: Re: [PATCH bpf 1/2] bpf: fix alignment of netns_dev/netns_ino fields in bpf_{map,prog}_info To: Eugene Syromiatnikov Cc: netdev@vger.kernel.org, open list , Martin KaFai Lau , Daniel Borkmann , Alexei Starovoitov , "David S. Miller" , Jiri Olsa , Ingo Molnar , Lawrence Brakmo , Andrey Ignatov , Jakub Kicinski , John Fastabend , "Dmitry V. Levin" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 27, 2018 at 4:28 AM, 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 > 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 > --- > 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))); Shall we add a __u32 padding variable before netns_dev? We can use it for in the future. Thanks, Song > > 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 > -- > 2.1.4 >