All of lore.kernel.org
 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,
	Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.14 54/71] inet_diag: fix reporting cgroup classid and fallback to priority
Date: Mon, 25 Feb 2019 22:11:56 +0100	[thread overview]
Message-ID: <20190225195038.702300108@linuxfoundation.org> (raw)
In-Reply-To: <20190225195034.555044862@linuxfoundation.org>

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

------------------

From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>

[ Upstream commit 1ec17dbd90f8b638f41ee650558609c1af63dfa0 ]

Field idiag_ext in struct inet_diag_req_v2 used as bitmap of requested
extensions has only 8 bits. Thus extensions starting from DCTCPINFO
cannot be requested directly. Some of them included into response
unconditionally or hook into some of lower 8 bits.

Extension INET_DIAG_CLASS_ID has not way to request from the beginning.

This patch bundle it with INET_DIAG_TCLASS (ipv6 tos), fixes space
reservation, and documents behavior for other extensions.

Also this patch adds fallback to reporting socket priority. This filed
is more widely used for traffic classification because ipv4 sockets
automatically maps TOS to priority and default qdisc pfifo_fast knows
about that. But priority could be changed via setsockopt SO_PRIORITY so
INET_DIAG_TOS isn't enough for predicting class.

Also cgroup2 obsoletes net_cls classid (it always zero), but we cannot
reuse this field for reporting cgroup2 id because it is 64-bit (ino+gen).

So, after this patch INET_DIAG_CLASS_ID will report socket priority
for most common setup when net_cls isn't set and/or cgroup2 in use.

Fixes: 0888e372c37f ("net: inet: diag: expose sockets cgroup classid")
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/uapi/linux/inet_diag.h |   16 +++++++++++-----
 net/ipv4/inet_diag.c           |   10 +++++++++-
 net/sctp/sctp_diag.c           |    1 +
 3 files changed, 21 insertions(+), 6 deletions(-)

--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -135,15 +135,21 @@ enum {
 	INET_DIAG_TCLASS,
 	INET_DIAG_SKMEMINFO,
 	INET_DIAG_SHUTDOWN,
-	INET_DIAG_DCTCPINFO,
-	INET_DIAG_PROTOCOL,  /* response attribute only */
+
+	/*
+	 * Next extenstions cannot be requested in struct inet_diag_req_v2:
+	 * its field idiag_ext has only 8 bits.
+	 */
+
+	INET_DIAG_DCTCPINFO,	/* request as INET_DIAG_VEGASINFO */
+	INET_DIAG_PROTOCOL,	/* response attribute only */
 	INET_DIAG_SKV6ONLY,
 	INET_DIAG_LOCALS,
 	INET_DIAG_PEERS,
 	INET_DIAG_PAD,
-	INET_DIAG_MARK,
-	INET_DIAG_BBRINFO,
-	INET_DIAG_CLASS_ID,
+	INET_DIAG_MARK,		/* only with CAP_NET_ADMIN */
+	INET_DIAG_BBRINFO,	/* request as INET_DIAG_VEGASINFO */
+	INET_DIAG_CLASS_ID,	/* request as INET_DIAG_TCLASS */
 	INET_DIAG_MD5SIG,
 	__INET_DIAG_MAX,
 };
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -109,6 +109,7 @@ static size_t inet_sk_attr_size(struct s
 		+ nla_total_size(1) /* INET_DIAG_TOS */
 		+ nla_total_size(1) /* INET_DIAG_TCLASS */
 		+ nla_total_size(4) /* INET_DIAG_MARK */
+		+ nla_total_size(4) /* INET_DIAG_CLASS_ID */
 		+ nla_total_size(sizeof(struct inet_diag_meminfo))
 		+ nla_total_size(sizeof(struct inet_diag_msg))
 		+ nla_total_size(SK_MEMINFO_VARS * sizeof(u32))
@@ -288,12 +289,19 @@ int inet_sk_diag_fill(struct sock *sk, s
 			goto errout;
 	}
 
-	if (ext & (1 << (INET_DIAG_CLASS_ID - 1))) {
+	if (ext & (1 << (INET_DIAG_CLASS_ID - 1)) ||
+	    ext & (1 << (INET_DIAG_TCLASS - 1))) {
 		u32 classid = 0;
 
 #ifdef CONFIG_SOCK_CGROUP_DATA
 		classid = sock_cgroup_classid(&sk->sk_cgrp_data);
 #endif
+		/* Fallback to socket priority if class id isn't set.
+		 * Classful qdiscs use it as direct reference to class.
+		 * For cgroup2 classid is always zero.
+		 */
+		if (!classid)
+			classid = sk->sk_priority;
 
 		if (nla_put_u32(skb, INET_DIAG_CLASS_ID, classid))
 			goto errout;
--- a/net/sctp/sctp_diag.c
+++ b/net/sctp/sctp_diag.c
@@ -225,6 +225,7 @@ static size_t inet_assoc_attr_size(struc
 		+ nla_total_size(1) /* INET_DIAG_TOS */
 		+ nla_total_size(1) /* INET_DIAG_TCLASS */
 		+ nla_total_size(4) /* INET_DIAG_MARK */
+		+ nla_total_size(4) /* INET_DIAG_CLASS_ID */
 		+ nla_total_size(addrlen * asoc->peer.transport_count)
 		+ nla_total_size(addrlen * addrcnt)
 		+ nla_total_size(sizeof(struct inet_diag_meminfo))



  parent reply	other threads:[~2019-02-25 21:59 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 21:11 [PATCH 4.14 00/71] 4.14.104-stable review Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 01/71] ARM: 8834/1: Fix: kprobes: optimized kprobes illegal instruction Greg Kroah-Hartman
2019-02-25 21:11   ` Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 02/71] tracing: Fix number of entries in trace header Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 03/71] MIPS: eBPF: Always return sign extended 32b values Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 04/71] mac80211: Restore vif beacon interval if start ap fails Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 05/71] mac80211: Free mpath object when rhashtable insertion fails Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 06/71] libceph: handle an empty authorize reply Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 07/71] ceph: avoid repeatedly adding inode to mdsc->snap_flush_list Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 08/71] numa: change get_mempolicy() to use nr_node_ids instead of MAX_NUMNODES Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 09/71] proc, oom: do not report alien mms when setting oom_score_adj Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 10/71] KEYS: allow reaching the keys quotas exactly Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 11/71] mfd: ti_am335x_tscadc: Use PLATFORM_DEVID_AUTO while registering mfd cells Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 12/71] pvcalls-back: set -ENOTCONN in pvcalls_conn_back_read Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 13/71] mfd: twl-core: Fix section annotations on {,un}protect_pm_master Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 14/71] mfd: db8500-prcmu: Fix some section annotations Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 15/71] mfd: mt6397: Do not call irq_domain_remove if PMIC unsupported Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 16/71] mfd: ab8500-core: Return zero in get_register_interruptible() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 17/71] mfd: bd9571mwv: Add volatile register to make DVFS work Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 18/71] mfd: qcom_rpm: write fw_version to CTRL_REG Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 19/71] mfd: wm5110: Add missing ASRC rate register Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 20/71] mfd: tps65218: Use devm_regmap_add_irq_chip and clean up error path in probe() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 21/71] mfd: mc13xxx: Fix a missing check of a register-read failure Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 22/71] xen/pvcalls: remove set but not used variable intf Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 23/71] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 24/71] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 25/71] net: hns: Fix use after free identified by SLUB debug Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 26/71] MIPS: ath79: Enable OF serial ports in the default config Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 27/71] netfilter: nf_tables: fix leaking object reference count Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 28/71] scsi: qla4xxx: check return code of qla4xxx_copy_from_fwddb_param Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 29/71] scsi: isci: initialize shost fully before calling scsi_add_host() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 30/71] MIPS: jazz: fix 64bit build Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 31/71] bpf: correctly set initial window on active Fast Open sender Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 32/71] net: stmmac: Fix PCI module removal leak Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 33/71] isdn: i4l: isdn_tty: Fix some concurrency double-free bugs Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 34/71] scsi: ufs: Fix system suspend status Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 35/71] scsi: qedi: Add ep_state for login completion on un-reachable targets Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 36/71] always clear the X2APIC_ENABLE bit for PV guest Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 37/71] drm/meson: add missing of_node_put Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 38/71] atm: he: fix sign-extension overflow on large shift Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 39/71] hwmon: (tmp421) Correct the misspelling of the tmp442 compatible attribute in OF device ID table Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 40/71] leds: lp5523: fix a missing check of return value of lp55xx_read Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 41/71] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 42/71] mlxsw: spectrum_switchdev: Do not treat static FDB entries as sticky Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 43/71] net/mlx5e: Fix wrong (zero) TX drop counter indication for representor Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 44/71] isdn: avm: Fix string plus integer warning from Clang Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 45/71] batman-adv: fix uninit-value in batadv_interface_tx() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 46/71] ipv6: propagate genlmsg_reply return code Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 47/71] net/mlx5e: Dont overwrite pedit action when multiple pedit used Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 48/71] net/packet: fix 4gb buffer limit due to overflow check Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 49/71] net: sfp: do not probe SFP module before were attached Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 50/71] sctp: call gso_reset_checksum when computing checksum in sctp_gso_segment Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 51/71] team: avoid complex list operations in team_nl_cmd_options_set() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 52/71] sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 53/71] net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames Greg Kroah-Hartman
2019-02-25 21:11 ` Greg Kroah-Hartman [this message]
2019-02-25 21:11 ` [PATCH 4.14 55/71] RDMA/srp: Rework SCSI device reset handling Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 56/71] KEYS: user: Align the payload buffer Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 57/71] KEYS: always initialize keyring_index_key::desc_len Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 58/71] parisc: Fix ptrace syscall number modification Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 59/71] ARCv2: Enable unaligned access in early ASM code Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 60/71] ARC: U-boot: check arguments paranoidly Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 61/71] ARC: define ARCH_SLAB_MINALIGN = 8 Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 62/71] drm/i915/fbdev: Actually configure untiled displays Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 63/71] net: validate untrusted gso packets without csum offload Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 64/71] net: avoid false positives in untrusted gso validation Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 65/71] Revert "bridge: do not add port to router list when receives query with source 0.0.0.0" Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 66/71] netfilter: nf_tables: fix flush after rule deletion in the same batch Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 67/71] netfilter: nft_compat: use-after-free when deleting targets Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 68/71] netfilter: ipv6: Dont preserve original oif for loopback address Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 69/71] pinctrl: max77620: Use define directive for max77620_pinconf_param values Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 70/71] phy: tegra: remove redundant self assignment of map Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 71/71] sched/sysctl: Fix attributes of some extern declarations Greg Kroah-Hartman
2019-02-26  8:44 ` [PATCH 4.14 00/71] 4.14.104-stable review Naresh Kamboju
2019-02-26 12:24 ` Jon Hunter
2019-02-26 12:24   ` Jon Hunter
2019-02-26 14:20 ` kernelci.org bot
2019-02-26 15:40 ` shuah
2019-02-26 17:46 ` Guenter Roeck

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=20190225195038.702300108@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.