* [PATCH 5/5] sh_eth: make sh_eth_tsu_{read|write}_entry() prototypes symmetric
From: Sergei Shtylyov @ 2018-07-23 18:15 UTC (permalink / raw)
To: netdev, David S. Miller; +Cc: linux-renesas-soc
In-Reply-To: <24093fd0-1b9b-a211-f988-0272483185d6@cogentembedded.com>
sh_eth_tsu_read_entry() is still asymmetric with sh_eth_tsu_write_entry()
WRT their prototypes -- make them symmetric by passing to the former a TSU
register offset instead of its address and also adding the (now necessary)
'ndev' parameter...
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
drivers/net/ethernet/renesas/sh_eth.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -2695,16 +2695,17 @@ static int sh_eth_tsu_write_entry(struct
return 0;
}
-static void sh_eth_tsu_read_entry(void *reg, u8 *addr)
+static void sh_eth_tsu_read_entry(struct net_device *ndev, u16 offset, u8 *addr)
{
+ struct sh_eth_private *mdp = netdev_priv(ndev);
u32 val;
- val = ioread32(reg);
+ val = ioread32(mdp->tsu_addr + offset);
addr[0] = (val >> 24) & 0xff;
addr[1] = (val >> 16) & 0xff;
addr[2] = (val >> 8) & 0xff;
addr[3] = val & 0xff;
- val = ioread32(reg + 4);
+ val = ioread32(mdp->tsu_addr + offset + 4);
addr[4] = (val >> 8) & 0xff;
addr[5] = val & 0xff;
}
@@ -2718,7 +2719,7 @@ static int sh_eth_tsu_find_entry(struct
u8 c_addr[ETH_ALEN];
for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) {
- sh_eth_tsu_read_entry(mdp->tsu_addr + reg_offset, c_addr);
+ sh_eth_tsu_read_entry(ndev, reg_offset, c_addr);
if (ether_addr_equal(addr, c_addr))
return i;
}
@@ -2839,7 +2840,7 @@ static void sh_eth_tsu_purge_mcast(struc
return;
for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) {
- sh_eth_tsu_read_entry(mdp->tsu_addr + reg_offset, addr);
+ sh_eth_tsu_read_entry(ndev, reg_offset, addr);
if (is_multicast_ether_addr(addr))
sh_eth_tsu_del_entry(ndev, addr);
}
^ permalink raw reply
* Re: [PATCH net] ipv6: use fib6_info_hold_safe() when necessary
From: David Miller @ 2018-07-23 18:19 UTC (permalink / raw)
To: weiwan; +Cc: netdev, edumazet, dsahern, kafai
In-Reply-To: <20180722035632.136090-1-tracywwnj@gmail.com>
From: Wei Wang <weiwan@google.com>
Date: Sat, 21 Jul 2018 20:56:32 -0700
> From: Wei Wang <weiwan@google.com>
>
> In the code path where only rcu read lock is held, e.g. in the route
> lookup code path, it is not safe to directly call fib6_info_hold()
> because the fib6_info may already have been deleted but still exists
> in the rcu grace period. Holding reference to it could cause double
> free and crash the kernel.
>
> This patch adds a new function fib6_info_hold_safe() and replace
> fib6_info_hold() in all necessary places.
>
> Syzbot reported 3 crash traces because of this. One of them is:
...
> Fixes: 93531c674315 (net/ipv6: separate handling of FIB entries from dst based routes)
> Reported-by: syzbot+902e2a1bcd4f7808cef5@syzkaller.appspotmail.com
> Reported-by: syzbot+8ae62d67f647abeeceb9@syzkaller.appspotmail.com
> Reported-by: syzbot+3f08feb14086930677d0@syzkaller.appspotmail.com
> Signed-off-by: Wei Wang <weiwan@google.com>
> Acked-by: Eric Dumazet <edumazet@google.com>
Applied, thank you.
^ permalink raw reply
* Re: [PATCH net-next 1/2] be2net: Collect the transmit queue data in Tx timeout
From: David Miller @ 2018-07-23 18:23 UTC (permalink / raw)
To: suresh.reddy; +Cc: netdev
In-Reply-To: <20180723142524.24224-2-suresh.reddy@broadcom.com>
From: Suresh Reddy <suresh.reddy@broadcom.com>
Date: Mon, 23 Jul 2018 10:25:23 -0400
> Driver dumps tx_queue, tx_compl, pending SKBs information in tx_timeout.
> This debug data used to idenfiy the cause of the time out.
>
> Also reset Lancer chip in tx_timeout.
>
> Signed-off-by: Suresh Reddy <suresh.reddy@broadcom.com>
The purpose of the tx timeout NDO operation is to do whatever is
necessary to handle the TX timeout.
Outputting debugging information is useful, but is secondary.
I see that you do reset the Lancer, but that is far from what really
needs to happen here.
When you get a TX timeout, the hardware is not processing TX ring
entries, nor signalling completion any longer.
Therefore the only way to get things going again is to reset all of
the TX side data structure and logic. This means shutting down the TX
engine, freeing up all of the TX SKBs in the ring, resetting the TX
ring software state, and then finally reprogramming the head/tail
pointer registers and re-enabling TX DMA processing.
^ permalink raw reply
* Re: [PATCH net] ipv6: use fib6_info_hold_safe() when necessary
From: Martin KaFai Lau @ 2018-07-23 18:25 UTC (permalink / raw)
To: Wei Wang; +Cc: David Miller, netdev, Eric Dumazet, David Ahern
In-Reply-To: <20180722035632.136090-1-tracywwnj@gmail.com>
On Sat, Jul 21, 2018 at 08:56:32PM -0700, Wei Wang wrote:
> From: Wei Wang <weiwan@google.com>
>
> In the code path where only rcu read lock is held, e.g. in the route
> lookup code path, it is not safe to directly call fib6_info_hold()
> because the fib6_info may already have been deleted but still exists
> in the rcu grace period. Holding reference to it could cause double
> free and crash the kernel.
>
> This patch adds a new function fib6_info_hold_safe() and replace
> fib6_info_hold() in all necessary places.
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply
* Re: [RFC PATCH ghak90 (was ghak32) V3 02/10] audit: log container info of syscalls
From: Paul Moore @ 2018-07-23 18:31 UTC (permalink / raw)
To: sgrubb, rgb
Cc: cgroups, containers, linux-api, linux-audit, linux-fsdevel,
linux-kernel, netdev, ebiederm, luto, carlos, dhowells, viro,
simo, Eric Paris, serge
In-Reply-To: <2739536.aL1iVigTi9@x2>
On Mon, Jul 23, 2018 at 12:48 PM Steve Grubb <sgrubb@redhat.com> wrote:
> On Monday, July 23, 2018 11:11:48 AM EDT Richard Guy Briggs wrote:
> > On 2018-07-23 09:19, Steve Grubb wrote:
> > > On Sunday, July 22, 2018 4:55:10 PM EDT Richard Guy Briggs wrote:
> > > > On 2018-07-22 09:32, Steve Grubb wrote:
> > > > > On Saturday, July 21, 2018 4:29:30 PM EDT Richard Guy Briggs wrote:
> > > > > > > > + * audit_log_contid - report container info
> > > > > > > > + * @tsk: task to be recorded
> > > > > > > > + * @context: task or local context for record
> > > > > > > > + * @op: contid string description
> > > > > > > > + */
> > > > > > > > +int audit_log_contid(struct task_struct *tsk,
> > > > > > > > + struct audit_context *context,
> > > > > > > > char
> > > > > > > > *op)
> > > > > > > > +{
> > > > > > > > + struct audit_buffer *ab;
> > > > > > > > +
> > > > > > > > + if (!audit_contid_set(tsk))
> > > > > > > > + return 0;
> > > > > > > > + /* Generate AUDIT_CONTAINER record with container ID */
> > > > > > > > + ab = audit_log_start(context, GFP_KERNEL,
> > > > > > > > AUDIT_CONTAINER);
> > > > > > > > + if (!ab)
> > > > > > > > + return -ENOMEM;
> > > > > > > > + audit_log_format(ab, "op=%s contid=%llu",
> > > > > > > > + op, audit_get_contid(tsk));
> > > > > > >
> > > > > > > Can you explain your reason for including an "op" field in this
> > > > > > > record
> > > > > > > type? I've been looking at the rest of the patches in this
> > > > > > > patchset
> > > > > > > and it seems to be used more as an indicator of the record's
> > > > > > > generating context rather than any sort of audit container ID
> > > > > > > operation.
> > > > > >
> > > > > > "action" might work, but that's netfilter and numeric... "kind"?
> > > > > > Nothing else really seems to fit from a field name, type or lack of
> > > > > > searchability perspective.
> > > > > >
> > > > > > Steve, do you have an opinion?
> > > > >
> > > > > We only have 1 sample event where we have op=task. What are the other
> > > > > possible values?
> > > >
> > > > For the AUDIT_CONTAINER record we have op= "task", "target" (from the
> > > > ptrace and signals patch), "tty".
> > > >
> > > > For the AUDIT_CONTAINER_ID record we have "op=set".
> > >
> > > Since the purpose of this record is to log the container id, I think that
> > > is all that is needed. We can get the context from the other records in
> > > the event. I'd suggest dropping the "op" field.
> >
> > Ok, the information above it for two different audit container
> > identifier records. Which one should drop the "op=" field? Both? Or
> > just the AUDIT_CONTAINER record? The AUDIT_CONTAINER_ID record (which
> > might be renamed) could use it to distinguish a "set" record from a
> > dropped audit container identifier that is no longer registered by any
> > task or namespace.
>
> Neither of them need it. All they need to do is state the container that is
> being acted upon.
I think we should keep the "op" field for audit container ID
management operations, even though we really only have a "set"
operation at the moment, but the others should drop the "op" field
(see my previous emails in this thread).
--
paul moore
www.paul-moore.com
^ permalink raw reply
* Re: [PATCH v2 bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR
From: Yonghong Song @ 2018-07-23 18:31 UTC (permalink / raw)
To: Martin KaFai Lau, netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <20180721182043.1401089-4-kafai@fb.com>
On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> This patch introduces BPF_ANNOTATE_KV_PAIR to signal the
> bpf loader about the btf key_type and value_type of a bpf map.
> Please refer to the changes in test_btf_haskv.c for its usage.
> Both iproute2 and libbpf loader will then have the same
> convention to find out the map's btf_key_type_id and
> btf_value_type_id from a map's name.
>
> Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
> tools/lib/bpf/btf.c | 7 +-
> tools/lib/bpf/btf.h | 2 +
> tools/lib/bpf/libbpf.c | 75 +++++++++++---------
> tools/testing/selftests/bpf/bpf_helpers.h | 9 +++
> tools/testing/selftests/bpf/test_btf_haskv.c | 7 +-
> 5 files changed, 56 insertions(+), 44 deletions(-)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index ce77b5b57912..321a99e648ed 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -189,8 +189,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> return 0;
> }
>
> -static const struct btf_type *btf_type_by_id(const struct btf *btf,
> - __u32 type_id)
> +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id)
> {
> if (type_id > btf->nr_types)
> return NULL;
> @@ -233,7 +232,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> __s64 size = -1;
> int i;
>
> - t = btf_type_by_id(btf, type_id);
> + t = btf__type_by_id(btf, type_id);
> for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t);
> i++) {
> size = btf_type_size(t);
> @@ -258,7 +257,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> return -EINVAL;
> }
>
> - t = btf_type_by_id(btf, type_id);
> + t = btf__type_by_id(btf, type_id);
> }
>
> if (size < 0)
> diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> index ed3a84370ccc..e2a09a155f84 100644
> --- a/tools/lib/bpf/btf.h
> +++ b/tools/lib/bpf/btf.h
> @@ -9,6 +9,7 @@
> #define BTF_ELF_SEC ".BTF"
>
> struct btf;
> +struct btf_type;
>
> typedef int (*btf_print_fn_t)(const char *, ...)
> __attribute__((format(printf, 1, 2)));
> @@ -16,6 +17,7 @@ typedef int (*btf_print_fn_t)(const char *, ...)
> void btf__free(struct btf *btf);
> struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
> __s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 id);
> __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
> int btf__fd(const struct btf *btf);
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 6deb4fe4fffe..d881d370616c 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -36,6 +36,7 @@
> #include <linux/err.h>
> #include <linux/kernel.h>
> #include <linux/bpf.h>
> +#include <linux/btf.h>
> #include <linux/list.h>
> #include <linux/limits.h>
> #include <sys/stat.h>
> @@ -1014,68 +1015,72 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
>
> static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
> {
> + const struct btf_type *container_type;
> + const struct btf_member *key, *value;
> struct bpf_map_def *def = &map->def;
> const size_t max_name = 256;
> + char container_name[max_name];
> __s64 key_size, value_size;
> - __s32 key_id, value_id;
> - char name[max_name];
> + __s32 container_id;
>
> - /* Find key type by name from BTF */
> - if (snprintf(name, max_name, "%s_key", map->name) == max_name) {
> - pr_warning("map:%s length of BTF key_type:%s_key is too long\n",
> + if (snprintf(container_name, max_name, "____btf_map_%s", map->name) ==
> + max_name) {
> + pr_warning("map:%s length of '____btf_map_%s' is too long\n",
> map->name, map->name);
> return -EINVAL;
> }
>
> - key_id = btf__find_by_name(btf, name);
> - if (key_id < 0) {
> - pr_debug("map:%s key_type:%s cannot be found in BTF\n",
> - map->name, name);
> - return key_id;
> + container_id = btf__find_by_name(btf, container_name);
> + if (container_id < 0) {
> + pr_debug("map:%s container_name:%s cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?\n",
> + map->name, container_name);
> + return container_id;
> }
>
> - key_size = btf__resolve_size(btf, key_id);
> - if (key_size < 0) {
> - pr_warning("map:%s key_type:%s cannot get the BTF type_size\n",
> - map->name, name);
> - return key_size;
> + container_type = btf__type_by_id(btf, container_id);
> + if (!container_type) {
> + pr_warning("map:%s cannot find BTF type for container_id:%u\n",
> + map->name, container_id);
> + return -EINVAL;
> }
>
> - if (def->key_size != key_size) {
> - pr_warning("map:%s key_type:%s has BTF type_size:%u != key_size:%u\n",
> - map->name, name, (unsigned int)key_size, def->key_size);
> + if (BTF_INFO_KIND(container_type->info) != BTF_KIND_STRUCT ||
> + BTF_INFO_VLEN(container_type->info) < 2) {
Should "BTF_INFO_VLEN(container_type->info) < 2" be
"BTF_INFO_VLEN(container_type->info) != 2"?
> + pr_warning("map:%s container_name:%s is an invalid container struct\n",
> + map->name, container_name);
> return -EINVAL;
> }
>
> - /* Find value type from BTF */
> - if (snprintf(name, max_name, "%s_value", map->name) == max_name) {
> - pr_warning("map:%s length of BTF value_type:%s_value is too long\n",
> - map->name, map->name);
> - return -EINVAL;
> + key = (struct btf_member *)(container_type + 1);
> + value = key + 1;
> +
> + key_size = btf__resolve_size(btf, key->type);
> + if (key_size < 0) {
> + pr_warning("map:%s invalid BTF key_type_size\n",
> + map->name);
> + return key_size;
> }
>
> - value_id = btf__find_by_name(btf, name);
> - if (value_id < 0) {
> - pr_debug("map:%s value_type:%s cannot be found in BTF\n",
> - map->name, name);
> - return value_id;
> + if (def->key_size != key_size) {
> + pr_warning("map:%s btf_key_type_size:%u != map_def_key_size:%u\n",
> + map->name, (__u32)key_size, def->key_size);
> + return -EINVAL;
> }
>
> - value_size = btf__resolve_size(btf, value_id);
> + value_size = btf__resolve_size(btf, value->type);
> if (value_size < 0) {
> - pr_warning("map:%s value_type:%s cannot get the BTF type_size\n",
> - map->name, name);
> + pr_warning("map:%s invalid BTF value_type_size\n", map->name);
> return value_size;
> }
>
> if (def->value_size != value_size) {
> - pr_warning("map:%s value_type:%s has BTF type_size:%u != value_size:%u\n",
> - map->name, name, (unsigned int)value_size, def->value_size);
> + pr_warning("map:%s btf_value_type_size:%u != map_def_value_size:%u\n",
> + map->name, (__u32)value_size, def->value_size);
> return -EINVAL;
> }
>
> - map->btf_key_type_id = key_id;
> - map->btf_value_type_id = value_id;
> + map->btf_key_type_id = key->type;
> + map->btf_value_type_id = value->type;
>
> return 0;
> }
> diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
> index f2f28b6c8915..810de20e8e26 100644
> --- a/tools/testing/selftests/bpf/bpf_helpers.h
> +++ b/tools/testing/selftests/bpf/bpf_helpers.h
> @@ -158,6 +158,15 @@ struct bpf_map_def {
> unsigned int numa_node;
> };
>
> +#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) \
> + struct ____btf_map_##name { \
> + type_key key; \
> + type_val value; \
> + }; \
> + struct ____btf_map_##name \
> + __attribute__ ((section(".maps." #name), used)) \
> + ____btf_map_##name = { }
> +
> static int (*bpf_skb_load_bytes)(void *ctx, int off, void *to, int len) =
> (void *) BPF_FUNC_skb_load_bytes;
> static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) =
> diff --git a/tools/testing/selftests/bpf/test_btf_haskv.c b/tools/testing/selftests/bpf/test_btf_haskv.c
> index 8c7ca096ecf2..b21b876f475d 100644
> --- a/tools/testing/selftests/bpf/test_btf_haskv.c
> +++ b/tools/testing/selftests/bpf/test_btf_haskv.c
> @@ -10,11 +10,6 @@ struct ipv_counts {
> unsigned int v6;
> };
>
> -typedef int btf_map_key;
> -typedef struct ipv_counts btf_map_value;
> -btf_map_key dumm_key;
> -btf_map_value dummy_value;
> -
> struct bpf_map_def SEC("maps") btf_map = {
> .type = BPF_MAP_TYPE_ARRAY,
> .key_size = sizeof(int),
> @@ -22,6 +17,8 @@ struct bpf_map_def SEC("maps") btf_map = {
> .max_entries = 4,
> };
>
> +BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
> +
> struct dummy_tracepoint_args {
> unsigned long long pad;
> struct sock *sock;
>
^ permalink raw reply
* Re: KASAN: use-after-free Read in p9_fd_poll
From: syzbot @ 2018-07-23 19:41 UTC (permalink / raw)
To: davem, ericvh, linux-kernel, lucho, netdev, rminnich,
syzkaller-bugs, v9fs-developer
In-Reply-To: <000000000000afbebb0570be9bf3@google.com>
syzbot has found a reproducer for the following crash on:
HEAD commit: d72e90f33aa4 Linux 4.18-rc6
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=161894c8400000
kernel config: https://syzkaller.appspot.com/x/.config?x=68af3495408deac5
dashboard link: https://syzkaller.appspot.com/bug?extid=0442e6e2f7e1e33b1037
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=1569b51c400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16e7a978400000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+0442e6e2f7e1e33b1037@syzkaller.appspotmail.com
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
==================================================================
BUG: KASAN: use-after-free in p9_fd_poll+0x280/0x2b0 net/9p/trans_fd.c:238
Read of size 8 at addr ffff8801d6ddf340 by task kworker/0:2/26
CPU: 0 PID: 26 Comm: kworker/0:2 Not tainted 4.18.0-rc6+ #160
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: events p9_poll_workfn
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1c9/0x2b4 lib/dump_stack.c:113
print_address_description+0x6c/0x20b mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
p9_fd_poll+0x280/0x2b0 net/9p/trans_fd.c:238
p9_poll_mux net/9p/trans_fd.c:617 [inline]
p9_poll_workfn+0x463/0x6d0 net/9p/trans_fd.c:1107
process_one_work+0xc73/0x1ba0 kernel/workqueue.c:2153
worker_thread+0x189/0x13c0 kernel/workqueue.c:2296
kthread+0x345/0x410 kernel/kthread.c:246
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
Allocated by task 4581:
save_stack+0x43/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
kmem_cache_alloc_trace+0x152/0x780 mm/slab.c:3620
kmalloc include/linux/slab.h:513 [inline]
kzalloc include/linux/slab.h:707 [inline]
p9_fd_open net/9p/trans_fd.c:796 [inline]
p9_fd_create+0x1a7/0x3f0 net/9p/trans_fd.c:1036
p9_client_create+0x8ed/0x1770 net/9p/client.c:1063
v9fs_session_init+0x21a/0x1a80 fs/9p/v9fs.c:400
v9fs_mount+0x7c/0x900 fs/9p/vfs_super.c:135
mount_fs+0xae/0x328 fs/super.c:1277
vfs_kern_mount.part.34+0xdc/0x4e0 fs/namespace.c:1037
vfs_kern_mount fs/namespace.c:1027 [inline]
do_new_mount fs/namespace.c:2518 [inline]
do_mount+0x581/0x30e0 fs/namespace.c:2848
ksys_mount+0x12d/0x140 fs/namespace.c:3064
__do_sys_mount fs/namespace.c:3078 [inline]
__se_sys_mount fs/namespace.c:3075 [inline]
__x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 4581:
save_stack+0x43/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
__kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
__cache_free mm/slab.c:3498 [inline]
kfree+0xd9/0x260 mm/slab.c:3813
p9_fd_close+0x416/0x5b0 net/9p/trans_fd.c:893
p9_client_create+0xa9a/0x1770 net/9p/client.c:1077
v9fs_session_init+0x21a/0x1a80 fs/9p/v9fs.c:400
v9fs_mount+0x7c/0x900 fs/9p/vfs_super.c:135
mount_fs+0xae/0x328 fs/super.c:1277
vfs_kern_mount.part.34+0xdc/0x4e0 fs/namespace.c:1037
vfs_kern_mount fs/namespace.c:1027 [inline]
do_new_mount fs/namespace.c:2518 [inline]
do_mount+0x581/0x30e0 fs/namespace.c:2848
ksys_mount+0x12d/0x140 fs/namespace.c:3064
__do_sys_mount fs/namespace.c:3078 [inline]
__se_sys_mount fs/namespace.c:3075 [inline]
__x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff8801d6ddf340
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 0 bytes inside of
512-byte region [ffff8801d6ddf340, ffff8801d6ddf540)
The buggy address belongs to the page:
page:ffffea00075b77c0 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0007398548 ffffea0006c59188 ffff8801da800940
raw: 0000000000000000 ffff8801d6ddf0c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8801d6ddf200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d6ddf280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff8801d6ddf300: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff8801d6ddf380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d6ddf400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
^ permalink raw reply
* Re: bisected: 4.18-rc* regression: x86-32 troubles (with timers?)
From: Daniel Borkmann @ 2018-07-23 19:41 UTC (permalink / raw)
To: Arnd Bergmann, Meelis Roos; +Cc: Linux Kernel list, Networking
In-Reply-To: <CAK8P3a19pCbn5Ns0jVqGTiSmGj4AOgjWL0CQtAA-sYRqY4Gvjw@mail.gmail.com>
Hello Meelis, Arnd,
On 07/23/2018 06:03 PM, Arnd Bergmann wrote:
> On Sat, Jul 21, 2018 at 1:01 AM, Meelis Roos <mroos@linux.ee> wrote:
>> Added netdev and Daniel Borkmann - please see
>> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1724795.html
>> for the original report. It seems to be about BPF instead.
>>
>> Meanwhile I have found more machines with the trouble. Still no clear
>> mark in the config - some x86-32 machines that have
>> CONFIG_BPF=y
>> CONFIG_BPF_SYSCALL=y
>> CONFIG_BPF_JIT_ALWAYS_ON=y
>> are working fine.
>>
>>> The new bisect seems to have also led me to a strange commit. This time
>>> I tried to be careful and tested most on two reboots before classifying
>>> as good.
>>>
>>> However, f4e3ec0d573e was suspicious - it failed to autoload e1000 but
>>> had no other errors. On both boots with this kernel, modprobe e1000 and
>>> ifup -a made the system work so I assumed it was good, while it might
>>> not have been. Will try bisecting with f4e3ec0d573e marked bad.
>>
>> Now this seems more relevant:
>>
>> mroos@rx100s2:~/linux$ nice git bisect good
>> 24dea04767e6e5175f4750770281b0c17ac6a2fb is the first bad commit
>> commit 24dea04767e6e5175f4750770281b0c17ac6a2fb
>> Author: Daniel Borkmann <daniel@iogearbox.net>
>> Date: Fri May 4 01:08:23 2018 +0200
>>
>> bpf, x32: remove ld_abs/ld_ind
>>
>> Since LD_ABS/LD_IND instructions are now removed from the core and
>> reimplemented through a combination of inlined BPF instructions and
>> a slow-path helper, we can get rid of the complexity from x32 JIT.
>
> This does seem much more likely than the previous bisection, given
> that you ended up in an x86-32 specific commit (the subject says x32,
> but that is a mistake). I also checked that systemd indeed does
> call into bpf in a number of places, possibly for the journald socket.
>
> OTOH, it's still hard to tell how that commit can have ended up
> corrupting the clock read function in systemd. To cross-check,
> could you try reverting that commit on the latest kernel and see
> if it still works?
I would be curious as well about that whether revert would make it
work. What's the value of sysctl net.core.bpf_jit_enable ? Does it
change anything if you set it to 0 (only interpreter) or 1 (JIT
enabled). Seems a bit strange to me that bisect ended at this commit
given the issue you have. The JIT itself was also new in this window
fwiw. In any case some more debug info would be great to have.
Thanks,
Daniel
^ permalink raw reply
* Re: [PATCH net] ip: hash fragments consistently
From: David Miller @ 2018-07-23 18:40 UTC (permalink / raw)
To: pabeni; +Cc: netdev, tom
In-Reply-To: <9b22fd3a35416b3145f1245466167b001925ce1a.1532357173.git.pabeni@redhat.com>
From: Paolo Abeni <pabeni@redhat.com>
Date: Mon, 23 Jul 2018 16:50:48 +0200
> The skb hash for locally generated ip[v6] fragments belonging
> to the same datagram can vary in several circumstances:
> * for connected UDP[v6] sockets, the first fragment get its hash
> via set_owner_w()/skb_set_hash_from_sk()
> * for unconnected IPv6 UDPv6 sockets, the first fragment can get
> its hash via ip6_make_flowlabel()/skb_get_hash_flowi6(), if
> auto_flowlabel is enabled
>
> For the following frags the hash is usually computed via
> skb_get_hash().
> The above can cause OoO for unconnected IPv6 UDPv6 socket: in that
> scenario the egress tx queue can be selected on a per packet basis
> via the skb hash.
> It may also fool flow-oriented schedulers to place fragments belonging
> to the same datagram in different flows.
>
> Fix the issue by copying the skb hash from the head frag into
> the others at fragmentation time.
>
> Before this commit:
> perf probe -a "dev_queue_xmit skb skb->hash skb->l4_hash:b1@0/8 skb->sw_hash:b1@1/8"
> netperf -H $IPV4 -t UDP_STREAM -l 5 -- -m 2000 -n &
> perf record -e probe:dev_queue_xmit -e probe:skb_set_owner_w -a sleep 0.1
> perf script
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=3713014309 l4_hash=1 sw_hash=0
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=0 l4_hash=0 sw_hash=0
>
> After this commit:
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=2171763177 l4_hash=1 sw_hash=0
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=2171763177 l4_hash=1 sw_hash=0
>
> Fixes: b73c3d0e4f0e ("net: Save TX flow hash in sock and set in skbuf on xmit")
> Fixes: 67800f9b1f4e ("ipv6: Call skb_get_hash_flowi6 to get skb->hash in ip6_make_flowlabel")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Good catch!
Applied and queued up for -stable, thanks!
^ permalink raw reply
* Re: [PATCH v2 bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR
From: Martin KaFai Lau @ 2018-07-23 18:41 UTC (permalink / raw)
To: Yonghong Song; +Cc: netdev, Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <bd832483-293f-0113-14fa-d7b5fef53f4d@fb.com>
On Mon, Jul 23, 2018 at 11:31:43AM -0700, Yonghong Song wrote:
>
>
> On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> > This patch introduces BPF_ANNOTATE_KV_PAIR to signal the
> > bpf loader about the btf key_type and value_type of a bpf map.
> > Please refer to the changes in test_btf_haskv.c for its usage.
> > Both iproute2 and libbpf loader will then have the same
> > convention to find out the map's btf_key_type_id and
> > btf_value_type_id from a map's name.
> >
> > Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> > Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> > ---
> > tools/lib/bpf/btf.c | 7 +-
> > tools/lib/bpf/btf.h | 2 +
> > tools/lib/bpf/libbpf.c | 75 +++++++++++---------
> > tools/testing/selftests/bpf/bpf_helpers.h | 9 +++
> > tools/testing/selftests/bpf/test_btf_haskv.c | 7 +-
> > 5 files changed, 56 insertions(+), 44 deletions(-)
> >
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index ce77b5b57912..321a99e648ed 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -189,8 +189,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> > return 0;
> > }
> > -static const struct btf_type *btf_type_by_id(const struct btf *btf,
> > - __u32 type_id)
> > +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id)
> > {
> > if (type_id > btf->nr_types)
> > return NULL;
> > @@ -233,7 +232,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> > __s64 size = -1;
> > int i;
> > - t = btf_type_by_id(btf, type_id);
> > + t = btf__type_by_id(btf, type_id);
> > for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t);
> > i++) {
> > size = btf_type_size(t);
> > @@ -258,7 +257,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> > return -EINVAL;
> > }
> > - t = btf_type_by_id(btf, type_id);
> > + t = btf__type_by_id(btf, type_id);
> > }
> > if (size < 0)
> > diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> > index ed3a84370ccc..e2a09a155f84 100644
> > --- a/tools/lib/bpf/btf.h
> > +++ b/tools/lib/bpf/btf.h
> > @@ -9,6 +9,7 @@
> > #define BTF_ELF_SEC ".BTF"
> > struct btf;
> > +struct btf_type;
> > typedef int (*btf_print_fn_t)(const char *, ...)
> > __attribute__((format(printf, 1, 2)));
> > @@ -16,6 +17,7 @@ typedef int (*btf_print_fn_t)(const char *, ...)
> > void btf__free(struct btf *btf);
> > struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
> > __s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> > +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 id);
> > __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
> > int btf__fd(const struct btf *btf);
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 6deb4fe4fffe..d881d370616c 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -36,6 +36,7 @@
> > #include <linux/err.h>
> > #include <linux/kernel.h>
> > #include <linux/bpf.h>
> > +#include <linux/btf.h>
> > #include <linux/list.h>
> > #include <linux/limits.h>
> > #include <sys/stat.h>
> > @@ -1014,68 +1015,72 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
> > static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
> > {
> > + const struct btf_type *container_type;
> > + const struct btf_member *key, *value;
> > struct bpf_map_def *def = &map->def;
> > const size_t max_name = 256;
> > + char container_name[max_name];
> > __s64 key_size, value_size;
> > - __s32 key_id, value_id;
> > - char name[max_name];
> > + __s32 container_id;
> > - /* Find key type by name from BTF */
> > - if (snprintf(name, max_name, "%s_key", map->name) == max_name) {
> > - pr_warning("map:%s length of BTF key_type:%s_key is too long\n",
> > + if (snprintf(container_name, max_name, "____btf_map_%s", map->name) ==
> > + max_name) {
> > + pr_warning("map:%s length of '____btf_map_%s' is too long\n",
> > map->name, map->name);
> > return -EINVAL;
> > }
> > - key_id = btf__find_by_name(btf, name);
> > - if (key_id < 0) {
> > - pr_debug("map:%s key_type:%s cannot be found in BTF\n",
> > - map->name, name);
> > - return key_id;
> > + container_id = btf__find_by_name(btf, container_name);
> > + if (container_id < 0) {
> > + pr_debug("map:%s container_name:%s cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?\n",
> > + map->name, container_name);
> > + return container_id;
> > }
> > - key_size = btf__resolve_size(btf, key_id);
> > - if (key_size < 0) {
> > - pr_warning("map:%s key_type:%s cannot get the BTF type_size\n",
> > - map->name, name);
> > - return key_size;
> > + container_type = btf__type_by_id(btf, container_id);
> > + if (!container_type) {
> > + pr_warning("map:%s cannot find BTF type for container_id:%u\n",
> > + map->name, container_id);
> > + return -EINVAL;
> > }
> > - if (def->key_size != key_size) {
> > - pr_warning("map:%s key_type:%s has BTF type_size:%u != key_size:%u\n",
> > - map->name, name, (unsigned int)key_size, def->key_size);
> > + if (BTF_INFO_KIND(container_type->info) != BTF_KIND_STRUCT ||
> > + BTF_INFO_VLEN(container_type->info) < 2) {
>
> Should "BTF_INFO_VLEN(container_type->info) < 2" be
> "BTF_INFO_VLEN(container_type->info) != 2"?
I intentionally use "<" in case we may want to extend
BPF_ANNOTATE_KV_PAIR in the future.
>
> > + pr_warning("map:%s container_name:%s is an invalid container struct\n",
> > + map->name, container_name);
> > return -EINVAL;
> > }
> > - /* Find value type from BTF */
> > - if (snprintf(name, max_name, "%s_value", map->name) == max_name) {
> > - pr_warning("map:%s length of BTF value_type:%s_value is too long\n",
> > - map->name, map->name);
> > - return -EINVAL;
> > + key = (struct btf_member *)(container_type + 1);
> > + value = key + 1;
> > +
> > + key_size = btf__resolve_size(btf, key->type);
> > + if (key_size < 0) {
> > + pr_warning("map:%s invalid BTF key_type_size\n",
> > + map->name);
> > + return key_size;
> > }
> > - value_id = btf__find_by_name(btf, name);
> > - if (value_id < 0) {
> > - pr_debug("map:%s value_type:%s cannot be found in BTF\n",
> > - map->name, name);
> > - return value_id;
> > + if (def->key_size != key_size) {
> > + pr_warning("map:%s btf_key_type_size:%u != map_def_key_size:%u\n",
> > + map->name, (__u32)key_size, def->key_size);
> > + return -EINVAL;
> > }
> > - value_size = btf__resolve_size(btf, value_id);
> > + value_size = btf__resolve_size(btf, value->type);
> > if (value_size < 0) {
> > - pr_warning("map:%s value_type:%s cannot get the BTF type_size\n",
> > - map->name, name);
> > + pr_warning("map:%s invalid BTF value_type_size\n", map->name);
> > return value_size;
> > }
> > if (def->value_size != value_size) {
> > - pr_warning("map:%s value_type:%s has BTF type_size:%u != value_size:%u\n",
> > - map->name, name, (unsigned int)value_size, def->value_size);
> > + pr_warning("map:%s btf_value_type_size:%u != map_def_value_size:%u\n",
> > + map->name, (__u32)value_size, def->value_size);
> > return -EINVAL;
> > }
> > - map->btf_key_type_id = key_id;
> > - map->btf_value_type_id = value_id;
> > + map->btf_key_type_id = key->type;
> > + map->btf_value_type_id = value->type;
> > return 0;
> > }
> > diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
> > index f2f28b6c8915..810de20e8e26 100644
> > --- a/tools/testing/selftests/bpf/bpf_helpers.h
> > +++ b/tools/testing/selftests/bpf/bpf_helpers.h
> > @@ -158,6 +158,15 @@ struct bpf_map_def {
> > unsigned int numa_node;
> > };
> > +#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) \
> > + struct ____btf_map_##name { \
> > + type_key key; \
> > + type_val value; \
> > + }; \
> > + struct ____btf_map_##name \
> > + __attribute__ ((section(".maps." #name), used)) \
> > + ____btf_map_##name = { }
> > +
> > static int (*bpf_skb_load_bytes)(void *ctx, int off, void *to, int len) =
> > (void *) BPF_FUNC_skb_load_bytes;
> > static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) =
> > diff --git a/tools/testing/selftests/bpf/test_btf_haskv.c b/tools/testing/selftests/bpf/test_btf_haskv.c
> > index 8c7ca096ecf2..b21b876f475d 100644
> > --- a/tools/testing/selftests/bpf/test_btf_haskv.c
> > +++ b/tools/testing/selftests/bpf/test_btf_haskv.c
> > @@ -10,11 +10,6 @@ struct ipv_counts {
> > unsigned int v6;
> > };
> > -typedef int btf_map_key;
> > -typedef struct ipv_counts btf_map_value;
> > -btf_map_key dumm_key;
> > -btf_map_value dummy_value;
> > -
> > struct bpf_map_def SEC("maps") btf_map = {
> > .type = BPF_MAP_TYPE_ARRAY,
> > .key_size = sizeof(int),
> > @@ -22,6 +17,8 @@ struct bpf_map_def SEC("maps") btf_map = {
> > .max_entries = 4,
> > };
> > +BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
> > +
> > struct dummy_tracepoint_args {
> > unsigned long long pad;
> > struct sock *sock;
> >
^ permalink raw reply
* Re: [PATCH v2 bpf 2/3] bpf: Replace [u]int32_t and [u]int64_t in libbpf
From: Martin KaFai Lau @ 2018-07-23 18:41 UTC (permalink / raw)
To: Yonghong Song; +Cc: netdev, Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <f9f7ad47-b53b-35c7-d0ab-119d01c2cf41@fb.com>
On Mon, Jul 23, 2018 at 11:04:34AM -0700, Yonghong Song wrote:
>
>
> On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> > This patch replaces [u]int32_t and [u]int64_t usage with
> > __[su]32 and __[su]64. The same change goes for [u]int16_t
> > and [u]int8_t.
> >
> > Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> > ---
> > tools/lib/bpf/btf.c | 28 +++++++++++++---------------
> > tools/lib/bpf/btf.h | 8 ++++----
> > tools/lib/bpf/libbpf.c | 12 ++++++------
> > tools/lib/bpf/libbpf.h | 4 ++--
> > 4 files changed, 25 insertions(+), 27 deletions(-)
> >
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index 8c54a4b6f187..ce77b5b57912 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -2,7 +2,6 @@
> > /* Copyright (c) 2018 Facebook */
> > #include <stdlib.h>
> > -#include <stdint.h>
> > #include <string.h>
> > #include <unistd.h>
> > #include <errno.h>
> > @@ -27,13 +26,13 @@ struct btf {
> > struct btf_type **types;
> > const char *strings;
> > void *nohdr_data;
> > - uint32_t nr_types;
> > - uint32_t types_size;
> > - uint32_t data_size;
> > + __u32 nr_types;
> > + __u32 types_size;
> > + __u32 data_size;
> > int fd;
> > };
> > -static const char *btf_name_by_offset(const struct btf *btf, uint32_t offset)
> > +static const char *btf_name_by_offset(const struct btf *btf, __u32 offset)
> > {
> > if (offset < btf->hdr->str_len)
> > return &btf->strings[offset];
> > @@ -151,7 +150,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> > while (next_type < end_type) {
> > struct btf_type *t = next_type;
> > - uint16_t vlen = BTF_INFO_VLEN(t->info);
> > + __u16 vlen = BTF_INFO_VLEN(t->info);
> > int err;
> > next_type += sizeof(*t);
> > @@ -191,7 +190,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> > }
> > static const struct btf_type *btf_type_by_id(const struct btf *btf,
> > - uint32_t type_id)
> > + __u32 type_id)
> > {
> > if (type_id > btf->nr_types)
> > return NULL;
> > @@ -226,12 +225,12 @@ static int64_t btf_type_size(const struct btf_type *t)
>
> Missing this one:
> static int64_t btf_type_size(const struct btf_type *t)
>
> There are a couple of instances of using u32 instead of __u32, better to use
> __u32 everywhere in the same file:
> u32 expand_by, new_size;
> u32 meta_left;
Thanks for pointing them out. Will make the changes.
>
>
> > #define MAX_RESOLVE_DEPTH 32
> > -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
> > +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> > {
> > const struct btf_array *array;
> > const struct btf_type *t;
> > - uint32_t nelems = 1;
> > - int64_t size = -1;
> > + __u32 nelems = 1;
> > + __s64 size = -1;
> > int i;
> > t = btf_type_by_id(btf, type_id);
> > @@ -271,9 +270,9 @@ int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
> > return nelems * size;
> > }
> > -int32_t btf__find_by_name(const struct btf *btf, const char *type_name)
> > +__s32 btf__find_by_name(const struct btf *btf, const char *type_name)
> > {
> > - uint32_t i;
> > + __u32 i;
> > if (!strcmp(type_name, "void"))
> > return 0;
> > @@ -302,10 +301,9 @@ void btf__free(struct btf *btf)
> > free(btf);
> > }
> > -struct btf *btf__new(uint8_t *data, uint32_t size,
> > - btf_print_fn_t err_log)
> > +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
> > {
> > - uint32_t log_buf_size = 0;
> > + __u32 log_buf_size = 0;
> > char *log_buf = NULL;
> > struct btf *btf;
> > int err;
> > diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> > index 74bb344035bb..ed3a84370ccc 100644
> > --- a/tools/lib/bpf/btf.h
> > +++ b/tools/lib/bpf/btf.h
> > @@ -4,7 +4,7 @@
> > #ifndef __BPF_BTF_H
> > #define __BPF_BTF_H
> > -#include <stdint.h>
> > +#include <linux/types.h>
> > #define BTF_ELF_SEC ".BTF"
> > @@ -14,9 +14,9 @@ typedef int (*btf_print_fn_t)(const char *, ...)
> > __attribute__((format(printf, 1, 2)));
> > void btf__free(struct btf *btf);
> > -struct btf *btf__new(uint8_t *data, uint32_t size, btf_print_fn_t err_log);
> > -int32_t btf__find_by_name(const struct btf *btf, const char *type_name);
> > -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id);
> > +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
> > +__s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> > +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
> > int btf__fd(const struct btf *btf);
> > #endif
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index a1e96b5de5ff..6deb4fe4fffe 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -216,8 +216,8 @@ struct bpf_map {
> > size_t offset;
> > int map_ifindex;
> > struct bpf_map_def def;
> > - uint32_t btf_key_type_id;
> > - uint32_t btf_value_type_id;
> > + __u32 btf_key_type_id;
> > + __u32 btf_value_type_id;
> > void *priv;
> > bpf_map_clear_priv_t clear_priv;
> > };
> > @@ -1016,8 +1016,8 @@ static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
> > {
> > struct bpf_map_def *def = &map->def;
> > const size_t max_name = 256;
> > - int64_t key_size, value_size;
> > - int32_t key_id, value_id;
> > + __s64 key_size, value_size;
> > + __s32 key_id, value_id;
> > char name[max_name];
> > /* Find key type by name from BTF */
> > @@ -2089,12 +2089,12 @@ const char *bpf_map__name(struct bpf_map *map)
> > return map ? map->name : NULL;
> > }
> > -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map)
> > +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map)
> > {
> > return map ? map->btf_key_type_id : 0;
> > }
> > -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map)
> > +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map)
> > {
> > return map ? map->btf_value_type_id : 0;
> > }
> > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> > index 09976531aa74..b33ae02f7d0e 100644
> > --- a/tools/lib/bpf/libbpf.h
> > +++ b/tools/lib/bpf/libbpf.h
> > @@ -244,8 +244,8 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
> > int bpf_map__fd(struct bpf_map *map);
> > const struct bpf_map_def *bpf_map__def(struct bpf_map *map);
> > const char *bpf_map__name(struct bpf_map *map);
> > -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map);
> > -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map);
> > +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map);
> > +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map);
> > typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
> > int bpf_map__set_priv(struct bpf_map *map, void *priv,
> >
^ permalink raw reply
* Re: [PATCH bpf] bpf: btf: Ensure the member->offset is in the right order
From: Yonghong Song @ 2018-07-23 18:45 UTC (permalink / raw)
To: Martin KaFai Lau, netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <20180721003837.2772516-1-kafai@fb.com>
On 7/20/18 5:38 PM, Martin KaFai Lau wrote:
> This patch ensures the member->offset of a struct
> is in the correct order (i.e the later member's offset cannot
> go backward).
>
> The current "pahole -J" BTF encoder does not generate something
> like this. However, checking this can ensure future encoder
> will not violate this.
>
> Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)")
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply
* [PATCH v2] rfkill: fix spelling mistake contidion to condition
From: Richard Guy Briggs @ 2018-07-23 18:47 UTC (permalink / raw)
To: netdev; +Cc: Linux-Audit Mailing List, Richard Guy Briggs
This came about while trying to determine if there would be any pattern
match on contid, a new audit container identifier internal variable.
This was the only one.
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
net/rfkill/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index a7a4e6f..3aab053 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -508,8 +508,8 @@ void rfkill_remove_epo_lock(void)
/**
* rfkill_is_epo_lock_active - returns true EPO is active
*
- * Returns 0 (false) if there is NOT an active EPO contidion,
- * and 1 (true) if there is an active EPO contition, which
+ * Returns 0 (false) if there is NOT an active EPO condition,
+ * and 1 (true) if there is an active EPO condition, which
* locks all radios in one of the BLOCKED states.
*
* Can be called in atomic context.
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH net 0/5] tcp: more robust ooo handling
From: David Miller @ 2018-07-23 19:03 UTC (permalink / raw)
To: edumazet; +Cc: juha-matti.tilli, ycheng, soheil, netdev, eric.dumazet
In-Reply-To: <20180723162821.11556-1-edumazet@google.com>
From: Eric Dumazet <edumazet@google.com>
Date: Mon, 23 Jul 2018 09:28:16 -0700
> Juha-Matti Tilli reported that malicious peers could inject tiny
> packets in out_of_order_queue, forcing very expensive calls
> to tcp_collapse_ofo_queue() and tcp_prune_ofo_queue() for
> every incoming packet.
>
> With tcp_rmem[2] default of 6MB, the ooo queue could
> contain ~7000 nodes.
>
> This patch series makes sure we cut cpu cycles enough to
> render the attack not critical.
>
> We might in the future go further, like disconnecting
> or black-holing proven malicious flows.
Sucky...
It took me a while to understand the sums_tiny logic, every
time I read that function I forget that we reset all of the
state and restart the loop after a coalesce inside the loop.
Series applied, and queued up for -stable.
Thanks!
^ permalink raw reply
* Re: [PATCH v2] rfkill: fix spelling mistake contidion to condition
From: David Miller @ 2018-07-23 19:06 UTC (permalink / raw)
To: rgb; +Cc: netdev, linux-audit
In-Reply-To: <d20eb29b5ab96608af9e68ba219f15c3bdc080b4.1532369437.git.rgb@redhat.com>
From: Richard Guy Briggs <rgb@redhat.com>
Date: Mon, 23 Jul 2018 14:47:30 -0400
> This came about while trying to determine if there would be any pattern
> match on contid, a new audit container identifier internal variable.
> This was the only one.
>
> Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
As per MAINTAINERS, rfkill patches should be sent to the linux-wireless
list and the maintainer, Johannes Berg.
Thank you.
^ permalink raw reply
* Re: [PATCH net-next 1/2] net: phy: add helper phy_polling_mode
From: Heiner Kallweit @ 2018-07-23 19:30 UTC (permalink / raw)
To: David Miller; +Cc: andrew, f.fainelli, netdev
In-Reply-To: <20180722.111140.529768117470903738.davem@davemloft.net>
On 22.07.2018 20:11, David Miller wrote:
>
> I think you can combine these two patches into one.
>
> Thank you.
>
Sure, will provide a v2.
^ permalink raw reply
* Re: bisected: 4.18-rc* regression: x86-32 troubles (with timers?)
From: Meelis Roos @ 2018-07-23 20:34 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: Arnd Bergmann, Linux Kernel list, Networking
In-Reply-To: <32227088-7754-c160-8046-e860f42ca91c@iogearbox.net>
> >> Now this seems more relevant:
> >>
> >> mroos@rx100s2:~/linux$ nice git bisect good
> >> 24dea04767e6e5175f4750770281b0c17ac6a2fb is the first bad commit
> >> commit 24dea04767e6e5175f4750770281b0c17ac6a2fb
> >> Author: Daniel Borkmann <daniel@iogearbox.net>
> >> Date: Fri May 4 01:08:23 2018 +0200
> >>
> >> bpf, x32: remove ld_abs/ld_ind
> >>
> >> Since LD_ABS/LD_IND instructions are now removed from the core and
> >> reimplemented through a combination of inlined BPF instructions and
> >> a slow-path helper, we can get rid of the complexity from x32 JIT.
> >
> > This does seem much more likely than the previous bisection, given
> > that you ended up in an x86-32 specific commit (the subject says x32,
> > but that is a mistake). I also checked that systemd indeed does
> > call into bpf in a number of places, possibly for the journald socket.
> >
> > OTOH, it's still hard to tell how that commit can have ended up
> > corrupting the clock read function in systemd. To cross-check,
> > could you try reverting that commit on the latest kernel and see
> > if it still works?
>
> I would be curious as well about that whether revert would make it
> work. What's the value of sysctl net.core.bpf_jit_enable ? Does it
> change anything if you set it to 0 (only interpreter) or 1 (JIT
> enabled). Seems a bit strange to me that bisect ended at this commit
> given the issue you have. The JIT itself was also new in this window
> fwiw. In any case some more debug info would be great to have.
net.core.bpf_jit_enable is 1.
Since it breaks bootup, I can not easily change the value at runtime (it
would be postfactum). Do you mean changing the
CONFIG_BPF_JIT_ALWAYS_ON=y option?
Anyway, I started compile of v4.18-rc5 that was the latest I tested,
with the commit in question reverted. Will see if I can test tomorrow
morning. But I will leave tomorrow for a week and can only test further
things if they happen to boot fine (no manual reboot possible for a
week).
--
Meelis Roos (mroos@linux.ee)
^ permalink raw reply
* Re: [PATCH 0/5] sh_eth: clean up the TSU register accessors
From: David Miller @ 2018-07-23 19:35 UTC (permalink / raw)
To: sergei.shtylyov; +Cc: netdev, linux-renesas-soc
In-Reply-To: <24093fd0-1b9b-a211-f988-0272483185d6@cogentembedded.com>
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Mon, 23 Jul 2018 21:08:31 +0300
> Here's a set of 5 patches against DaveM's 'net-next.git' repo. They
> do a final clean up of the TSU register accessors...
Series applied, thanks Sergei.
^ permalink raw reply
* [PATCH v2 net-next] net: phy: add helper phy_polling_mode
From: Heiner Kallweit @ 2018-07-23 19:40 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
Add a helper for checking whether polling is used to detect PHY status
changes.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- merge both patches
---
drivers/net/phy/phy.c | 8 ++++----
include/linux/phy.h | 10 ++++++++++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 914fe8e6..7ade22a7 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -519,7 +519,7 @@ static int phy_start_aneg_priv(struct phy_device *phydev, bool sync)
* negotiation may already be done and aneg interrupt may not be
* generated.
*/
- if (phydev->irq != PHY_POLL && phydev->state == PHY_AN) {
+ if (!phy_polling_mode(phydev) && phydev->state == PHY_AN) {
err = phy_aneg_done(phydev);
if (err > 0) {
trigger = true;
@@ -977,7 +977,7 @@ void phy_state_machine(struct work_struct *work)
needs_aneg = true;
break;
case PHY_NOLINK:
- if (phydev->irq != PHY_POLL)
+ if (!phy_polling_mode(phydev))
break;
err = phy_read_status(phydev);
@@ -1018,7 +1018,7 @@ void phy_state_machine(struct work_struct *work)
/* Only register a CHANGE if we are polling and link changed
* since latest checking.
*/
- if (phydev->irq == PHY_POLL) {
+ if (phy_polling_mode(phydev)) {
old_link = phydev->link;
err = phy_read_status(phydev);
if (err)
@@ -1117,7 +1117,7 @@ void phy_state_machine(struct work_struct *work)
* PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
* between states from phy_mac_interrupt()
*/
- if (phydev->irq == PHY_POLL)
+ if (phy_polling_mode(phydev))
queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
PHY_STATE_TIME * HZ);
}
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 075c2f77..cd6f637c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -824,6 +824,16 @@ static inline bool phy_interrupt_is_valid(struct phy_device *phydev)
return phydev->irq != PHY_POLL && phydev->irq != PHY_IGNORE_INTERRUPT;
}
+/**
+ * phy_polling_mode - Convenience function for testing whether polling is
+ * used to detect PHY status changes
+ * @phydev: the phy_device struct
+ */
+static inline bool phy_polling_mode(struct phy_device *phydev)
+{
+ return phydev->irq == PHY_POLL;
+}
+
/**
* phy_is_internal - Convenience function for testing if a PHY is internal
* @phydev: the phy_device struct
--
2.18.0
^ permalink raw reply related
* Re: [PATCH v4] selftests: add headers_install to lib.mk
From: Anders Roxell @ 2018-07-23 20:49 UTC (permalink / raw)
To: Masahiro Yamada, Michal Marek, Shuah Khan, Bamvor Zhang, brgl,
Paolo Bonzini, Andrew Morton, Mike Rapoport, aarcange
Cc: linux-kbuild, Linux Kernel Mailing List,
open list:KERNEL SELFTEST FRAMEWORK, Networking
In-Reply-To: <20180607110911.12252-1-anders.roxell@linaro.org>
On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote:
>
> If the kernel headers aren't installed we can't build all the tests.
> Add a new make target rule 'khdr' in the file lib.mk to generate the
> kernel headers and that gets include for every test-dir Makefile that
> includes lib.mk If the testdir in turn have its own sub-dirs the
> top_srcdir needs to be set to the linux-rootdir to be able to generate
> the kernel headers.
>
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org>
> ---
> Makefile | 14 +-------------
> scripts/subarch.include | 13 +++++++++++++
> tools/testing/selftests/android/Makefile | 2 +-
> tools/testing/selftests/android/ion/Makefile | 2 ++
> tools/testing/selftests/futex/functional/Makefile | 1 +
> tools/testing/selftests/gpio/Makefile | 7 ++-----
> tools/testing/selftests/kvm/Makefile | 7 ++-----
> tools/testing/selftests/lib.mk | 12 ++++++++++++
> tools/testing/selftests/net/Makefile | 1 +
> .../selftests/networking/timestamping/Makefile | 1 +
> tools/testing/selftests/vm/Makefile | 4 ----
> 11 files changed, 36 insertions(+), 28 deletions(-)
> create mode 100644 scripts/subarch.include
>
> diff --git a/Makefile b/Makefile
> index 6b9aea95ae3a..8050072300fa 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
> export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
>
> -# SUBARCH tells the usermode build what the underlying arch is. That is set
> -# first, and if a usermode build is happening, the "ARCH=um" on the command
> -# line overrides the setting of ARCH below. If a native build is happening,
> -# then ARCH is assigned, getting whatever value it gets normally, and
> -# SUBARCH is subsequently ignored.
> -
> -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
> - -e s/sun4u/sparc64/ \
> - -e s/arm.*/arm/ -e s/sa110/arm/ \
> - -e s/s390x/s390/ -e s/parisc64/parisc/ \
> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
> - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
> - -e s/riscv.*/riscv/)
> +include scripts/subarch.include
>
> # Cross compiling and selecting different set of gcc/bin-utils
> # ---------------------------------------------------------------------------
> diff --git a/scripts/subarch.include b/scripts/subarch.include
> new file mode 100644
> index 000000000000..650682821126
> --- /dev/null
> +++ b/scripts/subarch.include
> @@ -0,0 +1,13 @@
> +# SUBARCH tells the usermode build what the underlying arch is. That is set
> +# first, and if a usermode build is happening, the "ARCH=um" on the command
> +# line overrides the setting of ARCH below. If a native build is happening,
> +# then ARCH is assigned, getting whatever value it gets normally, and
> +# SUBARCH is subsequently ignored.
> +
> +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
> + -e s/sun4u/sparc64/ \
> + -e s/arm.*/arm/ -e s/sa110/arm/ \
> + -e s/s390x/s390/ -e s/parisc64/parisc/ \
> + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
> + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
> + -e s/riscv.*/riscv/)
> diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile
> index 72c25a3cb658..d9a725478375 100644
> --- a/tools/testing/selftests/android/Makefile
> +++ b/tools/testing/selftests/android/Makefile
> @@ -6,7 +6,7 @@ TEST_PROGS := run.sh
>
> include ../lib.mk
>
> -all:
> +all: khdr
> @for DIR in $(SUBDIRS); do \
> BUILD_TARGET=$(OUTPUT)/$$DIR; \
> mkdir $$BUILD_TARGET -p; \
> diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile
> index e03695287f76..88cfe88e466f 100644
> --- a/tools/testing/selftests/android/ion/Makefile
> +++ b/tools/testing/selftests/android/ion/Makefile
> @@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c
>
> TEST_PROGS := ion_test.sh
>
> +KSFT_KHDR_INSTALL := 1
> +top_srcdir = ../../../../..
> include ../../lib.mk
>
> $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c
> diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
> index ff8feca49746..ad1eeb14fda7 100644
> --- a/tools/testing/selftests/futex/functional/Makefile
> +++ b/tools/testing/selftests/futex/functional/Makefile
> @@ -18,6 +18,7 @@ TEST_GEN_FILES := \
>
> TEST_PROGS := run.sh
>
> +top_srcdir = ../../../../..
> include ../../lib.mk
>
> $(TEST_GEN_FILES): $(HEADERS)
> diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> index 1bbb47565c55..4665cdbf1a8d 100644
> --- a/tools/testing/selftests/gpio/Makefile
> +++ b/tools/testing/selftests/gpio/Makefile
> @@ -21,11 +21,8 @@ endef
> CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
> LDLIBS += -lmount -I/usr/include/libmount
>
> -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
> +$(BINARIES):| khdr
> +$(BINARIES): ../../../gpio/gpio-utils.o
>
> ../../../gpio/gpio-utils.o:
> make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
> -
> -../../../../usr/include/linux/gpio.h:
> - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/
> -
> diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
> index d9d00319b07c..bcb69380bbab 100644
> --- a/tools/testing/selftests/kvm/Makefile
> +++ b/tools/testing/selftests/kvm/Makefile
> @@ -32,9 +32,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
> $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
> $(AR) crs $@ $^
>
> -$(LINUX_HDR_PATH):
> - make -C $(top_srcdir) headers_install
> -
> -all: $(STATIC_LIBS) $(LINUX_HDR_PATH)
> +all: $(STATIC_LIBS)
> $(TEST_GEN_PROGS): $(STATIC_LIBS)
> -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH)
> +$(STATIC_LIBS):| khdr
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 17ab36605a8e..0a8e75886224 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
> TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
> TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
>
> +top_srcdir ?= ../../../..
> +include $(top_srcdir)/scripts/subarch.include
> +ARCH ?= $(SUBARCH)
> +
> all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
>
> +.PHONY: khdr
> +khdr:
> + make ARCH=$(ARCH) -C $(top_srcdir) headers_install
> +
> +ifdef KSFT_KHDR_INSTALL
> +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr
> +endif
> +
> .ONESHELL:
> define RUN_TEST_PRINT_RESULT
> TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \
> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> index 663e11e85727..d515dabc6b0d 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx
> TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
> TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict
>
> +KSFT_KHDR_INSTALL := 1
> include ../lib.mk
>
> $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma
> diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile
> index a728040edbe1..14cfcf006936 100644
> --- a/tools/testing/selftests/networking/timestamping/Makefile
> +++ b/tools/testing/selftests/networking/timestamping/Makefile
> @@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp
>
> all: $(TEST_PROGS)
>
> +top_srcdir = ../../../../..
> include ../../lib.mk
>
> clean:
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index fdefa2295ddc..58759454b1d0 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -25,10 +25,6 @@ TEST_PROGS := run_vmtests
>
> include ../lib.mk
>
> -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h
> $(OUTPUT)/userfaultfd: LDLIBS += -lpthread
>
> $(OUTPUT)/mlock-random-test: LDLIBS += -lcap
> -
> -../../../../usr/include/linux/kernel.h:
> - make -C ../../../.. headers_install
> --
> 2.17.1
>
Ping.
^ permalink raw reply
* [PATCH] vxge: Remove unnecessary include of <linux/pci_hotplug.h>
From: Bjorn Helgaas @ 2018-07-23 20:59 UTC (permalink / raw)
To: Jon Mason; +Cc: David S. Miller, netdev, linux-pci, linux-kernel
From: Bjorn Helgaas <bhelgaas@google.com>
The vxge driver doesn't need anything provided by pci_hotplug.h, so remove
the unnecessary include of it.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/net/ethernet/neterion/vxge/vxge-config.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
index 358ed6118881..a2c0a93ca8b6 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
@@ -14,7 +14,6 @@
#include <linux/vmalloc.h>
#include <linux/etherdevice.h>
#include <linux/pci.h>
-#include <linux/pci_hotplug.h>
#include <linux/slab.h>
#include "vxge-traffic.h"
^ permalink raw reply related
* [PATCH] net: sort Kconfig menu items alphabetically
From: Bjorn Helgaas @ 2018-07-23 21:01 UTC (permalink / raw)
To: David S. Miller
Cc: Florian Fainelli, Rasesh Mody, Sudarsana Kalluru, Jon Mason,
Dept-GELinuxNICDev, netdev, linux-kernel
From: Bjorn Helgaas <bhelgaas@google.com>
6c541b4595a2 ("net: ethernet: Sort Kconfig sourcing alphabetically")
sorted Kconfig sourcing based on directory names, but in a couple cases,
the menu item text is quite different from the directory name and is not
sorted correctly:
drivers/net/ethernet/neterion/Kconfig => "Exar devices"
drivers/net/ethernet/brocade/Kconfig => "QLogic BR-series devices"
Move these entries so the Kconfig menu items are sorted.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/net/ethernet/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index af766fd61151..b21febba458e 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -34,7 +34,6 @@ source "drivers/net/ethernet/arc/Kconfig"
source "drivers/net/ethernet/atheros/Kconfig"
source "drivers/net/ethernet/aurora/Kconfig"
source "drivers/net/ethernet/broadcom/Kconfig"
-source "drivers/net/ethernet/brocade/Kconfig"
source "drivers/net/ethernet/cadence/Kconfig"
source "drivers/net/ethernet/calxeda/Kconfig"
source "drivers/net/ethernet/cavium/Kconfig"
@@ -71,6 +70,7 @@ config DNET
source "drivers/net/ethernet/dec/Kconfig"
source "drivers/net/ethernet/dlink/Kconfig"
source "drivers/net/ethernet/emulex/Kconfig"
+source "drivers/net/ethernet/neterion/Kconfig"
source "drivers/net/ethernet/ezchip/Kconfig"
source "drivers/net/ethernet/faraday/Kconfig"
source "drivers/net/ethernet/freescale/Kconfig"
@@ -81,7 +81,6 @@ source "drivers/net/ethernet/huawei/Kconfig"
source "drivers/net/ethernet/i825xx/Kconfig"
source "drivers/net/ethernet/ibm/Kconfig"
source "drivers/net/ethernet/intel/Kconfig"
-source "drivers/net/ethernet/neterion/Kconfig"
source "drivers/net/ethernet/xscale/Kconfig"
config JME
@@ -160,6 +159,7 @@ config ETHOC
source "drivers/net/ethernet/packetengines/Kconfig"
source "drivers/net/ethernet/pasemi/Kconfig"
source "drivers/net/ethernet/qlogic/Kconfig"
+source "drivers/net/ethernet/brocade/Kconfig"
source "drivers/net/ethernet/qualcomm/Kconfig"
source "drivers/net/ethernet/rdc/Kconfig"
source "drivers/net/ethernet/realtek/Kconfig"
^ permalink raw reply related
* Re: [PATCH bpf] xdp: add NULL pointer check in __xdp_return()
From: Jakub Kicinski @ 2018-07-23 19:58 UTC (permalink / raw)
To: Björn Töpel
Cc: Daniel Borkmann, Björn Töpel, Jesper Dangaard Brouer,
kafai, ap420073, ast, Netdev, Karlsson, Magnus
In-Reply-To: <CAJ+HfNh5BLoqhJWkiDf7-mVxuPrOgAyGp6=8e5jOOOvVkb9+HA@mail.gmail.com>
On Mon, 23 Jul 2018 11:39:36 +0200, Björn Töpel wrote:
> Den fre 20 juli 2018 kl 22:08 skrev Jakub Kicinski:
> > On Fri, 20 Jul 2018 10:18:21 -0700, Martin KaFai Lau wrote:
> > > On Sat, Jul 21, 2018 at 01:04:45AM +0900, Taehee Yoo wrote:
> > > > rhashtable_lookup() can return NULL. so that NULL pointer
> > > > check routine should be added.
> > > >
> > > > Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")
> > > > Signed-off-by: Taehee Yoo <ap420073@gmail.com>
> > > > ---
> > > > net/core/xdp.c | 3 ++-
> > > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/net/core/xdp.c b/net/core/xdp.c
> > > > index 9d1f220..1c12bc7 100644
> > > > --- a/net/core/xdp.c
> > > > +++ b/net/core/xdp.c
> > > > @@ -345,7 +345,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
> > > > rcu_read_lock();
> > > > /* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */
> > > > xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
> > > > - xa->zc_alloc->free(xa->zc_alloc, handle);
> > > > + if (xa)
> > > > + xa->zc_alloc->free(xa->zc_alloc, handle);
> > > hmm...It is not clear to me the "!xa" case don't have to be handled?
> >
> > Actually I have a more fundamental question about this interface I've
> > been meaning to ask.
> >
> > IIUC free() can happen on any CPU at any time, when whatever device,
> > socket or CPU this got redirected to completed the TX. IOW there may
> > be multiple producers. Drivers would need to create spin lock a'la the
> > a9744f7ca200 ("xsk: fix potential race in SKB TX completion code") fix?
> >
>
> Jakub, apologies for the slow response. I'm still in
> "holiday/hammock&beer mode", but will be back in a week. :-P
Ah, sorry to interrupt! :)
> The idea with the xdp_return_* functions are that an xdp_buff and
> xdp_frame can have custom allocations schemes. The difference beween
> struct xdp_buff and struct xdp_frame is lifetime. The xdp_buff
> lifetime is within the napi context, whereas xdp_frame can have a
> lifetime longer/outside the napi context. E.g. for a XDP_REDIRECT
> scenario an xdp_buff is converted to a xdp_frame. The conversion is
> done in include/net/xdp.h:convert_to_xdp_frame.
>
> Currently, the zero-copy MEM_TYPE_ZERO_COPY memtype can *only* be used
> for xdp_buff, meaning that the lifetime is constrained to a napi
> context. Further, given an xdp_buff with memtype MEM_TYPE_ZERO_COPY,
> doing XDP_REDIRECT to a target that is *not* an AF_XDP socket would
> mean converting the xdp_buff to an xdp_frame. The xdp_frame can then
> be free'd on any CPU.
>
> Note that the xsk_rcv* functions is always called from an napi
> context, and therefore is using the xdp_return_buff calls.
>
> To answer your question -- no, this fix is *not* needed, because the
> xdp_buff napi constrained, and the xdp_buff will only be free'd on one
> CPU.
Oh, thanks, I missed the check in convert_to_xdp_frame(), so the only
frames which can come back via the free path are out of the error path
in __xsk_rcv_zc()?
That path looks a little surprising too, isn't the expectation that if
xdp_do_redirect() returns an error the driver retains the ownership of
the buffer?
static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
{
int err = xskq_produce_batch_desc(xs->rx, (u64)xdp->handle, len);
if (err) {
xdp_return_buff(xdp);
xs->rx_dropped++;
}
return err;
}
This seems to call xdp_return_buff() *and* return an error.
> > We need some form of internal kernel circulation which would be MPSC.
> > I'm currently hacking up the XSK code to tell me whether the frame was
> > consumed by the correct XSK, and always clone the frame otherwise
> > (claiming to be the "traditional" MEM_TYPE_PAGE_ORDER0).
> >
> > I feel like I'm missing something about the code. Is redirect of
> > ZC/UMEM frame outside the xsk not possible and the only returns we will
> > see are from net/xdp/xsk.c? That would work, but I don't see such a
> > check. Help would be appreciated.
> >
>
> Right now, this is the case (refer to the TODO in
> convert_to_xdp_frame), i.e. you cannot redirect an ZC/UMEM allocated
> xdp_buff to a target that is not an xsk. This must, obviously, change
> so that an xdp_buff (of MEM_TYPE_ZERO_COPY) can be converted to an
> xdp_frame. The xdp_frame must be able to be free'd from multiple CPUs,
> so here the a more sophisticated allocation scheme is required.
>
> > Also the fact that XSK bufs can't be freed, only completed, adds to the
> > pain of implementing AF_XDP, we'd certainly need some form of "give
> > back the frame, but I may need it later" SPSC mechanism, otherwise
> > driver writers will have tough time. Unless, again, I'm missing
> > something about the code :)
> >
>
> Yup, moving the recycling scheme from driver to "generic" is a good
> idea! I need to finish up those i40e zerocopy patches first though...
Interesting, FWIW I wasn't necessarily thinking about full recycling,
although that would be the holy grail. Just a generic way of giving up
buffers for example when user changes ring sizes or brings the device
down.
> (...and I'm very excited that you're doing nfp support for AF_XDP!!!)
Thanks, I'm still way out in the weeds but it's interesting work :)
^ permalink raw reply
* [PATCH v4 net-next 0/8] lan743x: Add features to lan743x driver
From: Bryan Whitehead @ 2018-07-23 20:16 UTC (permalink / raw)
To: davem; +Cc: netdev, UNGLinuxDriver
This patch series adds extra features to the lan743x driver.
Updates for v4:
Patch 6/8 - Modified get/set_wol to use super set of
MAC and PHY driver support.
Patch 7/9 - In set_eee, return the return value from phy_ethtool_set_eee.
Updates for v3:
Removed patch 9 from this series, regarding PTP support
Patch 6/8 - Add call to phy_ethtool_get_wol to lan743x_ethtool_get_wol
Patch 7/8 - Add call to phy_ethtool_set_eee on (!eee->eee_enabled)
Updates for v2:
Patch 3/9 - Used ARRAY_SIZE macro in lan743x_ethtool_get_ethtool_stats.
Patch 5/9 - Used MAX_EEPROM_SIZE in lan743x_ethtool_set_eeprom.
Patch 6/9 - Removed unnecessary read of PMT_CTL.
Used CRC algorithm from lib.
Removed PHY interrupt settings from lan743x_pm_suspend
Change "#if CONFIG_PM" to "#ifdef CONFIG_PM"
Bryan Whitehead (8):
lan743x: Add support for ethtool get_drvinfo
lan743x: Add support for ethtool link settings
lan743x: Add support for ethtool statistics
lan743x: Add support for ethtool message level
lan743x: Add support for ethtool eeprom access
lan743x: Add power management support
lan743x: Add EEE support
lan743x: Add RSS support
drivers/net/ethernet/microchip/Makefile | 2 +-
drivers/net/ethernet/microchip/lan743x_ethtool.c | 696 +++++++++++++++++++++++
drivers/net/ethernet/microchip/lan743x_ethtool.h | 11 +
drivers/net/ethernet/microchip/lan743x_main.c | 204 ++++++-
drivers/net/ethernet/microchip/lan743x_main.h | 133 +++++
5 files changed, 1042 insertions(+), 4 deletions(-)
create mode 100644 drivers/net/ethernet/microchip/lan743x_ethtool.c
create mode 100644 drivers/net/ethernet/microchip/lan743x_ethtool.h
--
2.7.4
^ permalink raw reply
* [PATCH v4 net-next 1/8] lan743x: Add support for ethtool get_drvinfo
From: Bryan Whitehead @ 2018-07-23 20:16 UTC (permalink / raw)
To: davem; +Cc: netdev, UNGLinuxDriver
In-Reply-To: <1532376993-20765-1-git-send-email-Bryan.Whitehead@microchip.com>
Implement ethtool get_drvinfo
Signed-off-by: Bryan Whitehead <Bryan.Whitehead@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/ethernet/microchip/Makefile | 2 +-
drivers/net/ethernet/microchip/lan743x_ethtool.c | 21 +++++++++++++++++++++
drivers/net/ethernet/microchip/lan743x_ethtool.h | 11 +++++++++++
drivers/net/ethernet/microchip/lan743x_main.c | 2 ++
4 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ethernet/microchip/lan743x_ethtool.c
create mode 100644 drivers/net/ethernet/microchip/lan743x_ethtool.h
diff --git a/drivers/net/ethernet/microchip/Makefile b/drivers/net/ethernet/microchip/Makefile
index 2e982cc..43f47cb 100644
--- a/drivers/net/ethernet/microchip/Makefile
+++ b/drivers/net/ethernet/microchip/Makefile
@@ -6,4 +6,4 @@ obj-$(CONFIG_ENC28J60) += enc28j60.o
obj-$(CONFIG_ENCX24J600) += encx24j600.o encx24j600-regmap.o
obj-$(CONFIG_LAN743X) += lan743x.o
-lan743x-objs := lan743x_main.o
+lan743x-objs := lan743x_main.o lan743x_ethtool.o
diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c b/drivers/net/ethernet/microchip/lan743x_ethtool.c
new file mode 100644
index 0000000..0e20758
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan743x_ethtool.c
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* Copyright (C) 2018 Microchip Technology Inc. */
+
+#include <linux/netdevice.h>
+#include "lan743x_main.h"
+#include "lan743x_ethtool.h"
+#include <linux/pci.h>
+
+static void lan743x_ethtool_get_drvinfo(struct net_device *netdev,
+ struct ethtool_drvinfo *info)
+{
+ struct lan743x_adapter *adapter = netdev_priv(netdev);
+
+ strlcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
+ strlcpy(info->bus_info,
+ pci_name(adapter->pdev), sizeof(info->bus_info));
+}
+
+const struct ethtool_ops lan743x_ethtool_ops = {
+ .get_drvinfo = lan743x_ethtool_get_drvinfo,
+};
diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.h b/drivers/net/ethernet/microchip/lan743x_ethtool.h
new file mode 100644
index 0000000..d0d11a7
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan743x_ethtool.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* Copyright (C) 2018 Microchip Technology Inc. */
+
+#ifndef _LAN743X_ETHTOOL_H
+#define _LAN743X_ETHTOOL_H
+
+#include "linux/ethtool.h"
+
+extern const struct ethtool_ops lan743x_ethtool_ops;
+
+#endif /* _LAN743X_ETHTOOL_H */
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index e1747a4..ade3b04 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -12,6 +12,7 @@
#include <linux/rtnetlink.h>
#include <linux/iopoll.h>
#include "lan743x_main.h"
+#include "lan743x_ethtool.h"
static void lan743x_pci_cleanup(struct lan743x_adapter *adapter)
{
@@ -2689,6 +2690,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
goto cleanup_hardware;
adapter->netdev->netdev_ops = &lan743x_netdev_ops;
+ adapter->netdev->ethtool_ops = &lan743x_ethtool_ops;
adapter->netdev->features = NETIF_F_SG | NETIF_F_TSO | NETIF_F_HW_CSUM;
adapter->netdev->hw_features = adapter->netdev->features;
--
2.7.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox