linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Juliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>,
	Florian Westphal <fw@strlen.de>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Sasha Levin <sashal@kernel.org>
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	[thread overview]
Message-ID: <20190919214810.818333331@linuxfoundation.org> (raw)
In-Reply-To: <20190919214807.612593061@linuxfoundation.org>

From: Juliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>

[ 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 <chain> -m nfacct --nfacct-name <acct-object>
    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 <juliana.rodrigueiro@intra2net.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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




  parent reply	other threads:[~2019-09-19 22:13 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 22:02 [PATCH 4.19 00/79] 4.19.75-stable review Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 01/79] netfilter: nf_flow_table: set default timeout after successful insertion Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 02/79] HID: wacom: generic: read HID_DG_CONTACTMAX from any feature report Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 03/79] RDMA/restrack: Release task struct which was hold by CM_ID object Greg Kroah-Hartman
2019-09-21 20:22   ` Pavel Machek
2019-09-22  8:30     ` Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 04/79] Input: elan_i2c - remove Lenovo Legion Y7000 PnpID Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 05/79] powerpc/mm/radix: Use the right page size for vmemmap mapping Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 06/79] USB: usbcore: Fix slab-out-of-bounds bug during device reset Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 07/79] media: tm6000: double free if usb disconnect while streaming Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 08/79] phy: renesas: rcar-gen3-usb2: Disable clearing VBUS in over-current Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 09/79] ip6_gre: fix a dst leak in ip6erspan_tunnel_xmit Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 10/79] udp: correct reuseport selection with connected sockets Greg Kroah-Hartman
2019-09-21 20:32   ` Pavel Machek
2019-09-19 22:02 ` [PATCH 4.19 11/79] xen-netfront: do not assume sk_buff_head list is empty in error handling Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 12/79] net_sched: let qdisc_put() accept NULL pointer Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 13/79] KVM: coalesced_mmio: add bounds checking Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 14/79] firmware: google: check if size is valid when decoding VPD data Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 15/79] serial: sprd: correct the wrong sequence of arguments Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 16/79] tty/serial: atmel: reschedule TX after RX was started Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 17/79] mwifiex: Fix three heap overflow at parsing element in cfg80211_ap_settings Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 18/79] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds Greg Kroah-Hartman
2019-09-20 11:28   ` Pavel Machek
2019-09-19 22:03 ` [PATCH 4.19 19/79] ieee802154: hwsim: Fix error handle path in hwsim_init_module Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 20/79] ieee802154: hwsim: unregister hw while hwsim_subscribe_all_others fails Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 21/79] ARM: dts: am57xx: Disable voltage switching for SD card Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 22/79] ARM: OMAP2+: Fix missing SYSC_HAS_RESET_STATUS for dra7 epwmss Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 23/79] bus: ti-sysc: Fix using configured sysc mask value Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 24/79] s390/bpf: fix lcgr instruction encoding Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 25/79] ARM: OMAP2+: Fix omap4 errata warning on other SoCs Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 26/79] ARM: dts: dra74x: Fix iodelay configuration for mmc3 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 27/79] ARM: OMAP1: ams-delta-fiq: Fix missing irq_ack Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 28/79] bus: ti-sysc: Simplify cleanup upon failures in sysc_probe() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 29/79] s390/bpf: use 32-bit index for tail calls Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 30/79] selftests/bpf: fix "bind{4, 6} deny specific IP & port" on s390 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 31/79] tools: bpftool: close prog FD before exit on showing a single program Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 32/79] fpga: altera-ps-spi: Fix getting of optional confd gpio Greg Kroah-Hartman
2019-09-21 20:46   ` Pavel Machek
2019-09-23  1:33     ` Phil Reid
2019-09-19 22:03 ` [PATCH 4.19 33/79] netfilter: ebtables: Fix argument order to ADD_COUNTER Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 34/79] netfilter: nft_flow_offload: missing netlink attribute policy Greg Kroah-Hartman
2019-09-19 22:03 ` Greg Kroah-Hartman [this message]
2019-09-19 22:03 ` [PATCH 4.19 36/79] NFSv4: Fix return values for nfs4_file_open() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 37/79] NFSv4: Fix return value in nfs_finish_open() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 38/79] NFS: Fix initialisation of I/O result struct in nfs_pgio_rpcsetup Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 39/79] Kconfig: Fix the reference to the IDT77105 Phy driver in the description of ATM_NICSTAR_USE_IDT77105 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 40/79] xdp: unpin xdp umem pages in error path Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 41/79] qed: Add cleanup in qed_slowpath_start() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 42/79] ARM: 8874/1: mm: only adjust sections of valid mm structures Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 43/79] batman-adv: Only read OGM2 tvlv_len after buffer len check Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 44/79] bpf: allow narrow loads of some sk_reuseport_md fields with offset > 0 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 45/79] r8152: Set memory to all 0xFFs on failed reg reads Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 46/79] x86/apic: Fix arch_dynirq_lower_bound() bug for DT enabled machines Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 47/79] netfilter: xt_physdev: Fix spurious error message in physdev_mt_check Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 48/79] netfilter: nf_conntrack_ftp: Fix debug output Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 49/79] NFSv2: Fix eof handling Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 50/79] NFSv2: Fix write regression Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 51/79] kallsyms: Dont let kallsyms_lookup_size_offset() fail on retrieving the first symbol Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 52/79] cifs: set domainName when a domain-key is used in multiuser Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 53/79] cifs: Use kzfree() to zero out the password Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 54/79] usb: host: xhci-tegra: Set DMA mask correctly Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 55/79] ARM: 8901/1: add a criteria for pfn_valid of arm Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 56/79] ibmvnic: Do not process reset during or after device removal Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 57/79] sky2: Disable MSI on yet another ASUS boards (P6Xxxx) Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 58/79] i2c: designware: Synchronize IRQs when unregistering slave client Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 59/79] perf/x86/intel: Restrict period on Nehalem Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 60/79] perf/x86/amd/ibs: Fix sample bias for dispatched micro-ops Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 61/79] amd-xgbe: Fix error path in xgbe_mod_init() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 62/79] tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 63/79] tools/power x86_energy_perf_policy: Fix argument parsing Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 64/79] tools/power turbostat: fix buffer overrun Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 65/79] net: aquantia: fix out of memory condition on rx side Greg Kroah-Hartman
2019-09-20 11:20   ` Pavel Machek
2019-09-19 22:03 ` [PATCH 4.19 66/79] net: seeq: Fix the function used to release some memory in an error handling path Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 67/79] dmaengine: ti: dma-crossbar: Fix a memory leak bug Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 68/79] dmaengine: ti: omap-dma: Add cleanup in omap_dma_probe() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 69/79] x86/uaccess: Dont leak the AC flags into __get_user() argument evaluation Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 70/79] x86/hyper-v: Fix overflow bug in fill_gva_list() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 71/79] keys: Fix missing null pointer check in request_key_auth_describe() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 72/79] iommu/amd: Flush old domains in kdump kernel Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 73/79] iommu/amd: Fix race in increase_address_space() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 74/79] PCI: kirin: Fix section mismatch warning Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 75/79] ovl: fix regression caused by overlapping layers detection Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 76/79] floppy: fix usercopy direction Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 77/79] binfmt_elf: move brk out of mmap when doing direct loader exec Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 78/79] arm64: kpti: Whitelist Cortex-A CPUs that dont implement the CSV3 field Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 79/79] media: technisat-usb2: break out of loop at end of buffer Greg Kroah-Hartman
2019-09-20  3:39 ` [PATCH 4.19 00/79] 4.19.75-stable review kernelci.org bot
2019-09-20  8:51 ` Naresh Kamboju
2019-09-20 13:48 ` Jon Hunter
2019-09-20 18:37 ` Guenter Roeck
2019-09-20 21:21 ` shuah

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=20190919214810.818333331@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=fw@strlen.de \
    --cc=juliana.rodrigueiro@intra2net.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).