Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1022387ybj; Fri, 20 Sep 2019 03:57:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxR6J0hv0mVLJPKI5jLLrbxo+hLFrhv9i8B7w0JPvsDf/esGhHakHyj5131VlSisO4C9zD7 X-Received: by 2002:a17:906:1ed6:: with SMTP id m22mr7136417ejj.135.1568977020004; Fri, 20 Sep 2019 03:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568977019; cv=none; d=google.com; s=arc-20160816; b=gkZFShzlKBc7W+TpLNHF7P01/dJXfvbVxkiY9sxiyRGBDM/71JYcP86uM0/YdV+Vqd Xa0aWD3WQmgq10btxLRL6EF51/JAcEi6AMe7ujo4xnNOs5Cdiulc0iNfVcdGZJYt+CcZ BIrqwqInIRDMIT1pcZTovc68vnNS/h6wXxriqXnlwtPfVWUAt+sTmnOwIKnumDBnvJlY 34AB7fqB+HixXDHM1CjneUU+J8UPftnxtHszwYuiwShNssXZ7qHJRi8Dkt0M5hvN0YdS giIAuZVV+jhO3bTnDM+sPjmGfRNMVzgHH3CTv2oQKZPbvsMfljQj7UgBhUYcgPP0ph8v dK5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PmIfcSzxUJDhYAPKMv87vFSmmaP425syUKcWR0fwLW4=; b=HUAkJzqC25g7pPkNGWEgMQ/yhM6s8nyP3dNTBgsC+q0so4NAJaavIwJKh2hn7gffky 4HEw91/vux3Ng6Lxsfib8j2+QtQU/NJ2aX9yRMblkkDyB/NFADDIr2/RBcaE8XB226M0 SQgt0HOadqS5YqfTESyDyZQn8zC9SCApt9KO7S5rcQx/waZ7qyl6iIz3iwE5Ie8tjeDt FIhSaN+A/0hHzZ/Ha/12HgGV8E0flcF/arpaZZyNUcCVO0Llp7dS8cbTap7acUSKk3LD co5EDWHzSEEOUxhzodOf6D3d677g0UvwQAYDTYpc2dMWwJxHOvFpcnCZJx3Xhww87too bQbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ll/URLjw"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ch26si842147ejb.190.2019.09.20.03.56.37; Fri, 20 Sep 2019 03:56:59 -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=@kernel.org header.s=default header.b="Ll/URLjw"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406050AbfISWNW (ORCPT + 99 others); Thu, 19 Sep 2019 18:13:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:52296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393731AbfISWNN (ORCPT ); Thu, 19 Sep 2019 18:13:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D99D21924; Thu, 19 Sep 2019 22:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931192; bh=f37VyrfJ+6B8a1BBEwyKuj1RitCm1kFr2ZZwpsJCCW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ll/URLjw4blxByFShrC4qYkdsrq92B0NJvcZKgKtE87YGBrUoxBCsufHjwmnHKlqX XHa4ZbKRGYrpIHq/0zet0Ks5khfOP1r4EwerRadUmNHCGOHuGKYMW8rQBIL65h2LUA O+W7WuQTzCL6sAnHggbnleHtVw8cXsIK0vkk91tw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juliana Rodrigueiro , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.19 35/79] netfilter: xt_nfacct: Fix alignment mismatch in xt_nfacct_match_info Date: Fri, 20 Sep 2019 00:03:20 +0200 Message-Id: <20190919214810.818333331@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214807.612593061@linuxfoundation.org> References: <20190919214807.612593061@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juliana Rodrigueiro [ Upstream commit 89a26cd4b501e9511d3cd3d22327fc76a75a38b3 ] When running a 64-bit kernel with a 32-bit iptables binary, the size of the xt_nfacct_match_info struct diverges. kernel: sizeof(struct xt_nfacct_match_info) : 40 iptables: sizeof(struct xt_nfacct_match_info)) : 36 Trying to append nfacct related rules results in an unhelpful message. Although it is suggested to look for more information in dmesg, nothing can be found there. # iptables -A -m nfacct --nfacct-name iptables: Invalid argument. Run `dmesg' for more information. This patch fixes the memory misalignment by enforcing 8-byte alignment within the struct's first revision. This solution is often used in many other uapi netfilter headers. Signed-off-by: Juliana Rodrigueiro Acked-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/uapi/linux/netfilter/xt_nfacct.h | 5 ++++ net/netfilter/xt_nfacct.c | 36 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/include/uapi/linux/netfilter/xt_nfacct.h b/include/uapi/linux/netfilter/xt_nfacct.h index 5c8a4d760ee34..b5123ab8d54a8 100644 --- a/include/uapi/linux/netfilter/xt_nfacct.h +++ b/include/uapi/linux/netfilter/xt_nfacct.h @@ -11,4 +11,9 @@ struct xt_nfacct_match_info { struct nf_acct *nfacct; }; +struct xt_nfacct_match_info_v1 { + char name[NFACCT_NAME_MAX]; + struct nf_acct *nfacct __attribute__((aligned(8))); +}; + #endif /* _XT_NFACCT_MATCH_H */ diff --git a/net/netfilter/xt_nfacct.c b/net/netfilter/xt_nfacct.c index 6b56f4170860c..3241fee9f2a19 100644 --- a/net/netfilter/xt_nfacct.c +++ b/net/netfilter/xt_nfacct.c @@ -57,25 +57,39 @@ nfacct_mt_destroy(const struct xt_mtdtor_param *par) nfnl_acct_put(info->nfacct); } -static struct xt_match nfacct_mt_reg __read_mostly = { - .name = "nfacct", - .family = NFPROTO_UNSPEC, - .checkentry = nfacct_mt_checkentry, - .match = nfacct_mt, - .destroy = nfacct_mt_destroy, - .matchsize = sizeof(struct xt_nfacct_match_info), - .usersize = offsetof(struct xt_nfacct_match_info, nfacct), - .me = THIS_MODULE, +static struct xt_match nfacct_mt_reg[] __read_mostly = { + { + .name = "nfacct", + .revision = 0, + .family = NFPROTO_UNSPEC, + .checkentry = nfacct_mt_checkentry, + .match = nfacct_mt, + .destroy = nfacct_mt_destroy, + .matchsize = sizeof(struct xt_nfacct_match_info), + .usersize = offsetof(struct xt_nfacct_match_info, nfacct), + .me = THIS_MODULE, + }, + { + .name = "nfacct", + .revision = 1, + .family = NFPROTO_UNSPEC, + .checkentry = nfacct_mt_checkentry, + .match = nfacct_mt, + .destroy = nfacct_mt_destroy, + .matchsize = sizeof(struct xt_nfacct_match_info_v1), + .usersize = offsetof(struct xt_nfacct_match_info_v1, nfacct), + .me = THIS_MODULE, + }, }; static int __init nfacct_mt_init(void) { - return xt_register_match(&nfacct_mt_reg); + return xt_register_matches(nfacct_mt_reg, ARRAY_SIZE(nfacct_mt_reg)); } static void __exit nfacct_mt_exit(void) { - xt_unregister_match(&nfacct_mt_reg); + xt_unregister_matches(nfacct_mt_reg, ARRAY_SIZE(nfacct_mt_reg)); } module_init(nfacct_mt_init); -- 2.20.1