linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Michal Schmidt <mschmidt@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 109/111] rtnetlink: fix userspace API breakage for iproute2 < v3.9.0
Date: Mon, 23 Jun 2014 10:32:24 +0200	[thread overview]
Message-ID: <76acb94289d2ca897bd820b9627f4ade15230663.1403512281.git.jslaby@suse.cz> (raw)
In-Reply-To: <55d5f044a1fc96a74e4470e318c0a24f27a9ab7e.1403512280.git.jslaby@suse.cz>
In-Reply-To: <cover.1403512280.git.jslaby@suse.cz>

From: Michal Schmidt <mschmidt@redhat.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

[ Upstream commit e5eca6d41f53db48edd8cf88a3f59d2c30227f8e ]

When running RHEL6 userspace on a current upstream kernel, "ip link"
fails to show VF information.

The reason is a kernel<->userspace API change introduced by commit
88c5b5ce5cb57 ("rtnetlink: Call nlmsg_parse() with correct header length"),
after which the kernel does not see iproute2's IFLA_EXT_MASK attribute
in the netlink request.

iproute2 adjusted for the API change in its commit 63338dca4513
("libnetlink: Use ifinfomsg instead of rtgenmsg in rtnl_wilddump_req_filter").

The problem has been noticed before:
http://marc.info/?l=linux-netdev&m=136692296022182&w=2
(Subject: Re: getting VF link info seems to be broken in 3.9-rc8)

We can do better than tell those with old userspace to upgrade. We can
recognize the old iproute2 in the kernel by checking the netlink message
length. Even when including the IFLA_EXT_MASK attribute, its netlink
message is shorter than struct ifinfomsg.

With this patch "ip link" shows VF information in both old and new
iproute2 versions.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/core/rtnetlink.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f3d46dfb6944..070c51506eb1 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1106,6 +1106,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 	struct nlattr *tb[IFLA_MAX+1];
 	u32 ext_filter_mask = 0;
 	int err;
+	int hdrlen;
 
 	s_h = cb->args[0];
 	s_idx = cb->args[1];
@@ -1113,8 +1114,17 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 	rcu_read_lock();
 	cb->seq = net->dev_base_seq;
 
-	if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
-			ifla_policy) >= 0) {
+	/* A hack to preserve kernel<->userspace interface.
+	 * The correct header is ifinfomsg. It is consistent with rtnl_getlink.
+	 * However, before Linux v3.9 the code here assumed rtgenmsg and that's
+	 * what iproute2 < v3.9.0 used.
+	 * We can detect the old iproute2. Even including the IFLA_EXT_MASK
+	 * attribute, its netlink message is shorter than struct ifinfomsg.
+	 */
+	hdrlen = nlmsg_len(cb->nlh) < sizeof(struct ifinfomsg) ?
+		 sizeof(struct rtgenmsg) : sizeof(struct ifinfomsg);
+
+	if (nlmsg_parse(cb->nlh, hdrlen, tb, IFLA_MAX, ifla_policy) >= 0) {
 
 		if (tb[IFLA_EXT_MASK])
 			ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
@@ -1979,9 +1989,13 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
 	struct nlattr *tb[IFLA_MAX+1];
 	u32 ext_filter_mask = 0;
 	u16 min_ifinfo_dump_size = 0;
+	int hdrlen;
+
+	/* Same kernel<->userspace interface hack as in rtnl_dump_ifinfo. */
+	hdrlen = nlmsg_len(nlh) < sizeof(struct ifinfomsg) ?
+		 sizeof(struct rtgenmsg) : sizeof(struct ifinfomsg);
 
-	if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
-			ifla_policy) >= 0) {
+	if (nlmsg_parse(nlh, hdrlen, tb, IFLA_MAX, ifla_policy) >= 0) {
 		if (tb[IFLA_EXT_MASK])
 			ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
 	}
-- 
2.0.0


  parent reply	other threads:[~2014-06-23  8:40 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23  8:32 [PATCH 3.12 000/111] 3.12.23-stable review Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 001/111] ath9k: Fix sequence number assignment for non-data frames Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 002/111] rtlwifi: rtl8192se: Fix regression due to commit 1bf4bbb Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 003/111] xhci: extend quirk for Renesas cards Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 004/111] drm/i915: restrict vt-d stolen memory workaround to pre-gen8 Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 005/111] floppy: do not corrupt bio.bi_flags when reading block 0 Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 006/111] xhci: Switch only Intel Lynx Point-LP ports to EHCI on shutdown Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 007/111] MIPS: asm: thread_info: Add _TIF_SECCOMP flag Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 008/111] btrfs: fix defrag 32-bit integer overflow Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 009/111] target: Fix NULL pointer dereference for XCOPY in target_put_sess_cmd Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 010/111] mm: compaction: reset cached scanner pfn's before reading them Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 011/111] mm: compaction: detect when scanners meet in isolate_freepages Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 012/111] mm/compaction: make isolate_freepages start at pageblock boundary Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 013/111] ARM: perf: hook up perf_sample_event_took around pmu irq handling Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 014/111] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap() Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 015/111] sched: Use CPUPRI_NR_PRIORITIES instead of MAX_RT_PRIO in cpupri check Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 016/111] sched: Sanitize irq accounting madness Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 017/111] perf: Prevent false warning in perf_swevent_add Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 018/111] perf: Limit perf_event_attr::sample_period to 63 bits Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 019/111] perf: Fix race in removing an event Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 020/111] mm/memory-failure.c: fix memory leak by race between poison and unpoison Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 021/111] Documentation: fix DOCBOOKS=... building Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 022/111] hwmon: (ntc_thermistor) Fix dependencies Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 023/111] hwmon: (ntc_thermistor) Fix OF device ID mapping Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 024/111] drm/gf119-/disp: fix nasty bug which can clobber SOR0's clock setup Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 025/111] drm/radeon: also try GART for CPU accessed buffers Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 026/111] drm/radeon: handle non-VGA class pci devices with ATRM Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 027/111] SCSI: scsi_transport_sas: move bsg destructor into sas_rphy_remove Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 028/111] ARM: imx: fix error handling in ipu device registration Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 029/111] ARM: omap5: hwmod_data: Correct IDLEMODE for McPDM Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 030/111] ARM: OMAP3: clock: Back-propagate rate change from cam_mclk to dpll4_m5 on all OMAP3 platforms Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 031/111] ARM: 8051/1: put_user: fix possible data corruption in put_user Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 032/111] ARM: 8064/1: fix v7-M signal return Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 033/111] cpufreq: remove race while accessing cur_policy Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 034/111] dm cache: always split discards on cache block boundaries Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 035/111] sched: Fix hotplug vs. set_cpus_allowed_ptr() Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 036/111] drm/radeon: avoid crash if VM command submission isn't available Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 037/111] drm/i915: Only copy back the modified fields to userspace from execbuffer Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 038/111] libata: Blacklist queued trim for Crucial M500 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 039/111] md: always set MD_RECOVERY_INTR when aborting a reshape or other "resync" Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 040/111] md: always set MD_RECOVERY_INTR when interrupting a reshape thread Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 041/111] xhci: delete endpoints from bandwidth list before freeing whole device Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 042/111] Staging: speakup: Move pasting into a work item Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 043/111] staging: comedi: ni_daq_700: add mux settling delay Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 044/111] Staging: speakup: Update __speakup_paste_selection() tty (ab)usage to match vt Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 045/111] ALSA: hda/analog - Fix silent output on ASUS A8JN Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 046/111] ALSA: hda/realtek - Correction of fixup codes for PB V7900 laptop Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 047/111] ALSA: hda/realtek - Fix COEF widget NID for ALC260 replacer fixup Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 048/111] USB: ftdi_sio: add NovaTech OrionLXm product ID Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 049/111] usb: cdc-wdm: export cdc-wdm uapi header Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 050/111] USB: cdc-wdm: properly include types.h Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 051/111] USB: serial: option: add support for Novatel E371 PCIe card Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 052/111] USB: io_ti: fix firmware download on big-endian machines (part 2) Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 053/111] usb: pci-quirks: Prevent Sony VAIO t-series from switching usb ports Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 054/111] USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 055/111] percpu-refcount: fix usage of this_cpu_ops Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 056/111] mm: rmap: fix use-after-free in __put_anon_vma Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 057/111] iser-target: Add missing target_put_sess_cmd for ImmedateData failure Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 058/111] target: Fix alua_access_state attribute OOPs for un-configured devices Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 059/111] gpio: mcp23s08: Bug fix of SPI device tree registration Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 060/111] [media] rtl28xxu: add 15f4:0131 Astrometa DVB-T2 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 061/111] [media] Add USB IDs for Winfast DTV Dongle Mini-D Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 062/111] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 063/111] Target/iscsi,iser: Avoid accepting transport connections during stop stage Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 064/111] iser-target: Fix multi network portal shutdown regression Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 065/111] target: Allow READ_CAPACITY opcode in ALUA Standby access state Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 066/111] auditsc: audit_krule mask accesses need bounds checking Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 067/111] mei: me: drop harmful wait optimization Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 068/111] rtl28xxu: add ID [0ccd:00b4] TerraTec NOXON DAB Stick (rev 3) Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 069/111] rtl28xxu: add USB ID for Genius TVGo DVB-T03 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 070/111] rtl28xxu: add chipset version comments into device list Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 071/111] rtl28xxu: add 1b80:d395 Peak DVB-T USB Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 072/111] rtl28xxu: add [1b80:d39d] Sveon STV20 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 073/111] rtl28xxu: add [1b80:d3af] Sveon STV27 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 074/111] ahci: Add Device ID for HighPoint RocketRaid 642L Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 075/111] ahci: add PCI ID for Marvell 88SE91A0 SATA Controller Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 076/111] drm/i915: Allow user modes to exceed DVI 165MHz limit Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 077/111] ima: audit log files opened with O_DIRECT flag Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 078/111] skbuff: skb_segment: s/frag/nskb_frag/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 079/111] skbuff: skb_segment: s/skb_frag/frag/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 080/111] skbuff: skb_segment: s/skb/head_skb/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 081/111] skbuff: skb_segment: s/fskb/list_skb/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 082/111] skbuff: skb_segment: orphan frags before copying Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 083/111] rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 084/111] iscsi-target: Reject mutual authentication with reflected CHAP_C Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 085/111] ima: introduce ima_kernel_read() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 086/111] evm: prohibit userspace writing 'security.evm' HMAC value Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 087/111] netlink: Rename netlink_capable netlink_allowed Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 088/111] net: Move the permission check in sock_diag_put_filterinfo to packet_diag_dump Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 089/111] net: Add variants of capable for use on on sockets Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 090/111] net: Add variants of capable for use on netlink messages Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 091/111] net: Use netlink_ns_capable to verify the permisions of " Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 092/111] netlink: Only check file credentials for implicit destinations Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 093/111] qlcnic: info leak in qlcnic_dcb_peer_app_info() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 094/111] netlink: rate-limit leftover bytes warning and print process name Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 095/111] bridge: Prevent insertion of FDB entry with disallowed vlan Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 096/111] net: tunnels - enable module autoloading Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 097/111] net: fix inet_getid() and ipv6_select_ident() bugs Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 098/111] team: fix mtu setting Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 099/111] tcp: fix cwnd undo on DSACK in F-RTO Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 100/111] sh_eth: use RNC mode for packet reception Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 101/111] sh_eth: fix SH7619/771x support Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 102/111] net: filter: fix typo in sparc BPF JIT Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 103/111] net: filter: fix sparc32 typo Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 104/111] net: qmi_wwan: add Olivetti Olicard modems Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 105/111] net: force a list_del() in unregister_netdevice_many() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 106/111] ipip, sit: fix ipv4_{update_pmtu,redirect} calls Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 107/111] ipv4: fix a race in ip4_datagram_release_cb() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 108/111] sctp: Fix sk_ack_backlog wrap-around problem Jiri Slaby
2014-06-23  8:32 ` Jiri Slaby [this message]
2014-06-23  8:32 ` [PATCH 3.12 110/111] vxlan: use dev->needed_headroom instead of dev->hard_header_len Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 111/111] ARM: at91: fix at91_sysirq_mask_rtc for sam9x5 SoCs Jiri Slaby
2014-06-23 14:55 ` [PATCH 3.12 000/111] 3.12.23-stable review Guenter Roeck
2014-06-25 13:29   ` Jiri Slaby
2014-06-23 16:45 ` Shuah Khan
2014-06-23 22:13 ` Satoru Takeuchi

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=76acb94289d2ca897bd820b9627f4ade15230663.1403512281.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mschmidt@redhat.com \
    --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).