lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190610160234.4070-5-bjorn.topel@gmail.com>
Date:   Mon, 10 Jun 2019 18:02:33 +0200
From:   Björn Töpel <bjorn.topel@...il.com>
To:     ast@...nel.org, daniel@...earbox.net, netdev@...r.kernel.org
Cc:     Björn Töpel <bjorn.topel@...el.com>,
        magnus.karlsson@...el.com, toke@...hat.com, brouer@...hat.com,
        bpf@...r.kernel.org, jakub.kicinski@...ronome.com,
        saeedm@...lanox.com
Subject: [PATCH bpf-next v3 4/5] net: xdp: refactor XDP flags checking

From: Björn Töpel <bjorn.topel@...el.com>

Similar to query a driver for a loaded XDP program, each driver need
to check the attachment flags when a program is loaded.

E.g., if an XDP program was loaded without explicit flags (fallback
mode), it must be reloaded/removed without explicit flags.

This commit moves that check to generic code as well.

Signed-off-by: Björn Töpel <bjorn.topel@...el.com>
---
 net/core/dev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 8e9f5693a7da..bb5fbb395596 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8075,8 +8075,8 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
 	const struct net_device_ops *ops = dev->netdev_ops;
 	xdp_query_prog_t query, check;
 	struct bpf_prog *prog = NULL;
+	bool offload, expl;
 	bpf_op_t bpf_op;
-	bool offload;
 	int err;
 
 	ASSERT_RTNL();
@@ -8124,6 +8124,14 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
 		}
 	}
 
+	expl = dev->xdp.explicit_mode;
+	if (!offload && query(dev) && !!expl ^ !!(flags & XDP_FLAGS_MODES)) {
+		NL_SET_ERR_MSG(extack, "program loaded with different flags");
+		if (prog)
+			bpf_prog_put(prog);
+		return -EBUSY;
+	}
+
 	err = dev_xdp_install(dev, bpf_op, extack, flags, prog);
 	if (err < 0 && prog)
 		bpf_prog_put(prog);
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ