Netdev List
 help / color / mirror / Atom feed
* Re: Linux 5.4 - bpf test build fails
From: Shuah Khan @ 2019-09-24 18:56 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Yonghong Song, Alexei Starovoitov,
	open list:KERNEL SELFTEST FRAMEWORK, bpf, Networking,
	David S. Miller, Andrii Nakryiko, Shuah Khan
In-Reply-To: <20190924184946.GB5889@pc-63.home>

On 9/24/19 12:49 PM, Daniel Borkmann wrote:
> On Tue, Sep 24, 2019 at 09:48:35AM -0600, Shuah Khan wrote:
>> On 9/24/19 9:43 AM, Yonghong Song wrote:
>>> On 9/24/19 8:26 AM, Shuah Khan wrote:
>>>> Hi Alexei and Daniel,
>>>>
>>>> bpf test doesn't build on Linux 5.4 mainline. Do you know what's
>>>> happening here.
>>>>
>>>> make -C tools/testing/selftests/bpf/
>>>>
>>>> -c progs/test_core_reloc_ptr_as_arr.c -o - || echo "clang failed") | \
>>>> llc -march=bpf -mcpu=generic  -filetype=obj -o
>>>> /mnt/data/lkml/linux_5.4/tools/testing/selftests/bpf/test_core_reloc_ptr_as_arr.o
>>>>
>>>> progs/test_core_reloc_ptr_as_arr.c:25:6: error: use of unknown builtin
>>>>          '__builtin_preserve_access_index' [-Wimplicit-function-declaration]
>>>>            if (BPF_CORE_READ(&out->a, &in[2].a))
>>>>                ^
>>>> ./bpf_helpers.h:533:10: note: expanded from macro 'BPF_CORE_READ'
>>>>                           __builtin_preserve_access_index(src))
>>>>                           ^
>>>> progs/test_core_reloc_ptr_as_arr.c:25:6: warning: incompatible integer to
>>>>          pointer conversion passing 'int' to parameter of type 'const void *'
>>>>          [-Wint-conversion]
>>>>            if (BPF_CORE_READ(&out->a, &in[2].a))
>>>>                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> ./bpf_helpers.h:533:10: note: expanded from macro 'BPF_CORE_READ'
>>>>                           __builtin_preserve_access_index(src))
>>>>                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> 1 warning and 1 error generated.
>>>> llc: error: llc: <stdin>:1:1: error: expected top-level entity
>>>> clang failed
>>>>
>>>> Also
>>>>
>>>> make TARGETS=bpf kselftest fails as well. Dependency between
>>>> tools/lib/bpf and the test. How can we avoid this type of
>>>> dependency or resolve it in a way it doesn't result in build
>>>> failures?
>>>
>>> Thanks, Shuah.
>>>
>>> The clang __builtin_preserve_access_index() intrinsic is
>>> introduced in LLVM9 (which just released last week) and
>>> the builtin and other CO-RE features are only supported
>>> in LLVM10 (current development branch) with more bug fixes
>>> and added features.
>>>
>>> I think we should do a feature test for llvm version and only
>>> enable these tests when llvm version >= 10.
>>
>> Yes. If new tests depend on a particular llvm revision, the failing
>> the build is a regression. I would like to see older tests that don't
>> have dependency build and run.
> 
> So far we haven't made it a requirement as majority of BPF contributors
> that would run/add tests in here are also on bleeding edge LLVM anyway
> and other CIs like 0-day bot have simply upgraded their LLVM version
> from git whenever there was a failure similar to the one here so its
> ensured that really /all/ test cases are running and nothing would be
> skipped. There is worry to some degree that CIs just keep sticking to
> an old compiler since tests "just" pass and regressions wouldn't be
> caught on new releases for those that are skipped. >

Sure. Bleeding edge is developer mode. We still have to be concerned
about users that might not upgrade quickly.

> That said, for the C based tests, it should actually be straight forward
> to categorize them based on built-in macros like ...
> 
> $ echo | clang -dM -E -
> [...]
> #define __clang_major__ 10
> #define __clang_minor__ 0
> [...]
> 

What would nice running the tests you can run and then say some tests
aren't going to run. Is this something you can support?

> ... given there is now also bpf-gcc, the test matrix gets bigger anyway,
> so it might be worth rethinking to run the suite multiple times with
> different major llvm{,gcc} versions at some point to make sure their
> generated BPF bytecode keeps passing the verifier, and yell loudly if
> newer features had to be skipped due to lack of recent compiler version.
> This would be a super set of /just/ skipping tests and improve coverage
> at the same time.
> 

Probably. Reality is most users will just quit and add bpf to "hard to
run category" of tests.

thanks,
-- Shuah


^ permalink raw reply

* Re: [PATCH] kcm: use BPF_PROG_RUN
From: Daniel Borkmann @ 2019-09-24 18:59 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alexei Starovoitov, Yonghong Song, Sami Tolvanen, David S. Miller,
	Tom Herbert, netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org
In-Reply-To: <048e82f4-5b31-f9f4-5bf7-82dfbf7ec8f3@gmail.com>

On Mon, Sep 23, 2019 at 02:31:04PM -0700, Eric Dumazet wrote:
> On 9/6/19 10:06 AM, Alexei Starovoitov wrote:
> > On Fri, Sep 6, 2019 at 3:03 AM Yonghong Song <yhs@fb.com> wrote:
> >> On 9/5/19 2:15 PM, Sami Tolvanen wrote:
> >>> Instead of invoking struct bpf_prog::bpf_func directly, use the
> >>> BPF_PROG_RUN macro.
> >>>
> >>> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> >>
> >> Acked-by: Yonghong Song <yhs@fb.com>
> > 
> > Applied. Thanks
> 
> Then we probably need this as well, what do you think ?

Yep, it's broken. 6cab5e90ab2b ("bpf: run bpf programs with preemption
disabled") probably forgot about it since it wasn't using BPF_PROG_RUN()
in the first place. If you get a chance, please send a proper patch,
thanks!

> diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
> index 8f12f5c6ab875ebaa6c59c6268c337919fb43bb9..6508e88efdaf57f206b84307f5ad5915a2ed21f7 100644
> --- a/net/kcm/kcmsock.c
> +++ b/net/kcm/kcmsock.c
> @@ -378,8 +378,13 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
>  {
>         struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
>         struct bpf_prog *prog = psock->bpf_prog;
> +       int res;
>  
> -       return BPF_PROG_RUN(prog, skb);
> +       preempt_disable();
> +       res = BPF_PROG_RUN(prog, skb);
> +       preempt_enable();
> +
> +       return res;
>  }
>  
>  static int kcm_read_sock_done(struct strparser *strp, int err)

^ permalink raw reply

* Re: [PATCH] kcm: use BPF_PROG_RUN
From: Eric Dumazet @ 2019-09-24 19:17 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Alexei Starovoitov, Yonghong Song, Sami Tolvanen, David S. Miller,
	Tom Herbert, netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org
In-Reply-To: <20190924185908.GC5889@pc-63.home>



On 9/24/19 11:59 AM, Daniel Borkmann wrote:
> On Mon, Sep 23, 2019 at 02:31:04PM -0700, Eric Dumazet wrote:
>> On 9/6/19 10:06 AM, Alexei Starovoitov wrote:
>>> On Fri, Sep 6, 2019 at 3:03 AM Yonghong Song <yhs@fb.com> wrote:
>>>> On 9/5/19 2:15 PM, Sami Tolvanen wrote:
>>>>> Instead of invoking struct bpf_prog::bpf_func directly, use the
>>>>> BPF_PROG_RUN macro.
>>>>>
>>>>> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
>>>>
>>>> Acked-by: Yonghong Song <yhs@fb.com>
>>>
>>> Applied. Thanks
>>
>> Then we probably need this as well, what do you think ?
> 
> Yep, it's broken. 6cab5e90ab2b ("bpf: run bpf programs with preemption
> disabled") probably forgot about it since it wasn't using BPF_PROG_RUN()
> in the first place. If you get a chance, please send a proper patch,
> thanks!

Sure, I will send this today.


^ permalink raw reply

* Re: Linux 5.4 - bpf test build fails
From: Daniel Borkmann @ 2019-09-24 19:19 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Yonghong Song, Alexei Starovoitov,
	open list:KERNEL SELFTEST FRAMEWORK, bpf, Networking,
	David S. Miller, Andrii Nakryiko
In-Reply-To: <edb38c06-a75f-89df-60cd-d9d2de1879d6@linuxfoundation.org>

On Tue, Sep 24, 2019 at 12:56:53PM -0600, Shuah Khan wrote:
> On 9/24/19 12:49 PM, Daniel Borkmann wrote:
> > On Tue, Sep 24, 2019 at 09:48:35AM -0600, Shuah Khan wrote:
> > > On 9/24/19 9:43 AM, Yonghong Song wrote:
> > > > On 9/24/19 8:26 AM, Shuah Khan wrote:
> > > > > Hi Alexei and Daniel,
> > > > > 
> > > > > bpf test doesn't build on Linux 5.4 mainline. Do you know what's
> > > > > happening here.
> > > > > 
> > > > > make -C tools/testing/selftests/bpf/
> > > > > 
> > > > > -c progs/test_core_reloc_ptr_as_arr.c -o - || echo "clang failed") | \
> > > > > llc -march=bpf -mcpu=generic  -filetype=obj -o
> > > > > /mnt/data/lkml/linux_5.4/tools/testing/selftests/bpf/test_core_reloc_ptr_as_arr.o
> > > > > 
> > > > > progs/test_core_reloc_ptr_as_arr.c:25:6: error: use of unknown builtin
> > > > >          '__builtin_preserve_access_index' [-Wimplicit-function-declaration]
> > > > >            if (BPF_CORE_READ(&out->a, &in[2].a))
> > > > >                ^
> > > > > ./bpf_helpers.h:533:10: note: expanded from macro 'BPF_CORE_READ'
> > > > >                           __builtin_preserve_access_index(src))
> > > > >                           ^
> > > > > progs/test_core_reloc_ptr_as_arr.c:25:6: warning: incompatible integer to
> > > > >          pointer conversion passing 'int' to parameter of type 'const void *'
> > > > >          [-Wint-conversion]
> > > > >            if (BPF_CORE_READ(&out->a, &in[2].a))
> > > > >                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > ./bpf_helpers.h:533:10: note: expanded from macro 'BPF_CORE_READ'
> > > > >                           __builtin_preserve_access_index(src))
> > > > >                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > 1 warning and 1 error generated.
> > > > > llc: error: llc: <stdin>:1:1: error: expected top-level entity
> > > > > clang failed
> > > > > 
> > > > > Also
> > > > > 
> > > > > make TARGETS=bpf kselftest fails as well. Dependency between
> > > > > tools/lib/bpf and the test. How can we avoid this type of
> > > > > dependency or resolve it in a way it doesn't result in build
> > > > > failures?
> > > > 
> > > > Thanks, Shuah.
> > > > 
> > > > The clang __builtin_preserve_access_index() intrinsic is
> > > > introduced in LLVM9 (which just released last week) and
> > > > the builtin and other CO-RE features are only supported
> > > > in LLVM10 (current development branch) with more bug fixes
> > > > and added features.
> > > > 
> > > > I think we should do a feature test for llvm version and only
> > > > enable these tests when llvm version >= 10.
> > > 
> > > Yes. If new tests depend on a particular llvm revision, the failing
> > > the build is a regression. I would like to see older tests that don't
> > > have dependency build and run.
> > 
> > So far we haven't made it a requirement as majority of BPF contributors
> > that would run/add tests in here are also on bleeding edge LLVM anyway
> > and other CIs like 0-day bot have simply upgraded their LLVM version
> > from git whenever there was a failure similar to the one here so its
> > ensured that really /all/ test cases are running and nothing would be
> > skipped. There is worry to some degree that CIs just keep sticking to
> > an old compiler since tests "just" pass and regressions wouldn't be
> > caught on new releases for those that are skipped. >
> 
> Sure. Bleeding edge is developer mode. We still have to be concerned
> about users that might not upgrade quickly.
> 
> > That said, for the C based tests, it should actually be straight forward
> > to categorize them based on built-in macros like ...
> > 
> > $ echo | clang -dM -E -
> > [...]
> > #define __clang_major__ 10
> > #define __clang_minor__ 0
> > [...]
> 
> What would nice running the tests you can run and then say some tests
> aren't going to run. Is this something you can support?

Once there is such infra in place, should be possible.

> > ... given there is now also bpf-gcc, the test matrix gets bigger anyway,
> > so it might be worth rethinking to run the suite multiple times with
> > different major llvm{,gcc} versions at some point to make sure their
> > generated BPF bytecode keeps passing the verifier, and yell loudly if
> > newer features had to be skipped due to lack of recent compiler version.
> > This would be a super set of /just/ skipping tests and improve coverage
> > at the same time.
> 
> Probably. Reality is most users will just quit and add bpf to "hard to
> run category" of tests.

I don't really worry too much about such users at this point, more important
is that we have a way to test bpf-gcc and llvm behavior side by side to
make sure behavior is consistent and to have some sort of automated CI
integration that runs BPF kselftests before we even stare at a patch for
review. These are right now the two highest prio items from BPF testing
side where we need to get to.

Thanks,
Daniel

^ permalink raw reply

* RE: [PATCH v4 2/2] PTP: add support for one-shot output
From: Keller, Jacob E @ 2019-09-24 19:23 UTC (permalink / raw)
  To: Felipe Balbi, Richard Cochran
  Cc: Hall, Christopher S, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
In-Reply-To: <20190911061622.774006-2-felipe.balbi@linux.intel.com>



> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] On
> Behalf Of Felipe Balbi
> Sent: Tuesday, September 10, 2019 11:16 PM
> To: Richard Cochran <richardcochran@gmail.com>
> Cc: Hall, Christopher S <christopher.s.hall@intel.com>; netdev@vger.kernel.org;
> linux-kernel@vger.kernel.org; Felipe Balbi <felipe.balbi@linux.intel.com>
> Subject: [PATCH v4 2/2] PTP: add support for one-shot output
> 
> Some controllers allow for a one-shot output pulse, in contrast to
> periodic output. Now that we have extensible versions of our IOCTLs, we
> can finally make use of the 'flags' field to pass a bit telling driver
> that if we want one-shot pulse output.
> 
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> ---
> 
> Changes since v3:
> 	- Remove bogus bitwise negation
> 
> Changes since v2:
> 	- Add _PEROUT_ to bit macro
> 
> Changes since v1:
> 	- remove comment from .flags field
> 
>  include/uapi/linux/ptp_clock.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h
> index 9a0af3511b68..f16301015949 100644
> --- a/include/uapi/linux/ptp_clock.h
> +++ b/include/uapi/linux/ptp_clock.h
> @@ -38,8 +38,8 @@
>  /*
>   * Bits of the ptp_perout_request.flags field:
>   */
> -#define PTP_PEROUT_VALID_FLAGS (0)
> -
> +#define PTP_PEROUT_ONE_SHOT (1<<0)
> +#define PTP_PEROUT_VALID_FLAGS	(PTP_PEROUT_ONE_SHOT)
>  /*
>   * struct ptp_clock_time - represents a time value
>   *
> @@ -77,7 +77,7 @@ struct ptp_perout_request {
>  	struct ptp_clock_time start;  /* Absolute start time. */
>  	struct ptp_clock_time period; /* Desired period, zero means disable. */
>  	unsigned int index;           /* Which channel to configure. */
> -	unsigned int flags;           /* Reserved for future use. */
> +	unsigned int flags;
>  	unsigned int rsv[4];          /* Reserved for future use. */
>  };
> 
> --
> 2.23.0

Hi Felipe,

Do you have any examples for how you envision using this? I don't see any drivers or other code on the list for doing so.

Additionally, it seems weird because we do not have support for specifying the pulse width. I guess you leave that up to driver choice?

Thanks,
Jake

^ permalink raw reply

* [PATCH net] kcm: disable preemption in kcm_parse_func_strparser()
From: Eric Dumazet @ 2019-09-24 19:29 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: David S . Miller, netdev, Eric Dumazet, Eric Dumazet, bpf, syzbot

After commit a2c11b034142 ("kcm: use BPF_PROG_RUN")
syzbot easily triggers the warning in cant_sleep().

As explained in commit 6cab5e90ab2b ("bpf: run bpf programs
with preemption disabled") we need to disable preemption before
running bpf programs.

BUG: assuming atomic context at net/kcm/kcmsock.c:382
in_atomic(): 0, irqs_disabled(): 0, pid: 7, name: kworker/u4:0
3 locks held by kworker/u4:0/7:
 #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: __write_once_size include/linux/compiler.h:226 [inline]
 #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
 #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: atomic64_set include/asm-generic/atomic-instrumented.h:855 [inline]
 #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: atomic_long_set include/asm-generic/atomic-long.h:40 [inline]
 #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: set_work_data kernel/workqueue.c:620 [inline]
 #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:647 [inline]
 #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: process_one_work+0x88b/0x1740 kernel/workqueue.c:2240
 #1: ffff8880a989fdc0 ((work_completion)(&strp->work)){+.+.}, at: process_one_work+0x8c1/0x1740 kernel/workqueue.c:2244
 #2: ffff888098998d10 (sk_lock-AF_INET){+.+.}, at: lock_sock include/net/sock.h:1522 [inline]
 #2: ffff888098998d10 (sk_lock-AF_INET){+.+.}, at: strp_sock_lock+0x2e/0x40 net/strparser/strparser.c:440
CPU: 0 PID: 7 Comm: kworker/u4:0 Not tainted 5.3.0+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: kstrp strp_work
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 __cant_sleep kernel/sched/core.c:6826 [inline]
 __cant_sleep.cold+0xa4/0xbc kernel/sched/core.c:6803
 kcm_parse_func_strparser+0x54/0x200 net/kcm/kcmsock.c:382
 __strp_recv+0x5dc/0x1b20 net/strparser/strparser.c:221
 strp_recv+0xcf/0x10b net/strparser/strparser.c:343
 tcp_read_sock+0x285/0xa00 net/ipv4/tcp.c:1639
 strp_read_sock+0x14d/0x200 net/strparser/strparser.c:366
 do_strp_work net/strparser/strparser.c:414 [inline]
 strp_work+0xe3/0x130 net/strparser/strparser.c:423
 process_one_work+0x9af/0x1740 kernel/workqueue.c:2269

Fixes: a2c11b034142 ("kcm: use BPF_PROG_RUN")
Fixes: 6cab5e90ab2b ("bpf: run bpf programs with preemption disabled")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
---
 net/kcm/kcmsock.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 8f12f5c6ab875ebaa6c59c6268c337919fb43bb9..ea9e73428ed9c8b7bb3441947151c41f0c099185 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -378,8 +378,12 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
 {
 	struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
 	struct bpf_prog *prog = psock->bpf_prog;
+	int res;
 
-	return BPF_PROG_RUN(prog, skb);
+	preempt_disable();
+	res = BPF_PROG_RUN(prog, skb);
+	preempt_enable();
+	return res;
 }
 
 static int kcm_read_sock_done(struct strparser *strp, int err)
-- 
2.23.0.351.gc4317032e6-goog


^ permalink raw reply related

* Re: [PATCH net] bpf/xskmap: Return ERR_PTR for failure case instead of NULL.
From: Björn Töpel @ 2019-09-24 19:30 UTC (permalink / raw)
  To: Jonathan Lemon, daniel, netdev, Alexei Starovoitov
  Cc: kernel-team, bpf, Karlsson, Magnus, syzkaller-bugs,
	syzbot+491c1b7565ba9069ecae
In-Reply-To: <20190924162521.1630419-1-jonathan.lemon@gmail.com>

On 2019-09-24 18:25, Jonathan Lemon wrote:
> When kzalloc() failed, NULL was returned to the caller, which
> tested the pointer with IS_ERR(), which didn't match, so the
> pointer was used later, resulting in a NULL dereference.
> 
> Return ERR_PTR(-ENOMEM) instead of NULL.
> 
> Reported-by: syzbot+491c1b7565ba9069ecae@syzkaller.appspotmail.com
> Fixes: 0402acd683c6 ("xsk: remove AF_XDP socket from map when the socket is released")
> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>

Thanks Jonathan! You beat me to it! :-P

Acked-by: Björn Töpel <bjorn.topel@intel.com>

> ---
>   kernel/bpf/xskmap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
> index 942c662e2eed..82a1ffe15dfa 100644
> --- a/kernel/bpf/xskmap.c
> +++ b/kernel/bpf/xskmap.c
> @@ -37,7 +37,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
>   
>   	node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
>   	if (!node)
> -		return NULL;
> +		return ERR_PTR(-ENOMEM);
>   
>   	err = xsk_map_inc(map);
>   	if (err) {
> 

^ permalink raw reply

* Re: [PATCHv2 iproute2 master] bpf: Fix race condition with map pinning
From: Stephen Hemminger @ 2019-09-24 19:32 UTC (permalink / raw)
  To: Joe Stringer; +Cc: netdev, daniel
In-Reply-To: <20190920020447.29119-1-joe@wand.net.nz>

On Thu, 19 Sep 2019 19:04:47 -0700
Joe Stringer <joe@wand.net.nz> wrote:

> If two processes attempt to invoke bpf_map_attach() at the same time,
> then they will both create maps, then the first will successfully pin
> the map to the filesystem and the second will not pin the map, but will
> continue operating with a reference to its own copy of the map. As a
> result, the sharing of the same map will be broken from the two programs
> that were concurrently loaded via loaders using this library.
> 
> Fix this by adding a retry in the case where the pinning fails because
> the map already exists on the filesystem. In that case, re-attempt
> opening a fd to the map on the filesystem as it shows that another
> program already created and pinned a map at that location.
> 
> Signed-off-by: Joe Stringer <joe@wand.net.nz>

Thanks, I put this in as last patch for 5.3.

^ permalink raw reply

* Re: [PATCH] net-icmp: remove ping_group_range sysctl
From: David Miller @ 2019-09-24 19:33 UTC (permalink / raw)
  To: zenczykowski; +Cc: netdev, keescook, dvyukov, edumazet, maheshb, lorenzo
In-Reply-To: <CANP3RGeZaGD5JLw4VCLXe_6qmrGRLjROJuUNwbysq_1BhNbKOg@mail.gmail.com>

From: Maciej Żenczykowski <zenczykowski@gmail.com>
Date: Tue, 24 Sep 2019 16:47:00 +0200

>> Removing this is going to break things, you can't just remove a sysctl
>> because "oh it was a bad idea to add this, sorry."
> 
> Yeah, I know... but do you have any other suggestions?
> 
> Would you take an alternative to make the default wide opened?

This also could break things.

The horse has left the barn on this one.

> Perhaps having it as a non-namespace aware global setting (with a
> default of on) would be more palatable?

Also could break things.

You're going to have to change this in a way such that the administrator
has to explicitly ask for the new behavior.

^ permalink raw reply

* [ANNOUNCE] iproute2 5.3 release
From: Stephen Hemminger @ 2019-09-24 19:36 UTC (permalink / raw)
  To: netdev

The 5.3 kernel has been released, and the last patches have
been applied to iproute2.

This update includes usual ammount of minor fixes and to tools and
documentation. More to the newer tools like devlink and rdma.

Download:
    https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-5.3.0.tar.gz

Repository for upcoming release:
    git://git.kernel.org/pub/scm/network/iproute2/iproute2.git

And future release (net-next):
    git://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git

Thanks for all the contributions.

Report problems (or enhancements) to the netdev@vger.kernel.org mailing list.

---
Andrea Claudi (8):
      Makefile: use make -C to change directory
      utils: move parse_percent() to tc_util
      ip-route: fix json formatting for metrics
      tc: util: constrain percentage in 0-100 interval
      Revert "ip6tunnel: fix 'ip -6 {show|change} dev <name>' cmds"
      ip tunnel: warn when changing IPv6 tunnel without tunnel name
      devlink: fix segfault on health command
      man: ss.8: add documentation for drop counter

Antonio Borneo (1):
      iplink_can: fix format output of clock with flag -details

Aya Levin (3):
      devlink: Change devlink health dump show command to dumpit
      devlink: Fix binary values print
      devlink: Remove enclosing array brackets binary print with json format

David Ahern (20):
      Update kernel headers and add asm-generic/sockios.h
      Update kernel headers
      Update kernel headers
      uapi: Import tc_ctinfo uapi
      libnetlink: Set NLA_F_NESTED in rta_nest
      lwtunnel: Pass encap and encap_type attributes to lwt_parse_encap
      libnetlink: Add helper to add a group via setsockopt
      uapi: Import nexthop object API
      libnetlink: Add helper to create nexthop dump request
      ip route: Export print_rt_flags, print_rta_if and print_rta_gateway
      Add support for nexthop objects
      ip: Add man page for nexthop command
      ip route: Add option to use nexthop objects
      ipmonitor: Add nexthop option to monitor
      tools: Fix include path for generate_nlmsg
      Update kernel headers
      ss: Change resolve_services to numeric
      Update kernel headers
      Import tc_mpls.h uapi header
      nexthop: Add space after blackhole

Denis Kirjanov (1):
      ipaddress: correctly print a VF hw address in the IPoIB case

Donald Sharp (1):
      ip nexthop: Add space to display properly when showing a group

Hangbin Liu (1):
      ip: add a new parameter -Numeric

Hoang Le (1):
      tipc: support interface name when activating UDP bearer

Ido Schimmel (1):
      tc: Fix block-handle support for filter operations

Ivan Delalande (1):
      json: fix backslash escape typo in jsonw_puts

Jakub Kicinski (1):
      tc: q_netem: JSON-ify the output

Jiri Pirko (1):
      devlink: finish queue.h to list.h transition

Joe Stringer (1):
      bpf: Fix race condition with map pinning

John Hurley (3):
      lib: add mpls_uc and mpls_mc as link layer protocol names
      tc: add mpls actions
      man: update man pages for TC MPLS actions

Kevin Darbyshire-Bryant (1):
      tc: add support for action act_ctinfo

Kurt Kanzenbach (1):
      utils: Fix get_s64() function

Mark Zhang (8):
      rdma: Add "stat qp show" support
      rdma: Add get per-port counter mode support
      rdma: Add rdma statistic counter per-port auto mode support
      rdma: Make get_port_from_argv() returns valid port in strict port mode
      rdma: Add stat manual mode support
      rdma: Add default counter show support
      rdma: Document counter statistic
      rdma: Check comm string before print in print_comm()

Matteo Croce (2):
      treewide: refactor help messages
      utils: don't match empty strings as prefixes

Nicolas Dichtel (1):
      link_xfrm: don't force to set phydev

Parav Pandit (6):
      rdma: Add an option to query,set net namespace sharing sys parameter
      rdma: Add man pages for rdma system commands
      rdma: Add an option to set net namespace of rdma device
      rdma: Add man page for rdma dev set netns command
      devlink: Show devlink port number
      devlink: Introduce PCI PF and VF port flavour and attribute

Patrick Talbert (2):
      ss: sctp: fix typo for nodelay
      ss: sctp: Formatting tweak in sctp_show_info for locals

Roman Mashak (2):
      tc: added mask parameter in skbedit action
      tc: document 'mask' parameter in skbedit man page

Sergei Trofimovich (1):
      iproute2: devlink: port from sys/queue.h to list.h

Stephen Hemminger (18):
      tc: print all error messages to stderr
      uapi: fix bpf.h link
      uapi: update uapi/magic.h
      uapi: rdma netlink.h update
      uapi: fix bpf comment typo
      uapi: update kernel headers from 5.3-rc1
      iplink: document 'change' option to ip link
      json_print: drop extra semi-colons
      Revert "tc: Remove pointless assignments in batch()"
      Revert "tc: flush after each command in batch mode"
      Revert "tc: fix batch force option"
      Revert "tc: Add batchsize feature for filter and actions"
      tc: fflush after each command in batch mode
      uapi: update socket.h
      tc: fix spelling errors
      lib: fix spelling errors
      uapi: update bpf.h header
      v5.3.0

Vincent Bernat (1):
      ip: bond: add peer notification delay support

Yamin Friedman (2):
      rdma: Control CQ adaptive moderation (DIM)
      rdma: Document adaptive-moderation


^ permalink raw reply

* Re: [PATCH v3 0/2] net: stmmac: Enhanced addressing mode for DWMAC 4.10
From: David Miller @ 2019-09-24 19:45 UTC (permalink / raw)
  To: thierry.reding
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, f.fainelli, jonathanh,
	bbiswas, netdev, linux-tegra
In-Reply-To: <20190920170036.22610-1-thierry.reding@gmail.com>

From: Thierry Reding <thierry.reding@gmail.com>
Date: Fri, 20 Sep 2019 19:00:34 +0200

> From: Thierry Reding <treding@nvidia.com>
> 
> The DWMAC 4.10 supports the same enhanced addressing mode as later
> generations. Parse this capability from the hardware feature registers
> and set the EAME (Enhanced Addressing Mode Enable) bit when necessary.

This looks like an enhancement and/or optimization rather than a bug fix.

Also, you're now writing to the high 32-bits unconditionally, even when
it will always be zero because of 32-bit addressing.  That looks like
a step backwards to me.

I'm not applying this.

^ permalink raw reply

* Re: Linux 5.4 - bpf test build fails
From: Shuah Khan @ 2019-09-24 19:48 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Yonghong Song, Alexei Starovoitov,
	open list:KERNEL SELFTEST FRAMEWORK, bpf, Networking,
	David S. Miller, Andrii Nakryiko, skh >> Shuah Khan
In-Reply-To: <20190924191957.GD5889@pc-63.home>

On 9/24/19 1:19 PM, Daniel Borkmann wrote:
> On Tue, Sep 24, 2019 at 12:56:53PM -0600, Shuah Khan wrote:
>> On 9/24/19 12:49 PM, Daniel Borkmann wrote:
>>> On Tue, Sep 24, 2019 at 09:48:35AM -0600, Shuah Khan wrote:
>>>> On 9/24/19 9:43 AM, Yonghong Song wrote:
>>>>> On 9/24/19 8:26 AM, Shuah Khan wrote:
>>>>>> Hi Alexei and Daniel,
>>>>>>
>>>>>> bpf test doesn't build on Linux 5.4 mainline. Do you know what's
>>>>>> happening here.
>>>>>>
>>>>>> make -C tools/testing/selftests/bpf/
>>>>>>
>>>>>> -c progs/test_core_reloc_ptr_as_arr.c -o - || echo "clang failed") | \
>>>>>> llc -march=bpf -mcpu=generic  -filetype=obj -o
>>>>>> /mnt/data/lkml/linux_5.4/tools/testing/selftests/bpf/test_core_reloc_ptr_as_arr.o
>>>>>>
>>>>>> progs/test_core_reloc_ptr_as_arr.c:25:6: error: use of unknown builtin
>>>>>>           '__builtin_preserve_access_index' [-Wimplicit-function-declaration]
>>>>>>             if (BPF_CORE_READ(&out->a, &in[2].a))
>>>>>>                 ^
>>>>>> ./bpf_helpers.h:533:10: note: expanded from macro 'BPF_CORE_READ'
>>>>>>                            __builtin_preserve_access_index(src))
>>>>>>                            ^
>>>>>> progs/test_core_reloc_ptr_as_arr.c:25:6: warning: incompatible integer to
>>>>>>           pointer conversion passing 'int' to parameter of type 'const void *'
>>>>>>           [-Wint-conversion]
>>>>>>             if (BPF_CORE_READ(&out->a, &in[2].a))
>>>>>>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>> ./bpf_helpers.h:533:10: note: expanded from macro 'BPF_CORE_READ'
>>>>>>                            __builtin_preserve_access_index(src))
>>>>>>                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>> 1 warning and 1 error generated.
>>>>>> llc: error: llc: <stdin>:1:1: error: expected top-level entity
>>>>>> clang failed
>>>>>>
>>>>>> Also
>>>>>>
>>>>>> make TARGETS=bpf kselftest fails as well. Dependency between
>>>>>> tools/lib/bpf and the test. How can we avoid this type of
>>>>>> dependency or resolve it in a way it doesn't result in build
>>>>>> failures?
>>>>>
>>>>> Thanks, Shuah.
>>>>>
>>>>> The clang __builtin_preserve_access_index() intrinsic is
>>>>> introduced in LLVM9 (which just released last week) and
>>>>> the builtin and other CO-RE features are only supported
>>>>> in LLVM10 (current development branch) with more bug fixes
>>>>> and added features.
>>>>>
>>>>> I think we should do a feature test for llvm version and only
>>>>> enable these tests when llvm version >= 10.
>>>>
>>>> Yes. If new tests depend on a particular llvm revision, the failing
>>>> the build is a regression. I would like to see older tests that don't
>>>> have dependency build and run.
>>>
>>> So far we haven't made it a requirement as majority of BPF contributors
>>> that would run/add tests in here are also on bleeding edge LLVM anyway
>>> and other CIs like 0-day bot have simply upgraded their LLVM version
>>> from git whenever there was a failure similar to the one here so its
>>> ensured that really /all/ test cases are running and nothing would be
>>> skipped. There is worry to some degree that CIs just keep sticking to
>>> an old compiler since tests "just" pass and regressions wouldn't be
>>> caught on new releases for those that are skipped. >
>>
>> Sure. Bleeding edge is developer mode. We still have to be concerned
>> about users that might not upgrade quickly.
>>
>>> That said, for the C based tests, it should actually be straight forward
>>> to categorize them based on built-in macros like ...
>>>
>>> $ echo | clang -dM -E -
>>> [...]
>>> #define __clang_major__ 10
>>> #define __clang_minor__ 0
>>> [...]
>>
>> What would nice running the tests you can run and then say some tests
>> aren't going to run. Is this something you can support?
> 
> Once there is such infra in place, should be possible.

Can't you do it in bpf run-time or during build for dependency?
You should be able to handle this as a dependency and let users
know at least.

> 
>>> ... given there is now also bpf-gcc, the test matrix gets bigger anyway,
>>> so it might be worth rethinking to run the suite multiple times with
>>> different major llvm{,gcc} versions at some point to make sure their
>>> generated BPF bytecode keeps passing the verifier, and yell loudly if
>>> newer features had to be skipped due to lack of recent compiler version.
>>> This would be a super set of /just/ skipping tests and improve coverage
>>> at the same time.
>>
>> Probably. Reality is most users will just quit and add bpf to "hard to
>> run category" of tests.
> 
> I don't really worry too much about such users at this point, more important
> is that we have a way to test bpf-gcc and llvm behavior side by side to
> make sure behavior is consistent and to have some sort of automated CI
> integration that runs BPF kselftests before we even stare at a patch for
> review. These are right now the two highest prio items from BPF testing
> side where we need to get to.
> 

What happens if CI's can't upgrade quickly and newer versions aren't
supported on test machines that are in their test rings?

thanks,
-- Shuah


^ permalink raw reply

* [PATCH net] sch_netem: fix rcu splat in netem_enqueue()
From: Eric Dumazet @ 2019-09-24 20:11 UTC (permalink / raw)
  To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet, syzbot

qdisc_root() use from netem_enqueue() triggers a lockdep warning.

__dev_queue_xmit() uses rcu_read_lock_bh() which is
not equivalent to rcu_read_lock() + local_bh_disable_bh as far
as lockdep is concerned.

WARNING: suspicious RCU usage
5.3.0-rc7+ #0 Not tainted
-----------------------------
include/net/sch_generic.h:492 suspicious rcu_dereference_check() usage!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 1
3 locks held by syz-executor427/8855:
 #0: 00000000b5525c01 (rcu_read_lock_bh){....}, at: lwtunnel_xmit_redirect include/net/lwtunnel.h:92 [inline]
 #0: 00000000b5525c01 (rcu_read_lock_bh){....}, at: ip_finish_output2+0x2dc/0x2570 net/ipv4/ip_output.c:214
 #1: 00000000b5525c01 (rcu_read_lock_bh){....}, at: __dev_queue_xmit+0x20a/0x3650 net/core/dev.c:3804
 #2: 00000000364bae92 (&(&sch->q.lock)->rlock){+.-.}, at: spin_lock include/linux/spinlock.h:338 [inline]
 #2: 00000000364bae92 (&(&sch->q.lock)->rlock){+.-.}, at: __dev_xmit_skb net/core/dev.c:3502 [inline]
 #2: 00000000364bae92 (&(&sch->q.lock)->rlock){+.-.}, at: __dev_queue_xmit+0x14b8/0x3650 net/core/dev.c:3838

stack backtrace:
CPU: 0 PID: 8855 Comm: syz-executor427 Not tainted 5.3.0-rc7+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 lockdep_rcu_suspicious+0x153/0x15d kernel/locking/lockdep.c:5357
 qdisc_root include/net/sch_generic.h:492 [inline]
 netem_enqueue+0x1cfb/0x2d80 net/sched/sch_netem.c:479
 __dev_xmit_skb net/core/dev.c:3527 [inline]
 __dev_queue_xmit+0x15d2/0x3650 net/core/dev.c:3838
 dev_queue_xmit+0x18/0x20 net/core/dev.c:3902
 neigh_hh_output include/net/neighbour.h:500 [inline]
 neigh_output include/net/neighbour.h:509 [inline]
 ip_finish_output2+0x1726/0x2570 net/ipv4/ip_output.c:228
 __ip_finish_output net/ipv4/ip_output.c:308 [inline]
 __ip_finish_output+0x5fc/0xb90 net/ipv4/ip_output.c:290
 ip_finish_output+0x38/0x1f0 net/ipv4/ip_output.c:318
 NF_HOOK_COND include/linux/netfilter.h:294 [inline]
 ip_mc_output+0x292/0xf40 net/ipv4/ip_output.c:417
 dst_output include/net/dst.h:436 [inline]
 ip_local_out+0xbb/0x190 net/ipv4/ip_output.c:125
 ip_send_skb+0x42/0xf0 net/ipv4/ip_output.c:1555
 udp_send_skb.isra.0+0x6b2/0x1160 net/ipv4/udp.c:887
 udp_sendmsg+0x1e96/0x2820 net/ipv4/udp.c:1174
 inet_sendmsg+0x9e/0xe0 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2311
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2413
 __do_sys_sendmmsg net/socket.c:2442 [inline]
 __se_sys_sendmmsg net/socket.c:2439 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2439
 do_syscall_64+0xfd/0x6a0 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
---
 include/net/sch_generic.h | 5 +++++
 net/sched/sch_netem.c     | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 43f5b7ed02bdbad6f5dba54ba79b8f1b9d144d16..637548d54b3ee9bdb0edd10a1667e81a40a6ef74 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -494,6 +494,11 @@ static inline struct Qdisc *qdisc_root(const struct Qdisc *qdisc)
 	return q;
 }
 
+static inline struct Qdisc *qdisc_root_bh(const struct Qdisc *qdisc)
+{
+	return rcu_dereference_bh(qdisc->dev_queue->qdisc);
+}
+
 static inline struct Qdisc *qdisc_root_sleeping(const struct Qdisc *qdisc)
 {
 	return qdisc->dev_queue->qdisc_sleeping;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index f5cb35e550f8df557f2e444cc2fd142cab97789b..0e44039e729c72be52d0bf65568b3641e7f910d8 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -476,7 +476,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	 * skb will be queued.
 	 */
 	if (count > 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
-		struct Qdisc *rootq = qdisc_root(sch);
+		struct Qdisc *rootq = qdisc_root_bh(sch);
 		u32 dupsave = q->duplicate; /* prevent duplicating a dup... */
 
 		q->duplicate = 0;
-- 
2.23.0.351.gc4317032e6-goog


^ permalink raw reply related

* RE: [PATCH v4 2/2] PTP: add support for one-shot output
From: Hall, Christopher S @ 2019-09-24 20:23 UTC (permalink / raw)
  To: Keller, Jacob E, Felipe Balbi, Richard Cochran
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <02874ECE860811409154E81DA85FBB58968D24E2@ORSMSX121.amr.corp.intel.com>

> -----Original Message-----
> From: Keller, Jacob E
> Sent: Tuesday, September 24, 2019 12:23 PM
> To: Felipe Balbi <felipe.balbi@linux.intel.com>; Richard Cochran
> <richardcochran@gmail.com>
> Cc: Hall, Christopher S <christopher.s.hall@intel.com>;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: RE: [PATCH v4 2/2] PTP: add support for one-shot output
> 
> 
> 
> > -----Original Message-----
> > From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> On
> > Behalf Of Felipe Balbi
> > Sent: Tuesday, September 10, 2019 11:16 PM
> > To: Richard Cochran <richardcochran@gmail.com>
> > Cc: Hall, Christopher S <christopher.s.hall@intel.com>;
> netdev@vger.kernel.org;
> > linux-kernel@vger.kernel.org; Felipe Balbi
> <felipe.balbi@linux.intel.com>
> > Subject: [PATCH v4 2/2] PTP: add support for one-shot output
> >
> > Some controllers allow for a one-shot output pulse, in contrast to
> > periodic output. Now that we have extensible versions of our IOCTLs, we
> > can finally make use of the 'flags' field to pass a bit telling driver
> > that if we want one-shot pulse output.
> >
> > Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> > ---
> >
> > Changes since v3:
> > 	- Remove bogus bitwise negation
> >
> > Changes since v2:
> > 	- Add _PEROUT_ to bit macro
> >
> > Changes since v1:
> > 	- remove comment from .flags field
> >
> >  include/uapi/linux/ptp_clock.h | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/uapi/linux/ptp_clock.h
> b/include/uapi/linux/ptp_clock.h
> > index 9a0af3511b68..f16301015949 100644
> > --- a/include/uapi/linux/ptp_clock.h
> > +++ b/include/uapi/linux/ptp_clock.h
> > @@ -38,8 +38,8 @@
> >  /*
> >   * Bits of the ptp_perout_request.flags field:
> >   */
> > -#define PTP_PEROUT_VALID_FLAGS (0)
> > -
> > +#define PTP_PEROUT_ONE_SHOT (1<<0)
> > +#define PTP_PEROUT_VALID_FLAGS	(PTP_PEROUT_ONE_SHOT)
> >  /*
> >   * struct ptp_clock_time - represents a time value
> >   *
> > @@ -77,7 +77,7 @@ struct ptp_perout_request {
> >  	struct ptp_clock_time start;  /* Absolute start time. */
> >  	struct ptp_clock_time period; /* Desired period, zero means disable.
> */
> >  	unsigned int index;           /* Which channel to configure. */
> > -	unsigned int flags;           /* Reserved for future use. */
> > +	unsigned int flags;
> >  	unsigned int rsv[4];          /* Reserved for future use. */
> >  };
> >
> > --
> > 2.23.0
> 
> Hi Felipe,
> 
> Do you have any examples for how you envision using this? I don't see any
> drivers or other code on the list for doing so.
> 
> Additionally, it seems weird because we do not have support for specifying
> the pulse width. I guess you leave that up to driver choice?
> 
> Thanks,
> Jake

Jake,

Good catch on the terminology. This is an API that produces edges not pulses.
This flag causes the PEROUT ioctl to ignore the period argument and produce a
single edge. Currently, the igb driver implements the same function, but uses
a "magic" invalid period specification to signal that the period argument
should be ignored (use_freq == 0):

		if (on && ((ns <= 70000000LL) || (ns == 125000000LL) ||
			   (ns == 250000000LL) || (ns == 500000000LL))) {
			if (ns < 8LL)
				return -EINVAL;
			use_freq = 1;
		}

The proposal is to support this function without magic period specifications
using an explicit flag instead. An example use case is pulse-per-second
output. While PPS is periodic, time-aware GPIO is driven by (an
unadjustable) Always Running Timer (ART). It's necessary to schedule each
edge in software to produce PPS synced with system time.

Chris

^ permalink raw reply

* RE: [PATCH v4 2/2] PTP: add support for one-shot output
From: Keller, Jacob E @ 2019-09-24 21:16 UTC (permalink / raw)
  To: Hall, Christopher S, Felipe Balbi, Richard Cochran
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <B79D786B7111A34A8CF09F833429C493BCA528D5@ORSMSX109.amr.corp.intel.com>

> -----Original Message-----
> From: Hall, Christopher S
> Sent: Tuesday, September 24, 2019 1:24 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>; Felipe Balbi
> <felipe.balbi@linux.intel.com>; Richard Cochran <richardcochran@gmail.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: RE: [PATCH v4 2/2] PTP: add support for one-shot output
> 
> Good catch on the terminology. This is an API that produces edges not pulses.
> This flag causes the PEROUT ioctl to ignore the period argument and produce a
> single edge. Currently, the igb driver implements the same function, but uses
> a "magic" invalid period specification to signal that the period argument
> should be ignored (use_freq == 0):
> 
> 		if (on && ((ns <= 70000000LL) || (ns == 125000000LL) ||
> 			   (ns == 250000000LL) || (ns == 500000000LL))) {
> 			if (ns < 8LL)
> 				return -EINVAL;
> 			use_freq = 1;
> 		}

From my understanding, the use_freq = 0 is intended to perform a clock using the target time registers with an interrupt to re-trigger the next toggle.

If you use a frequency not supported by freqout, it will result in an interrupt that re-toggles the target time, not a single edge.

> 
> The proposal is to support this function without magic period specifications
> using an explicit flag instead. An example use case is pulse-per-second
> output. While PPS is periodic, time-aware GPIO is driven by (an
> unadjustable) Always Running Timer (ART). It's necessary to schedule each
> edge in software to produce PPS synced with system time.
> 
> Chris

Oh, so "one shot" will simply toggle the clock output once. I see.

So this won't really work for generating a pulse per second, and we would possibly still want an API for that?

Thanks,
Jake

^ permalink raw reply

* memory leak in copy_net_ns
From: syzbot @ 2019-09-24 21:29 UTC (permalink / raw)
  To: a.p.zijlstra, acme, andi, davem, dhowells, dsahern,
	jakub.kicinski, johannes.berg, jolsa, linux-kernel, namhyung,
	netdev, nicolas.dichtel, syzkaller-bugs, tyhicks, willy

Hello,

syzbot found the following crash on:

HEAD commit:    5ad18b2e Merge branch 'siginfo-linus' of git://git.kernel...
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1239e6a0600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=13fb75d3ba8bfd9
dashboard link: https://syzkaller.appspot.com/bug?extid=3b3296d032353c33184b
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=116c6a87a00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14587d10600000

The bug was bisected to:

commit 195bc0f8443d8d564ae95d2e9c19ac0edfd647c3
Author: Namhyung Kim <namhyung@kernel.org>
Date:   Tue Sep 13 07:45:50 2016 +0000

     perf ui/stdio: Rename print_hierarchy_header()

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=16162df0600000
final crash:    https://syzkaller.appspot.com/x/report.txt?x=15162df0600000
console output: https://syzkaller.appspot.com/x/log.txt?x=11162df0600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+3b3296d032353c33184b@syzkaller.appspotmail.com
Fixes: 195bc0f8443d ("perf ui/stdio: Rename print_hierarchy_header()")

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.400s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.390s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.220s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.220s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.470s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.460s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.290s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.290s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.550s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.540s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.370s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.370s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.620s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.610s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.440s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.440s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.690s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.680s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.510s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.510s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.760s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.750s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.580s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.580s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.840s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.830s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.660s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.660s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff8881175007e0 (size 32):
   comm "syz-executor902", pid 7069, jiffies 4294944350 (age 28.910s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811cfb2080 (size 96):
   comm "syz-executor902", pid 7069, jiffies 4294944351 (age 28.900s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 50 4d bc 82 ff ff ff ff  ........PM......
     00 00 00 00 00 00 00 00 00 39 bc 82 ff ff ff ff  .........9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740

BUG: memory leak
unreferenced object 0xffff888115e047c0 (size 32):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.730s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000a83ed741>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000a83ed741>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000a83ed741>] slab_alloc mm/slab.c:3326 [inline]
     [<00000000a83ed741>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
     [<0000000059fc92b9>] kmalloc include/linux/slab.h:547 [inline]
     [<0000000059fc92b9>] kzalloc include/linux/slab.h:742 [inline]
     [<0000000059fc92b9>] net_alloc net/core/net_namespace.c:398 [inline]
     [<0000000059fc92b9>] copy_net_ns+0xb2/0x220 net/core/net_namespace.c:445
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740
     [<00000000f4c5f2c8>] do_syscall_64+0x76/0x1a0  
arch/x86/entry/common.c:296
     [<0000000038550184>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811ccd4e80 (size 96):
   comm "syz-executor902", pid 7079, jiffies 4294944368 (age 28.730s)
   hex dump (first 32 bytes):
     02 00 00 00 00 00 00 00 c0 4d bc 82 ff ff ff ff  .........M......
     00 00 00 00 00 00 00 00 70 39 bc 82 ff ff ff ff  ........p9......
   backtrace:
     [<00000000b0b6ab9a>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000b0b6ab9a>] slab_post_alloc_hook mm/slab.h:439 [inline]
     [<00000000b0b6ab9a>] slab_alloc_node mm/slab.c:3269 [inline]
     [<00000000b0b6ab9a>] kmem_cache_alloc_node_trace+0x15b/0x2a0  
mm/slab.c:3597
     [<00000000f96917f7>] __do_kmalloc_node mm/slab.c:3619 [inline]
     [<00000000f96917f7>] __kmalloc_node+0x38/0x50 mm/slab.c:3627
     [<0000000032c54692>] kmalloc_node include/linux/slab.h:590 [inline]
     [<0000000032c54692>] kvmalloc_node+0x4a/0xd0 mm/util.c:431
     [<00000000cdbb5464>] kvmalloc include/linux/mm.h:648 [inline]
     [<00000000cdbb5464>] kvzalloc include/linux/mm.h:656 [inline]
     [<00000000cdbb5464>] allocate_hook_entries_size+0x3b/0x60  
net/netfilter/core.c:61
     [<00000000ca33d229>] nf_hook_entries_grow+0xae/0x270  
net/netfilter/core.c:128
     [<000000003b071c4d>] __nf_register_net_hook+0x9a/0x170  
net/netfilter/core.c:337
     [<00000000d9c14042>] nf_register_net_hook+0x34/0xc0  
net/netfilter/core.c:464
     [<000000004119a586>] nf_register_net_hooks+0x53/0xc0  
net/netfilter/core.c:480
     [<000000004957a648>] __ip_vs_init+0xe8/0x170  
net/netfilter/ipvs/ip_vs_core.c:2280
     [<0000000044bb7165>] ops_init+0x4c/0x160 net/core/net_namespace.c:137
     [<000000002d8e331b>] setup_net+0xde/0x230 net/core/net_namespace.c:323
     [<000000003547ad16>] copy_net_ns+0x123/0x220  
net/core/net_namespace.c:458
     [<00000000a9d74bbc>] create_new_namespaces+0x141/0x2a0  
kernel/nsproxy.c:103
     [<000000008047d645>] unshare_nsproxy_namespaces+0x7f/0x100  
kernel/nsproxy.c:202
     [<000000005993ea6e>] ksys_unshare+0x236/0x490 kernel/fork.c:2674
     [<0000000019417e75>] __do_sys_unshare kernel/fork.c:2742 [inline]
     [<0000000019417e75>] __se_sys_unshare kernel/fork.c:2740 [inline]
     [<0000000019417e75>] __x64_sys_unshare+0x16/0x20 kernel/fork.c:2740



---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

^ permalink raw reply

* Re: [PATCH] ieee802154: mcr20a: simplify a bit 'mcr20a_handle_rx_read_buf_complete()'
From: Xue Liu @ 2019-09-24 21:40 UTC (permalink / raw)
  To: Stefan Schmidt
  Cc: Christophe JAILLET, alex. aring, David S. Miller, linux-wpan - ML,
	netdev, linux-kernel, kernel-janitors
In-Reply-To: <388f335a-a9ae-7230-1713-a1ecb682fecf@datenfreihafen.org>

On Sat, 21 Sep 2019 at 13:52, Stefan Schmidt <stefan@datenfreihafen.org> wrote:
>
> Hello Xue.
>
> On 20.09.19 21:45, Christophe JAILLET wrote:
> > Use a 'skb_put_data()' variant instead of rewritting it.
> > The __skb_put_data variant is safe here. It is obvious that the skb can
> > not overflow. It has just been allocated a few lines above with the same
> > 'len'.
> >
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> >  drivers/net/ieee802154/mcr20a.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
> > index 17f2300e63ee..8dc04e2590b1 100644
> > --- a/drivers/net/ieee802154/mcr20a.c
> > +++ b/drivers/net/ieee802154/mcr20a.c
> > @@ -800,7 +800,7 @@ mcr20a_handle_rx_read_buf_complete(void *context)
> >       if (!skb)
> >               return;
> >
> > -     memcpy(skb_put(skb, len), lp->rx_buf, len);
> > +     __skb_put_data(skb, lp->rx_buf, len);
> >       ieee802154_rx_irqsafe(lp->hw, skb, lp->rx_lqi[0]);
> >
> >       print_hex_dump_debug("mcr20a rx: ", DUMP_PREFIX_OFFSET, 16, 1,
> >
>
> Could you please review and ACK this? If you are happy I will take it
> through my tree.
>
> regards
> Stefan Schmidt

Acked-by: Xue Liu <liuxuenetmail@gmail.com>

--

^ permalink raw reply

* RE: [PATCH v4 2/2] PTP: add support for one-shot output
From: Keller, Jacob E @ 2019-09-24 21:53 UTC (permalink / raw)
  To: Hall, Christopher S, Felipe Balbi, Richard Cochran
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <B79D786B7111A34A8CF09F833429C493BCA528D5@ORSMSX109.amr.corp.intel.com>



> -----Original Message-----
> From: Hall, Christopher S
> Sent: Tuesday, September 24, 2019 1:24 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>; Felipe Balbi
> <felipe.balbi@linux.intel.com>; Richard Cochran <richardcochran@gmail.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: RE: [PATCH v4 2/2] PTP: add support for one-shot output
> 
> > -----Original Message-----
> > From: Keller, Jacob E
> > Sent: Tuesday, September 24, 2019 12:23 PM
> > To: Felipe Balbi <felipe.balbi@linux.intel.com>; Richard Cochran
> > <richardcochran@gmail.com>
> > Cc: Hall, Christopher S <christopher.s.hall@intel.com>;
> > netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: RE: [PATCH v4 2/2] PTP: add support for one-shot output
> >
> >
> >
> > > -----Original Message-----
> > > From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> > On
> > > Behalf Of Felipe Balbi
> > > Sent: Tuesday, September 10, 2019 11:16 PM
> > > To: Richard Cochran <richardcochran@gmail.com>
> > > Cc: Hall, Christopher S <christopher.s.hall@intel.com>;
> > netdev@vger.kernel.org;
> > > linux-kernel@vger.kernel.org; Felipe Balbi
> > <felipe.balbi@linux.intel.com>
> > > Subject: [PATCH v4 2/2] PTP: add support for one-shot output
> > >
> > > Some controllers allow for a one-shot output pulse, in contrast to
> > > periodic output. Now that we have extensible versions of our IOCTLs, we
> > > can finally make use of the 'flags' field to pass a bit telling driver
> > > that if we want one-shot pulse output.
> > >
> > > Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> > > ---
> > >
> > > Changes since v3:
> > > 	- Remove bogus bitwise negation
> > >
> > > Changes since v2:
> > > 	- Add _PEROUT_ to bit macro
> > >
> > > Changes since v1:
> > > 	- remove comment from .flags field
> > >
> > >  include/uapi/linux/ptp_clock.h | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/include/uapi/linux/ptp_clock.h
> > b/include/uapi/linux/ptp_clock.h
> > > index 9a0af3511b68..f16301015949 100644
> > > --- a/include/uapi/linux/ptp_clock.h
> > > +++ b/include/uapi/linux/ptp_clock.h
> > > @@ -38,8 +38,8 @@
> > >  /*
> > >   * Bits of the ptp_perout_request.flags field:
> > >   */
> > > -#define PTP_PEROUT_VALID_FLAGS (0)
> > > -
> > > +#define PTP_PEROUT_ONE_SHOT (1<<0)
> > > +#define PTP_PEROUT_VALID_FLAGS	(PTP_PEROUT_ONE_SHOT)
> > >  /*
> > >   * struct ptp_clock_time - represents a time value
> > >   *
> > > @@ -77,7 +77,7 @@ struct ptp_perout_request {
> > >  	struct ptp_clock_time start;  /* Absolute start time. */
> > >  	struct ptp_clock_time period; /* Desired period, zero means disable.
> > */
> > >  	unsigned int index;           /* Which channel to configure. */
> > > -	unsigned int flags;           /* Reserved for future use. */
> > > +	unsigned int flags;
> > >  	unsigned int rsv[4];          /* Reserved for future use. */
> > >  };
> > >
> > > --
> > > 2.23.0
> >
> > Hi Felipe,
> >
> > Do you have any examples for how you envision using this? I don't see any
> > drivers or other code on the list for doing so.
> >
> > Additionally, it seems weird because we do not have support for specifying
> > the pulse width. I guess you leave that up to driver choice?
> >
> > Thanks,
> > Jake
> 

Also a quick note/question:

Is there a spot where flags are explicitly checked and rejected? I don't see any driver which would reject this as "not an acceptable configuration".

I.e. if a function calls the PEROUT_REQUEST2 ioctl, they will pass the flag through, and drivers today don't seem to bother checking flags at all.

I think we also need a patch so that all drivers are updated to reject non-zero flags, ensuring that they do not attempt to configure a request incorrectly.

Thanks,
Jake

^ permalink raw reply

* [PATCH iproute2(-next) 1/1] ip: fix ip route show json output for multipath nexthops
From: Julien Fortin @ 2019-09-24 22:32 UTC (permalink / raw)
  To: netdev; +Cc: roopa, Julien Fortin

From: Julien Fortin <julien@cumulusnetworks.com>

print_rta_multipath doesn't support JSON output:

{
    "dst":"27.0.0.13",
    "protocol":"bgp",
    "metric":20,
    "flags":[],
    "gateway":"169.254.0.1"dev uplink-1 weight 1 ,
    "flags":["onlink"],
    "gateway":"169.254.0.1"dev uplink-2 weight 1 ,
    "flags":["onlink"]
},

since RTA_MULTIPATH has nested objects we should print them
in a json array.

With the path we have the following output:

{
    "flags": [],
    "dst": "36.0.0.13",
    "protocol": "bgp",
    "metric": 20,
    "nexthops": [
        {
	    "weight": 1,
	    "flags": [
	        "onlink"
	    ],
	    "gateway": "169.254.0.1",
	    "dev": "uplink-1"
        },
	{
	    "weight": 1,
	    "flags": [
	        "onlink"
            ],
	    "gateway": "169.254.0.1",
	    "dev": "uplink-2"
        }
    ]
}

Fixes: 663c3cb23103f4 ("iproute: implement JSON and color output")

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
---
 ip/iproute.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index a4533851..5d5f1551 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -649,23 +649,27 @@ static void print_rta_multipath(FILE *fp, const struct rtmsg *r,
 	int len = RTA_PAYLOAD(rta);
 	int first = 1;
 
+	open_json_array(PRINT_JSON, "nexthops");
+
 	while (len >= sizeof(*nh)) {
 		struct rtattr *tb[RTA_MAX + 1];
 
 		if (nh->rtnh_len > len)
 			break;
 
+		open_json_object(NULL);
+
 		if (!is_json_context()) {
 			if ((r->rtm_flags & RTM_F_CLONED) &&
 			    r->rtm_type == RTN_MULTICAST) {
 				if (first) {
-					fprintf(fp, "Oifs: ");
+					print_string(PRINT_FP, NULL, "Oifs: ", NULL);
 					first = 0;
 				} else {
-					fprintf(fp, " ");
+					print_string(PRINT_FP, NULL, " ", NULL);
 				}
 			} else
-				fprintf(fp, "%s\tnexthop ", _SL_);
+				print_string(PRINT_FP, NULL, "%s\tnexthop ", _SL_);
 		}
 
 		if (nh->rtnh_len > sizeof(*nh)) {
@@ -689,22 +693,30 @@ static void print_rta_multipath(FILE *fp, const struct rtmsg *r,
 
 		if ((r->rtm_flags & RTM_F_CLONED) &&
 		    r->rtm_type == RTN_MULTICAST) {
-			fprintf(fp, "%s", ll_index_to_name(nh->rtnh_ifindex));
+			print_string(PRINT_ANY, "dev",
+				     "%s", ll_index_to_name(nh->rtnh_ifindex));
+
 			if (nh->rtnh_hops != 1)
-				fprintf(fp, "(ttl>%d)", nh->rtnh_hops);
-			fprintf(fp, " ");
+				print_int(PRINT_ANY, "ttl", "(ttl>%d)", nh->rtnh_hops);
+
+			print_string(PRINT_FP, NULL, " ", NULL);
 		} else {
-			fprintf(fp, "dev %s ", ll_index_to_name(nh->rtnh_ifindex));
+			print_string(PRINT_ANY, "dev",
+				     "dev %s ", ll_index_to_name(nh->rtnh_ifindex));
+
 			if (r->rtm_family != AF_MPLS)
-				fprintf(fp, "weight %d ",
-					nh->rtnh_hops+1);
+				print_int(PRINT_ANY, "weight",
+					  "weight %d ", nh->rtnh_hops + 1);
 		}
 
 		print_rt_flags(fp, nh->rtnh_flags);
 
 		len -= NLMSG_ALIGN(nh->rtnh_len);
 		nh = RTNH_NEXT(nh);
+
+		close_json_object();
 	}
+	close_json_array(PRINT_JSON, NULL);
 }
 
 int print_route(struct nlmsghdr *n, void *arg)
-- 
2.23.0


^ permalink raw reply related

* Re: [PATCH V2 2/8] mdev: class id support
From: Alex Williamson @ 2019-09-24 23:06 UTC (permalink / raw)
  To: Jason Wang
  Cc: kvm, linux-s390, linux-kernel, dri-devel, intel-gfx,
	intel-gvt-dev, kwankhede, mst, tiwei.bie, virtualization, netdev,
	cohuck, maxime.coquelin, cunming.liang, zhihong.wang, rob.miller,
	xiao.w.wang, haotian.wang, zhenyuw, zhi.a.wang, jani.nikula,
	joonas.lahtinen, rodrigo.vivi, airlied, daniel, farman, pasic,
	sebott, oberpar, heiko.carstens, gor, borntraeger, akrowiak,
	freude, lingshan.zhu, idos, eperezma, lulu, parav,
	christophe.de.dinechin, kevin.tian
In-Reply-To: <20190924135332.14160-3-jasowang@redhat.com>

On Tue, 24 Sep 2019 21:53:26 +0800
Jason Wang <jasowang@redhat.com> wrote:

> Mdev bus only supports vfio driver right now, so it doesn't implement
> match method. But in the future, we may add drivers other than vfio,
> the first driver could be virtio-mdev. This means we need to add
> device class id support in bus match method to pair the mdev device
> and mdev driver correctly.
> 
> So this patch adds id_table to mdev_driver and class_id for mdev
> parent with the match method for mdev bus.

Description needs to be revised from v1, class_id is no longer on the
parent.

> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  Documentation/driver-api/vfio-mediated-device.rst |  3 +++
>  drivers/gpu/drm/i915/gvt/kvmgt.c                  |  1 +
>  drivers/s390/cio/vfio_ccw_ops.c                   |  1 +
>  drivers/s390/crypto/vfio_ap_ops.c                 |  1 +
>  drivers/vfio/mdev/mdev_core.c                     |  7 +++++++
>  drivers/vfio/mdev/mdev_driver.c                   | 14 ++++++++++++++
>  drivers/vfio/mdev/mdev_private.h                  |  1 +
>  drivers/vfio/mdev/vfio_mdev.c                     |  6 ++++++
>  include/linux/mdev.h                              |  8 ++++++++
>  include/linux/mod_devicetable.h                   |  8 ++++++++
>  samples/vfio-mdev/mbochs.c                        |  1 +
>  samples/vfio-mdev/mdpy.c                          |  1 +
>  samples/vfio-mdev/mtty.c                          |  1 +
>  13 files changed, 53 insertions(+)
> 
> diff --git a/Documentation/driver-api/vfio-mediated-device.rst b/Documentation/driver-api/vfio-mediated-device.rst
> index 25eb7d5b834b..a5bdc60d62a1 100644
> --- a/Documentation/driver-api/vfio-mediated-device.rst
> +++ b/Documentation/driver-api/vfio-mediated-device.rst
> @@ -102,12 +102,14 @@ structure to represent a mediated device's driver::
>        * @probe: called when new device created
>        * @remove: called when device removed
>        * @driver: device driver structure
> +      * @id_table: the ids serviced by this driver
>        */
>       struct mdev_driver {
>  	     const char *name;
>  	     int  (*probe)  (struct device *dev);
>  	     void (*remove) (struct device *dev);
>  	     struct device_driver    driver;
> +	     const struct mdev_class_id *id_table;
>       };
>  
>  A mediated bus driver for mdev should use this structure in the function calls
> @@ -165,6 +167,7 @@ register itself with the mdev core driver::
>  	extern int  mdev_register_device(struct device *dev,
>  	                                 const struct mdev_parent_ops *ops);
>  
> +
>  However, the mdev_parent_ops structure is not required in the function call
>  that a driver should use to unregister itself with the mdev core driver::

Unintended extra line?  Doesn't seem to match surrounding formatting.

Calling mdev_set_class_id() as part of create seems relatively
fundamental to the vendor driver with this change, it should be added
to the documentation.

> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index 23aa3e50cbf8..f793252a3d2a 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -678,6 +678,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
>  		     dev_name(mdev_dev(mdev)));
>  	ret = 0;
>  
> +	mdev_set_class_id(mdev, MDEV_ID_VFIO);
>  out:
>  	return ret;
>  }
> diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
> index f0d71ab77c50..d258ef1fedb9 100644
> --- a/drivers/s390/cio/vfio_ccw_ops.c
> +++ b/drivers/s390/cio/vfio_ccw_ops.c
> @@ -129,6 +129,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev)
>  			   private->sch->schid.ssid,
>  			   private->sch->schid.sch_no);
>  
> +	mdev_set_class_id(mdev, MDEV_ID_VFIO);
>  	return 0;
>  }
>  
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 5c0f53c6dde7..2cfd96112aa0 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -343,6 +343,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev)
>  	list_add(&matrix_mdev->node, &matrix_dev->mdev_list);
>  	mutex_unlock(&matrix_dev->lock);
>  
> +	mdev_set_class_id(mdev, MDEV_ID_VFIO);
>  	return 0;
>  }
>  
> diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
> index b558d4cfd082..8764cf4a276d 100644
> --- a/drivers/vfio/mdev/mdev_core.c
> +++ b/drivers/vfio/mdev/mdev_core.c
> @@ -45,6 +45,12 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data)
>  }
>  EXPORT_SYMBOL(mdev_set_drvdata);
>  
> +void mdev_set_class_id(struct mdev_device *mdev, u16 id)
> +{
> +	mdev->class_id = id;
> +}
> +EXPORT_SYMBOL(mdev_set_class_id);
> +
>  struct device *mdev_dev(struct mdev_device *mdev)
>  {
>  	return &mdev->dev;
> @@ -135,6 +141,7 @@ static int mdev_device_remove_cb(struct device *dev, void *data)
>   * mdev_register_device : Register a device
>   * @dev: device structure representing parent device.
>   * @ops: Parent device operation structure to be registered.
> + * @id: device id.
>   *
>   * Add device to list of registered parent devices.
>   * Returns a negative value on error, otherwise 0.
> diff --git a/drivers/vfio/mdev/mdev_driver.c b/drivers/vfio/mdev/mdev_driver.c
> index 0d3223aee20b..b7c40ce86ee3 100644
> --- a/drivers/vfio/mdev/mdev_driver.c
> +++ b/drivers/vfio/mdev/mdev_driver.c
> @@ -69,8 +69,22 @@ static int mdev_remove(struct device *dev)
>  	return 0;
>  }
>  
> +static int mdev_match(struct device *dev, struct device_driver *drv)
> +{
> +	unsigned int i;
> +	struct mdev_device *mdev = to_mdev_device(dev);
> +	struct mdev_driver *mdrv = to_mdev_driver(drv);
> +	const struct mdev_class_id *ids = mdrv->id_table;
> +
> +	for (i = 0; ids[i].id; i++)
> +		if (ids[i].id == mdev->class_id)

With the proposed API here, mdev->class_id can be NULL, do we allow
devices to exist in that state or should mdev_device_create() generate
an error if the .create() callback doesn't register a type?  Or a
warn_once and assume MDEV_ID_VFIO?  The latter seems pretty sketchy
when we get to patch 5/8.  Thanks,

Alex

> +			return 1;
> +	return 0;
> +}
> +
>  struct bus_type mdev_bus_type = {
>  	.name		= "mdev",
> +	.match		= mdev_match,
>  	.probe		= mdev_probe,
>  	.remove		= mdev_remove,
>  };
> diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
> index 7d922950caaf..c65f436c1869 100644
> --- a/drivers/vfio/mdev/mdev_private.h
> +++ b/drivers/vfio/mdev/mdev_private.h
> @@ -33,6 +33,7 @@ struct mdev_device {
>  	struct kobject *type_kobj;
>  	struct device *iommu_device;
>  	bool active;
> +	u16 class_id;
>  };
>  
>  #define to_mdev_device(dev)	container_of(dev, struct mdev_device, dev)
> diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c
> index 30964a4e0a28..fd2a4d9a3f26 100644
> --- a/drivers/vfio/mdev/vfio_mdev.c
> +++ b/drivers/vfio/mdev/vfio_mdev.c
> @@ -120,10 +120,16 @@ static void vfio_mdev_remove(struct device *dev)
>  	vfio_del_group_dev(dev);
>  }
>  
> +static struct mdev_class_id id_table[] = {
> +	{ MDEV_ID_VFIO },
> +	{ 0 },
> +};
> +
>  static struct mdev_driver vfio_mdev_driver = {
>  	.name	= "vfio_mdev",
>  	.probe	= vfio_mdev_probe,
>  	.remove	= vfio_mdev_remove,
> +	.id_table = id_table,
>  };
>  
>  static int __init vfio_mdev_init(void)
> diff --git a/include/linux/mdev.h b/include/linux/mdev.h
> index 0ce30ca78db0..3974650c074f 100644
> --- a/include/linux/mdev.h
> +++ b/include/linux/mdev.h
> @@ -118,6 +118,7 @@ struct mdev_type_attribute mdev_type_attr_##_name =		\
>   * @probe: called when new device created
>   * @remove: called when device removed
>   * @driver: device driver structure
> + * @id_table: the ids serviced by this driver.
>   *
>   **/
>  struct mdev_driver {
> @@ -125,12 +126,14 @@ struct mdev_driver {
>  	int  (*probe)(struct device *dev);
>  	void (*remove)(struct device *dev);
>  	struct device_driver driver;
> +	const struct mdev_class_id *id_table;
>  };
>  
>  #define to_mdev_driver(drv)	container_of(drv, struct mdev_driver, driver)
>  
>  void *mdev_get_drvdata(struct mdev_device *mdev);
>  void mdev_set_drvdata(struct mdev_device *mdev, void *data);
> +void mdev_set_class_id(struct mdev_device *mdev, u16 id);
>  const guid_t *mdev_uuid(struct mdev_device *mdev);
>  
>  extern struct bus_type mdev_bus_type;
> @@ -145,4 +148,9 @@ struct device *mdev_parent_dev(struct mdev_device *mdev);
>  struct device *mdev_dev(struct mdev_device *mdev);
>  struct mdev_device *mdev_from_dev(struct device *dev);
>  
> +enum {
> +	MDEV_ID_VFIO = 1,
> +	/* New entries must be added here */
> +};
> +
>  #endif /* MDEV_H */
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 5714fd35a83c..f32c6e44fb1a 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -821,4 +821,12 @@ struct wmi_device_id {
>  	const void *context;
>  };
>  
> +/**
> + * struct mdev_class_id - MDEV device class identifier
> + * @id: Used to identify a specific class of device, e.g vfio-mdev device.
> + */
> +struct mdev_class_id {
> +	__u16 id;
> +};
> +
>  #endif /* LINUX_MOD_DEVICETABLE_H */
> diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
> index ac5c8c17b1ff..8a8583c892b2 100644
> --- a/samples/vfio-mdev/mbochs.c
> +++ b/samples/vfio-mdev/mbochs.c
> @@ -561,6 +561,7 @@ static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)
>  	mbochs_reset(mdev);
>  
>  	mbochs_used_mbytes += type->mbytes;
> +	mdev_set_class_id(mdev, MDEV_ID_VFIO);
>  	return 0;
>  
>  err_mem:
> diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
> index cc86bf6566e4..88d7e76f3836 100644
> --- a/samples/vfio-mdev/mdpy.c
> +++ b/samples/vfio-mdev/mdpy.c
> @@ -269,6 +269,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)
>  	mdpy_reset(mdev);
>  
>  	mdpy_count++;
> +	mdev_set_class_id(mdev, MDEV_ID_VFIO);
>  	return 0;
>  }
>  
> diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
> index 92e770a06ea2..4e0735143b69 100644
> --- a/samples/vfio-mdev/mtty.c
> +++ b/samples/vfio-mdev/mtty.c
> @@ -770,6 +770,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
>  	list_add(&mdev_state->next, &mdev_devices_list);
>  	mutex_unlock(&mdev_list_lock);
>  
> +	mdev_set_class_id(mdev, MDEV_ID_VFIO);
>  	return 0;
>  }
>  


^ permalink raw reply

* Re: [PATCH V2 5/8] mdev: introduce device specific ops
From: Alex Williamson @ 2019-09-24 23:06 UTC (permalink / raw)
  To: Jason Wang
  Cc: kvm, linux-s390, linux-kernel, dri-devel, intel-gfx,
	intel-gvt-dev, kwankhede, mst, tiwei.bie, virtualization, netdev,
	cohuck, maxime.coquelin, cunming.liang, zhihong.wang, rob.miller,
	xiao.w.wang, haotian.wang, zhenyuw, zhi.a.wang, jani.nikula,
	joonas.lahtinen, rodrigo.vivi, airlied, daniel, farman, pasic,
	sebott, oberpar, heiko.carstens, gor, borntraeger, akrowiak,
	freude, lingshan.zhu, idos, eperezma, lulu, parav,
	christophe.de.dinechin, kevin.tian
In-Reply-To: <20190924135332.14160-6-jasowang@redhat.com>

On Tue, 24 Sep 2019 21:53:29 +0800
Jason Wang <jasowang@redhat.com> wrote:

> Currently, except for the create and remove, the rest of
> mdev_parent_ops is designed for vfio-mdev driver only and may not help
> for kernel mdev driver. With the help of class id, this patch
> introduces device specific callbacks inside mdev_device
> structure. This allows different set of callback to be used by
> vfio-mdev and virtio-mdev.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  .../driver-api/vfio-mediated-device.rst       |  4 +-
>  MAINTAINERS                                   |  1 +
>  drivers/gpu/drm/i915/gvt/kvmgt.c              | 17 +++---
>  drivers/s390/cio/vfio_ccw_ops.c               | 17 ++++--
>  drivers/s390/crypto/vfio_ap_ops.c             | 13 +++--
>  drivers/vfio/mdev/mdev_core.c                 | 12 +++++
>  drivers/vfio/mdev/mdev_private.h              |  1 +
>  drivers/vfio/mdev/vfio_mdev.c                 | 37 ++++++-------
>  include/linux/mdev.h                          | 42 ++++-----------
>  include/linux/vfio_mdev.h                     | 52 +++++++++++++++++++
>  samples/vfio-mdev/mbochs.c                    | 19 ++++---
>  samples/vfio-mdev/mdpy.c                      | 19 ++++---
>  samples/vfio-mdev/mtty.c                      | 17 ++++--
>  13 files changed, 168 insertions(+), 83 deletions(-)
>  create mode 100644 include/linux/vfio_mdev.h
> 
> diff --git a/Documentation/driver-api/vfio-mediated-device.rst b/Documentation/driver-api/vfio-mediated-device.rst
> index a5bdc60d62a1..d50425b368bb 100644
> --- a/Documentation/driver-api/vfio-mediated-device.rst
> +++ b/Documentation/driver-api/vfio-mediated-device.rst
> @@ -152,7 +152,9 @@ callbacks per mdev parent device, per mdev type, or any other categorization.
>  Vendor drivers are expected to be fully asynchronous in this respect or
>  provide their own internal resource protection.)
>  
> -The callbacks in the mdev_parent_ops structure are as follows:
> +The device specific callbacks are referred through device_ops pointer
> +in mdev_parent_ops. For vfio-mdev device, its callbacks in device_ops
> +are as follows:

This is not accurate.  device_ops is now on the mdev_device and is an
mdev bus driver specific structure of callbacks that must be registered
for each mdev device by the parent driver during the create callback.
There's a one to one mapping of class_id to mdev_device_ops callbacks.

That also suggests to me that we could be more clever in registering
both of these with mdev-core.  Can we embed the class_id in the ops
structure in a common way so that the core can extract it and the bus
drivers can access their specific callbacks?

>  * open: open callback of mediated device
>  * close: close callback of mediated device
> diff --git a/MAINTAINERS b/MAINTAINERS
> index b2326dece28e..89832b316500 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -17075,6 +17075,7 @@ S:	Maintained
>  F:	Documentation/driver-api/vfio-mediated-device.rst
>  F:	drivers/vfio/mdev/
>  F:	include/linux/mdev.h
> +F:	include/linux/vfio_mdev.h
>  F:	samples/vfio-mdev/
>  
>  VFIO PLATFORM DRIVER
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index f793252a3d2a..b274f5ee481f 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -42,6 +42,7 @@
>  #include <linux/kvm_host.h>
>  #include <linux/vfio.h>
>  #include <linux/mdev.h>
> +#include <linux/vfio_mdev.h>
>  #include <linux/debugfs.h>
>  
>  #include <linux/nospec.h>
> @@ -643,6 +644,8 @@ static void kvmgt_put_vfio_device(void *vgpu)
>  	vfio_device_put(((struct intel_vgpu *)vgpu)->vdev.vfio_device);
>  }
>  
> +static struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops;
> +
>  static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
>  {
>  	struct intel_vgpu *vgpu = NULL;
> @@ -679,6 +682,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
>  	ret = 0;
>  
>  	mdev_set_class_id(mdev, MDEV_ID_VFIO);
> +	mdev_set_dev_ops(mdev, &intel_vfio_vgpu_dev_ops);

This seems rather unrefined.  We're registering interdependent data in
separate calls.  All drivers need to make both of these calls.  I'm not
sure if this is a good idea, but what if we had:

static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops = {
	.id			= MDEV_ID_VFIO,
 	.open			= intel_vgpu_open,
 	.release		= intel_vgpu_release,
        ...

And the set function passed &intel_vfio_vgpu_dev_ops.id and the mdev
bus drivers used container_of to get to their callbacks?

>  out:
>  	return ret;
>  }
> @@ -1601,20 +1605,21 @@ static const struct attribute_group *intel_vgpu_groups[] = {
>  	NULL,
>  };
>  
> -static struct mdev_parent_ops intel_vgpu_ops = {
> -	.mdev_attr_groups       = intel_vgpu_groups,
> -	.create			= intel_vgpu_create,
> -	.remove			= intel_vgpu_remove,
> -
> +static struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops = {
>  	.open			= intel_vgpu_open,
>  	.release		= intel_vgpu_release,
> -
>  	.read			= intel_vgpu_read,
>  	.write			= intel_vgpu_write,
>  	.mmap			= intel_vgpu_mmap,
>  	.ioctl			= intel_vgpu_ioctl,
>  };
>  
> +static struct mdev_parent_ops intel_vgpu_ops = {

These could maybe be made const at the same time.  Thanks,

Alex

> +	.mdev_attr_groups       = intel_vgpu_groups,
> +	.create			= intel_vgpu_create,
> +	.remove			= intel_vgpu_remove,
> +};
> +
>  static int kvmgt_host_init(struct device *dev, void *gvt, const void *ops)
>  {
>  	struct attribute **kvm_type_attrs;
> diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
> index d258ef1fedb9..329d53c1f46b 100644
> --- a/drivers/s390/cio/vfio_ccw_ops.c
> +++ b/drivers/s390/cio/vfio_ccw_ops.c
> @@ -12,6 +12,7 @@
>  
>  #include <linux/vfio.h>
>  #include <linux/mdev.h>
> +#include <linux/vfio_mdev.h>
>  #include <linux/nospec.h>
>  #include <linux/slab.h>
>  
> @@ -110,6 +111,8 @@ static struct attribute_group *mdev_type_groups[] = {
>  	NULL,
>  };
>  
> +static const struct vfio_mdev_device_ops vfio_mdev_ops;
> +
>  static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev)
>  {
>  	struct vfio_ccw_private *private =
> @@ -130,6 +133,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev)
>  			   private->sch->schid.sch_no);
>  
>  	mdev_set_class_id(mdev, MDEV_ID_VFIO);
> +	mdev_set_dev_ops(mdev, &vfio_mdev_ops);
>  	return 0;
>  }
>  
> @@ -575,11 +579,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
>  	}
>  }
>  
> -static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
> -	.owner			= THIS_MODULE,
> -	.supported_type_groups  = mdev_type_groups,
> -	.create			= vfio_ccw_mdev_create,
> -	.remove			= vfio_ccw_mdev_remove,
> +static const struct vfio_mdev_device_ops vfio_mdev_ops = {
>  	.open			= vfio_ccw_mdev_open,
>  	.release		= vfio_ccw_mdev_release,
>  	.read			= vfio_ccw_mdev_read,
> @@ -587,6 +587,13 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
>  	.ioctl			= vfio_ccw_mdev_ioctl,
>  };
>  
> +static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
> +	.owner			= THIS_MODULE,
> +	.supported_type_groups  = mdev_type_groups,
> +	.create			= vfio_ccw_mdev_create,
> +	.remove			= vfio_ccw_mdev_remove,
> +};
> +
>  int vfio_ccw_mdev_reg(struct subchannel *sch)
>  {
>  	return mdev_register_device(&sch->dev, &vfio_ccw_mdev_ops);
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 2cfd96112aa0..3a89933f0d3e 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -16,6 +16,7 @@
>  #include <linux/bitops.h>
>  #include <linux/kvm_host.h>
>  #include <linux/module.h>
> +#include <linux/vfio_mdev.h>
>  #include <asm/kvm.h>
>  #include <asm/zcrypt.h>
>  
> @@ -321,6 +322,8 @@ static void vfio_ap_matrix_init(struct ap_config_info *info,
>  	matrix->adm_max = info->apxa ? info->Nd : 15;
>  }
>  
> +static const struct vfio_mdev_device_ops vfio_mdev_ops;
> +
>  static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev)
>  {
>  	struct ap_matrix_mdev *matrix_mdev;
> @@ -344,6 +347,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev)
>  	mutex_unlock(&matrix_dev->lock);
>  
>  	mdev_set_class_id(mdev, MDEV_ID_VFIO);
> +	mdev_set_dev_ops(mdev, &vfio_mdev_ops);
>  	return 0;
>  }
>  
> @@ -1281,15 +1285,18 @@ static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev,
>  	return ret;
>  }
>  
> +static const struct vfio_mdev_device_ops vfio_mdev_ops = {
> +	.open			= vfio_ap_mdev_open,
> +	.release		= vfio_ap_mdev_release,
> +	.ioctl			= vfio_ap_mdev_ioctl,
> +};
> +
>  static const struct mdev_parent_ops vfio_ap_matrix_ops = {
>  	.owner			= THIS_MODULE,
>  	.supported_type_groups	= vfio_ap_mdev_type_groups,
>  	.mdev_attr_groups	= vfio_ap_mdev_attr_groups,
>  	.create			= vfio_ap_mdev_create,
>  	.remove			= vfio_ap_mdev_remove,
> -	.open			= vfio_ap_mdev_open,
> -	.release		= vfio_ap_mdev_release,
> -	.ioctl			= vfio_ap_mdev_ioctl,
>  };
>  
>  int vfio_ap_mdev_register(void)
> diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
> index 8764cf4a276d..6f35f2ced2c9 100644
> --- a/drivers/vfio/mdev/mdev_core.c
> +++ b/drivers/vfio/mdev/mdev_core.c
> @@ -51,6 +51,18 @@ void mdev_set_class_id(struct mdev_device *mdev, u16 id)
>  }
>  EXPORT_SYMBOL(mdev_set_class_id);
>  
> +const void *mdev_get_dev_ops(struct mdev_device *mdev)
> +{
> +	return mdev->device_ops;
> +}
> +EXPORT_SYMBOL(mdev_get_dev_ops);
> +
> +void mdev_set_dev_ops(struct mdev_device *mdev, const void *ops)
> +{
> +	mdev->device_ops = ops;
> +}
> +EXPORT_SYMBOL(mdev_set_dev_ops);
> +
>  struct device *mdev_dev(struct mdev_device *mdev)
>  {
>  	return &mdev->dev;
> diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
> index c65f436c1869..b666805f0b1f 100644
> --- a/drivers/vfio/mdev/mdev_private.h
> +++ b/drivers/vfio/mdev/mdev_private.h
> @@ -34,6 +34,7 @@ struct mdev_device {
>  	struct device *iommu_device;
>  	bool active;
>  	u16 class_id;
> +	const void *device_ops;
>  };
>  
>  #define to_mdev_device(dev)	container_of(dev, struct mdev_device, dev)
> diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c
> index 891cf83a2d9a..95efa054442f 100644
> --- a/drivers/vfio/mdev/vfio_mdev.c
> +++ b/drivers/vfio/mdev/vfio_mdev.c
> @@ -14,6 +14,7 @@
>  #include <linux/slab.h>
>  #include <linux/vfio.h>
>  #include <linux/mdev.h>
> +#include <linux/vfio_mdev.h>
>  
>  #include "mdev_private.h"
>  
> @@ -24,16 +25,16 @@
>  static int vfio_mdev_open(void *device_data)
>  {
>  	struct mdev_device *mdev = device_data;
> -	struct mdev_parent *parent = mdev->parent;
> +	const struct vfio_mdev_device_ops *ops = mdev_get_dev_ops(mdev);
>  	int ret;
>  
> -	if (unlikely(!parent->ops->open))
> +	if (unlikely(!ops->open))
>  		return -EINVAL;
>  
>  	if (!try_module_get(THIS_MODULE))
>  		return -ENODEV;
>  
> -	ret = parent->ops->open(mdev);
> +	ret = ops->open(mdev);
>  	if (ret)
>  		module_put(THIS_MODULE);
>  
> @@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data)
>  static void vfio_mdev_release(void *device_data)
>  {
>  	struct mdev_device *mdev = device_data;
> -	struct mdev_parent *parent = mdev->parent;
> +	const struct vfio_mdev_device_ops *ops = mdev_get_dev_ops(mdev);
>  
> -	if (likely(parent->ops->release))
> -		parent->ops->release(mdev);
> +	if (likely(ops->release))
> +		ops->release(mdev);
>  
>  	module_put(THIS_MODULE);
>  }
> @@ -55,47 +56,47 @@ static long vfio_mdev_unlocked_ioctl(void *device_data,
>  				     unsigned int cmd, unsigned long arg)
>  {
>  	struct mdev_device *mdev = device_data;
> -	struct mdev_parent *parent = mdev->parent;
> +	const struct vfio_mdev_device_ops *ops = mdev_get_dev_ops(mdev);
>  
> -	if (unlikely(!parent->ops->ioctl))
> +	if (unlikely(!ops->ioctl))
>  		return -EINVAL;
>  
> -	return parent->ops->ioctl(mdev, cmd, arg);
> +	return ops->ioctl(mdev, cmd, arg);
>  }
>  
>  static ssize_t vfio_mdev_read(void *device_data, char __user *buf,
>  			      size_t count, loff_t *ppos)
>  {
>  	struct mdev_device *mdev = device_data;
> -	struct mdev_parent *parent = mdev->parent;
> +	const struct vfio_mdev_device_ops *ops = mdev_get_dev_ops(mdev);
>  
> -	if (unlikely(!parent->ops->read))
> +	if (unlikely(!ops->read))
>  		return -EINVAL;
>  
> -	return parent->ops->read(mdev, buf, count, ppos);
> +	return ops->read(mdev, buf, count, ppos);
>  }
>  
>  static ssize_t vfio_mdev_write(void *device_data, const char __user *buf,
>  			       size_t count, loff_t *ppos)
>  {
>  	struct mdev_device *mdev = device_data;
> -	struct mdev_parent *parent = mdev->parent;
> +	const struct vfio_mdev_device_ops *ops = mdev_get_dev_ops(mdev);
>  
> -	if (unlikely(!parent->ops->write))
> +	if (unlikely(!ops->write))
>  		return -EINVAL;
>  
> -	return parent->ops->write(mdev, buf, count, ppos);
> +	return ops->write(mdev, buf, count, ppos);
>  }
>  
>  static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma)
>  {
>  	struct mdev_device *mdev = device_data;
> -	struct mdev_parent *parent = mdev->parent;
> +	const struct vfio_mdev_device_ops *ops = mdev_get_dev_ops(mdev);
>  
> -	if (unlikely(!parent->ops->mmap))
> +	if (unlikely(!ops->mmap))
>  		return -EINVAL;
>  
> -	return parent->ops->mmap(mdev, vma);
> +	return ops->mmap(mdev, vma);
>  }
>  
>  static const struct vfio_device_ops vfio_mdev_dev_ops = {
> diff --git a/include/linux/mdev.h b/include/linux/mdev.h
> index 3974650c074f..3414307311f1 100644
> --- a/include/linux/mdev.h
> +++ b/include/linux/mdev.h
> @@ -10,6 +10,11 @@
>  #ifndef MDEV_H
>  #define MDEV_H
>  
> +#include <linux/types.h>
> +#include <linux/device.h>
> +#include <linux/mdev.h>
> +#include <uapi/linux/uuid.h>
> +
>  struct mdev_device;
>  
>  /*
> @@ -48,30 +53,8 @@ struct device *mdev_get_iommu_device(struct device *dev);
>   *			@mdev: mdev_device device structure which is being
>   *			       destroyed
>   *			Returns integer: success (0) or error (< 0)
> - * @open:		Open mediated device.
> - *			@mdev: mediated device.
> - *			Returns integer: success (0) or error (< 0)
> - * @release:		release mediated device
> - *			@mdev: mediated device.
> - * @read:		Read emulation callback
> - *			@mdev: mediated device structure
> - *			@buf: read buffer
> - *			@count: number of bytes to read
> - *			@ppos: address.
> - *			Retuns number on bytes read on success or error.
> - * @write:		Write emulation callback
> - *			@mdev: mediated device structure
> - *			@buf: write buffer
> - *			@count: number of bytes to be written
> - *			@ppos: address.
> - *			Retuns number on bytes written on success or error.
> - * @ioctl:		IOCTL callback
> - *			@mdev: mediated device structure
> - *			@cmd: ioctl command
> - *			@arg: arguments to ioctl
> - * @mmap:		mmap callback
> - *			@mdev: mediated device structure
> - *			@vma: vma structure
> + * @device_ops:         Device specific emulation callback.
> + *
>   * Parent device that support mediated device should be registered with mdev
>   * module with mdev_parent_ops structure.
>   **/
> @@ -83,15 +66,6 @@ struct mdev_parent_ops {
>  
>  	int     (*create)(struct kobject *kobj, struct mdev_device *mdev);
>  	int     (*remove)(struct mdev_device *mdev);
> -	int     (*open)(struct mdev_device *mdev);
> -	void    (*release)(struct mdev_device *mdev);
> -	ssize_t (*read)(struct mdev_device *mdev, char __user *buf,
> -			size_t count, loff_t *ppos);
> -	ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
> -			 size_t count, loff_t *ppos);
> -	long	(*ioctl)(struct mdev_device *mdev, unsigned int cmd,
> -			 unsigned long arg);
> -	int	(*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
>  };
>  
>  /* interface for exporting mdev supported type attributes */
> @@ -133,6 +107,8 @@ struct mdev_driver {
>  
>  void *mdev_get_drvdata(struct mdev_device *mdev);
>  void mdev_set_drvdata(struct mdev_device *mdev, void *data);
> +const void *mdev_get_dev_ops(struct mdev_device *mdev);
> +void mdev_set_dev_ops(struct mdev_device *mdev, const void *ops);
>  void mdev_set_class_id(struct mdev_device *mdev, u16 id);
>  const guid_t *mdev_uuid(struct mdev_device *mdev);
>  
> diff --git a/include/linux/vfio_mdev.h b/include/linux/vfio_mdev.h
> new file mode 100644
> index 000000000000..3907c5371c2b
> --- /dev/null
> +++ b/include/linux/vfio_mdev.h
> @@ -0,0 +1,52 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * VFIO Mediated device definition
> + */
> +
> +#ifndef VFIO_MDEV_H
> +#define VFIO_MDEV_H
> +
> +#include <linux/mdev.h>
> +
> +/**
> + * struct vfio_mdev_device_ops - Structure to be registered for each
> + * mdev device to register the device to vfio-mdev module.
> + *
> + * @open:		Open mediated device.
> + *			@mdev: mediated device.
> + *			Returns integer: success (0) or error (< 0)
> + * @release:		release mediated device
> + *			@mdev: mediated device.
> + * @read:		Read emulation callback
> + *			@mdev: mediated device structure
> + *			@buf: read buffer
> + *			@count: number of bytes to read
> + *			@ppos: address.
> + *			Retuns number on bytes read on success or error.
> + * @write:		Write emulation callback
> + *			@mdev: mediated device structure
> + *			@buf: write buffer
> + *			@count: number of bytes to be written
> + *			@ppos: address.
> + *			Retuns number on bytes written on success or error.
> + * @ioctl:		IOCTL callback
> + *			@mdev: mediated device structure
> + *			@cmd: ioctl command
> + *			@arg: arguments to ioctl
> + * @mmap:		mmap callback
> + *			@mdev: mediated device structure
> + *			@vma: vma structure
> + */
> +struct vfio_mdev_device_ops {
> +	int     (*open)(struct mdev_device *mdev);
> +	void    (*release)(struct mdev_device *mdev);
> +	ssize_t (*read)(struct mdev_device *mdev, char __user *buf,
> +			size_t count, loff_t *ppos);
> +	ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
> +			 size_t count, loff_t *ppos);
> +	long	(*ioctl)(struct mdev_device *mdev, unsigned int cmd,
> +			 unsigned long arg);
> +	int	(*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
> +};
> +
> +#endif
> diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
> index 8a8583c892b2..b4bf29c6136c 100644
> --- a/samples/vfio-mdev/mbochs.c
> +++ b/samples/vfio-mdev/mbochs.c
> @@ -30,6 +30,7 @@
>  #include <linux/iommu.h>
>  #include <linux/sysfs.h>
>  #include <linux/mdev.h>
> +#include <linux/vfio_mdev.h>
>  #include <linux/pci.h>
>  #include <linux/dma-buf.h>
>  #include <linux/highmem.h>
> @@ -516,6 +517,8 @@ static int mbochs_reset(struct mdev_device *mdev)
>  	return 0;
>  }
>  
> +static const struct vfio_mdev_device_ops vfio_mdev_ops;
> +
>  static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)
>  {
>  	const struct mbochs_type *type = mbochs_find_type(kobj);
> @@ -562,6 +565,7 @@ static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)
>  
>  	mbochs_used_mbytes += type->mbytes;
>  	mdev_set_class_id(mdev, MDEV_ID_VFIO);
> +	mdev_set_dev_ops(mdev, &vfio_mdev_ops);
>  	return 0;
>  
>  err_mem:
> @@ -1419,12 +1423,7 @@ static struct attribute_group *mdev_type_groups[] = {
>  	NULL,
>  };
>  
> -static const struct mdev_parent_ops mdev_fops = {
> -	.owner			= THIS_MODULE,
> -	.mdev_attr_groups	= mdev_dev_groups,
> -	.supported_type_groups	= mdev_type_groups,
> -	.create			= mbochs_create,
> -	.remove			= mbochs_remove,
> +static const struct vfio_mdev_device_ops vfio_mdev_ops = {
>  	.open			= mbochs_open,
>  	.release		= mbochs_close,
>  	.read			= mbochs_read,
> @@ -1433,6 +1432,14 @@ static const struct mdev_parent_ops mdev_fops = {
>  	.mmap			= mbochs_mmap,
>  };
>  
> +static const struct mdev_parent_ops mdev_fops = {
> +	.owner			= THIS_MODULE,
> +	.mdev_attr_groups	= mdev_dev_groups,
> +	.supported_type_groups	= mdev_type_groups,
> +	.create			= mbochs_create,
> +	.remove			= mbochs_remove,
> +};
> +
>  static const struct file_operations vd_fops = {
>  	.owner		= THIS_MODULE,
>  };
> diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
> index 88d7e76f3836..80c2df531326 100644
> --- a/samples/vfio-mdev/mdpy.c
> +++ b/samples/vfio-mdev/mdpy.c
> @@ -26,6 +26,7 @@
>  #include <linux/iommu.h>
>  #include <linux/sysfs.h>
>  #include <linux/mdev.h>
> +#include <linux/vfio_mdev.h>
>  #include <linux/pci.h>
>  #include <drm/drm_fourcc.h>
>  #include "mdpy-defs.h"
> @@ -226,6 +227,8 @@ static int mdpy_reset(struct mdev_device *mdev)
>  	return 0;
>  }
>  
> +static const struct vfio_mdev_device_ops vfio_mdev_ops;
> +
>  static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)
>  {
>  	const struct mdpy_type *type = mdpy_find_type(kobj);
> @@ -270,6 +273,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)
>  
>  	mdpy_count++;
>  	mdev_set_class_id(mdev, MDEV_ID_VFIO);
> +	mdev_set_dev_ops(mdev, &vfio_mdev_ops);
>  	return 0;
>  }
>  
> @@ -726,12 +730,7 @@ static struct attribute_group *mdev_type_groups[] = {
>  	NULL,
>  };
>  
> -static const struct mdev_parent_ops mdev_fops = {
> -	.owner			= THIS_MODULE,
> -	.mdev_attr_groups	= mdev_dev_groups,
> -	.supported_type_groups	= mdev_type_groups,
> -	.create			= mdpy_create,
> -	.remove			= mdpy_remove,
> +static const struct vfio_mdev_device_ops vfio_mdev_ops = {
>  	.open			= mdpy_open,
>  	.release		= mdpy_close,
>  	.read			= mdpy_read,
> @@ -740,6 +739,14 @@ static const struct mdev_parent_ops mdev_fops = {
>  	.mmap			= mdpy_mmap,
>  };
>  
> +static const struct mdev_parent_ops mdev_fops = {
> +	.owner			= THIS_MODULE,
> +	.mdev_attr_groups	= mdev_dev_groups,
> +	.supported_type_groups	= mdev_type_groups,
> +	.create			= mdpy_create,
> +	.remove			= mdpy_remove,
> +};
> +
>  static const struct file_operations vd_fops = {
>  	.owner		= THIS_MODULE,
>  };
> diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
> index 4e0735143b69..2db860ccb02c 100644
> --- a/samples/vfio-mdev/mtty.c
> +++ b/samples/vfio-mdev/mtty.c
> @@ -27,6 +27,7 @@
>  #include <linux/ctype.h>
>  #include <linux/file.h>
>  #include <linux/mdev.h>
> +#include <linux/vfio_mdev.h>
>  #include <linux/pci.h>
>  #include <linux/serial.h>
>  #include <uapi/linux/serial_reg.h>
> @@ -723,6 +724,8 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count,
>  	return ret;
>  }
>  
> +static const struct vfio_mdev_device_ops vfio_dev_ops;
> +
>  static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
>  {
>  	struct mdev_state *mdev_state;
> @@ -771,6 +774,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
>  	mutex_unlock(&mdev_list_lock);
>  
>  	mdev_set_class_id(mdev, MDEV_ID_VFIO);
> +	mdev_set_dev_ops(mdev, &vfio_dev_ops);
>  	return 0;
>  }
>  
> @@ -1411,6 +1415,14 @@ static struct attribute_group *mdev_type_groups[] = {
>  	NULL,
>  };
>  
> +static const struct vfio_mdev_device_ops vfio_dev_ops = {
> +	.open                   = mtty_open,
> +	.release                = mtty_close,
> +	.read                   = mtty_read,
> +	.write                  = mtty_write,
> +	.ioctl		        = mtty_ioctl,
> +};
> +
>  static const struct mdev_parent_ops mdev_fops = {
>  	.owner                  = THIS_MODULE,
>  	.dev_attr_groups        = mtty_dev_groups,
> @@ -1418,11 +1430,6 @@ static const struct mdev_parent_ops mdev_fops = {
>  	.supported_type_groups  = mdev_type_groups,
>  	.create                 = mtty_create,
>  	.remove			= mtty_remove,
> -	.open                   = mtty_open,
> -	.release                = mtty_close,
> -	.read                   = mtty_read,
> -	.write                  = mtty_write,
> -	.ioctl		        = mtty_ioctl,
>  };
>  
>  static void mtty_device_release(struct device *dev)


^ permalink raw reply

* Re: [PATCH V2 6/8] mdev: introduce virtio device and its device ops
From: Alex Williamson @ 2019-09-24 23:06 UTC (permalink / raw)
  To: Jason Wang
  Cc: kvm, linux-s390, linux-kernel, dri-devel, intel-gfx,
	intel-gvt-dev, kwankhede, mst, tiwei.bie, virtualization, netdev,
	cohuck, maxime.coquelin, cunming.liang, zhihong.wang, rob.miller,
	xiao.w.wang, haotian.wang, zhenyuw, zhi.a.wang, jani.nikula,
	joonas.lahtinen, rodrigo.vivi, airlied, daniel, farman, pasic,
	sebott, oberpar, heiko.carstens, gor, borntraeger, akrowiak,
	freude, lingshan.zhu, idos, eperezma, lulu, parav,
	christophe.de.dinechin, kevin.tian
In-Reply-To: <20190924135332.14160-7-jasowang@redhat.com>

On Tue, 24 Sep 2019 21:53:30 +0800
Jason Wang <jasowang@redhat.com> wrote:

> This patch implements basic support for mdev driver that supports
> virtio transport for kernel virtio driver.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  include/linux/mdev.h        |   2 +
>  include/linux/virtio_mdev.h | 145 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 147 insertions(+)
>  create mode 100644 include/linux/virtio_mdev.h
> 
> diff --git a/include/linux/mdev.h b/include/linux/mdev.h
> index 3414307311f1..73ac27b3b868 100644
> --- a/include/linux/mdev.h
> +++ b/include/linux/mdev.h
> @@ -126,6 +126,8 @@ struct mdev_device *mdev_from_dev(struct device *dev);
>  
>  enum {
>  	MDEV_ID_VFIO = 1,
> +	MDEV_ID_VIRTIO = 2,
> +	MDEV_ID_VHOST = 3,

MDEV_ID_VHOST isn't used yet here.  Also, given the strong
interdependence between the class_id and the ops structure, we might
wand to define them in the same place.  Thanks,

Alex

>  	/* New entries must be added here */
>  };
>  
> diff --git a/include/linux/virtio_mdev.h b/include/linux/virtio_mdev.h
> new file mode 100644
> index 000000000000..d1a40a739266
> --- /dev/null
> +++ b/include/linux/virtio_mdev.h
> @@ -0,0 +1,145 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Virtio mediated device driver
> + *
> + * Copyright 2019, Red Hat Corp.
> + *     Author: Jason Wang <jasowang@redhat.com>
> + */
> +#ifndef _LINUX_VIRTIO_MDEV_H
> +#define _LINUX_VIRTIO_MDEV_H
> +
> +#include <linux/interrupt.h>
> +#include <linux/mdev.h>
> +#include <uapi/linux/vhost.h>
> +
> +#define VIRTIO_MDEV_DEVICE_API_STRING		"virtio-mdev"
> +#define VIRTIO_MDEV_VERSION 0x1
> +
> +struct virtio_mdev_callback {
> +	irqreturn_t (*callback)(void *data);
> +	void *private;
> +};
> +
> +/**
> + * struct vfio_mdev_device_ops - Structure to be registered for each
> + * mdev device to register the device to virtio-mdev module.
> + *
> + * @set_vq_address:		Set the address of virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + *				@desc_area: address of desc area
> + *				@driver_area: address of driver area
> + *				@device_area: address of device area
> + *				Returns integer: success (0) or error (< 0)
> + * @set_vq_num:		Set the size of virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + *				@num: the size of virtqueue
> + * @kick_vq:			Kick the virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + * @set_vq_cb:			Set the interrut calback function for
> + *				a virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + *				@cb: virtio-mdev interrupt callback structure
> + * @set_vq_ready:		Set ready status for a virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + *				@ready: ready (true) not ready(false)
> + * @get_vq_ready:		Get ready status for a virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + *				Returns boolean: ready (true) or not (false)
> + * @set_vq_state:		Set the state for a virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + *				@state: virtqueue state (last_avail_idx)
> + *				Returns integer: success (0) or error (< 0)
> + * @get_vq_state:		Get the state for a virtqueue
> + *				@mdev: mediated device
> + *				@idx: virtqueue index
> + *				Returns virtqueue state (last_avail_idx)
> + * @get_vq_align:		Get the virtqueue align requirement
> + *				for the device
> + *				@mdev: mediated device
> + *				Returns virtqueue algin requirement
> + * @get_features:		Get virtio features supported by the device
> + *				@mdev: mediated device
> + *				Returns the features support by the
> + *				device
> + * @get_features:		Set virtio features supported by the driver
> + *				@mdev: mediated device
> + *				@features: feature support by the driver
> + *				Returns integer: success (0) or error (< 0)
> + * @set_config_cb:		Set the config interrupt callback
> + *				@mdev: mediated device
> + *				@cb: virtio-mdev interrupt callback structure
> + * @get_device_id:		Get virtio device id
> + *				@mdev: mediated device
> + *				Returns u32: virtio device id
> + * @get_vendor_id:		Get virtio vendor id
> + *				@mdev: mediated device
> + *				Returns u32: virtio vendor id
> + * @get_status:		Get the device status
> + *				@mdev: mediated device
> + *				Returns u8: virtio device status
> + * @set_status:		Set the device status
> + *				@mdev: mediated device
> + *				@status: virtio device status
> + * @get_config:		Read from device specific confiugration space
> + *				@mdev: mediated device
> + *				@offset: offset from the beginning of
> + *				configuration space
> + *				@buf: buffer used to read to
> + *				@len: the length to read from
> + *				configration space
> + * @set_config:		Write to device specific confiugration space
> + *				@mdev: mediated device
> + *				@offset: offset from the beginning of
> + *				configuration space
> + *				@buf: buffer used to write from
> + *				@len: the length to write to
> + *				configration space
> + * @get_version:		Get the version of virtio mdev device
> + *				@mdev: mediated device
> + *				Returns integer: version of the device
> + * @get_generation:		Get device generaton
> + *				@mdev: mediated device
> + *				Returns u32: device generation
> + */
> +struct virtio_mdev_device_ops {
> +	/* Virtqueue ops */
> +	int (*set_vq_address)(struct mdev_device *mdev,
> +			      u16 idx, u64 desc_area, u64 driver_area,
> +			      u64 device_area);
> +	void (*set_vq_num)(struct mdev_device *mdev, u16 idx, u32 num);
> +	void (*kick_vq)(struct mdev_device *mdev, u16 idx);
> +	void (*set_vq_cb)(struct mdev_device *mdev, u16 idx,
> +			  struct virtio_mdev_callback *cb);
> +	void (*set_vq_ready)(struct mdev_device *mdev, u16 idx, bool ready);
> +	bool (*get_vq_ready)(struct mdev_device *mdev, u16 idx);
> +	int (*set_vq_state)(struct mdev_device *mdev, u16 idx, u64 state);
> +	u64 (*get_vq_state)(struct mdev_device *mdev, u16 idx);
> +
> +	/* Device ops */
> +	u16 (*get_vq_align)(struct mdev_device *mdev);
> +	u64 (*get_features)(struct mdev_device *mdev);
> +	int (*set_features)(struct mdev_device *mdev, u64 features);
> +	void (*set_config_cb)(struct mdev_device *mdev,
> +			      struct virtio_mdev_callback *cb);
> +	u16 (*get_queue_max)(struct mdev_device *mdev);
> +	u32 (*get_device_id)(struct mdev_device *mdev);
> +	u32 (*get_vendor_id)(struct mdev_device *mdev);
> +	u8 (*get_status)(struct mdev_device *mdev);
> +	void (*set_status)(struct mdev_device *mdev, u8 status);
> +	void (*get_config)(struct mdev_device *mdev, unsigned int offset,
> +			   void *buf, unsigned int len);
> +	void (*set_config)(struct mdev_device *mdev, unsigned int offset,
> +			   const void *buf, unsigned int len);
> +	int (*get_version)(struct mdev_device *mdev);
> +	u32 (*get_generation)(struct mdev_device *mdev);
> +};
> +
> +#endif
> +


^ permalink raw reply

* Re: [PATCH] r8152: Use guard clause and fix comment typos
From: Grant Grundler @ 2019-09-24 23:47 UTC (permalink / raw)
  To: Hayes Wang
  Cc: Prashant Malani, grundler@chromium.org, netdev@vger.kernel.org,
	nic_swsd
In-Reply-To: <0835B3720019904CB8F7AA43166CEEB2F18E1587@RTITMBSVM03.realtek.com.tw>

On Mon, Sep 23, 2019 at 7:47 PM Hayes Wang <hayeswang@realtek.com> wrote:
>
> Prashant Malani [mailto:pmalani@chromium.org]
> > Sent: Tuesday, September 24, 2019 6:27 AM
> > To: Hayes Wang
> [...]
> > -     do {
> > +     while (1) {
> >               struct tx_agg *agg;
> > +             struct net_device *netdev = tp->netdev;
> >
> >               if (skb_queue_empty(&tp->tx_queue))
> >                       break;
> > @@ -2188,26 +2189,25 @@ static void tx_bottom(struct r8152 *tp)
> >                       break;
> >
> >               res = r8152_tx_agg_fill(tp, agg);
> > -             if (res) {
> > -                     struct net_device *netdev = tp->netdev;
> > +             if (!res)
> > +                     break;
>
> I let the loop run continually until an error occurs or the queue is empty.
> However, you stop the loop when r8152_tx_agg_fill() is successful.

Hayes,
Are you sure about both assertions?
The do/while loop exits if "res == 0". Isn't that the same as "!res"?

> If an error occurs continually, the loop may not be broken.

And what prevents that from happening with the current code?

Should current code break out of the loop in -ENODEV case, right?

That would be more obvious if the code inside the loop were:
    ...
    res = r8152_tx_agg_fill(tp, agg);
    if (res == -ENODEV) {
       ...
       break;
     }
     if (!res)
         break;
    ...

(Or whatever the right code is to "loop until an error occurs or queue
is empty").

cheers,
grant

>
> > -                     if (res == -ENODEV) {
> > -                             rtl_set_unplug(tp);
> > -                             netif_device_detach(netdev);
> > -                     } else {
> > -                             struct net_device_stats *stats = &netdev->stats;
> > -                             unsigned long flags;
> > +             if (res == -ENODEV) {
> > +                     rtl_set_unplug(tp);
> > +                     netif_device_detach(netdev);
> > +             } else {
> > +                     struct net_device_stats *stats = &netdev->stats;
> > +                     unsigned long flags;
> >
> > -                             netif_warn(tp, tx_err, netdev,
> > -                                        "failed tx_urb %d\n", res);
> > -                             stats->tx_dropped += agg->skb_num;
> > +                     netif_warn(tp, tx_err, netdev,
> > +                                "failed tx_urb %d\n", res);
> > +                     stats->tx_dropped += agg->skb_num;
> >
> > -                             spin_lock_irqsave(&tp->tx_lock, flags);
> > -                             list_add_tail(&agg->list, &tp->tx_free);
> > -                             spin_unlock_irqrestore(&tp->tx_lock, flags);
> > -                     }
> > +                     spin_lock_irqsave(&tp->tx_lock, flags);
> > +                     list_add_tail(&agg->list, &tp->tx_free);
> > +                     spin_unlock_irqrestore(&tp->tx_lock, flags);
> >               }
> > -     } while (res == 0);
> > +     }
>
> I think the behavior is different from the current one.
>
> Best Regards,
> Hayes
>

^ permalink raw reply

* Re: [PATCH] r8152: Use guard clause and fix comment typos
From: Grant Grundler @ 2019-09-25  0:28 UTC (permalink / raw)
  To: Grant Grundler
  Cc: Hayes Wang, Prashant Malani, netdev@vger.kernel.org, nic_swsd
In-Reply-To: <CANEJEGsN44m190YSw=NYozV72Dt3fuPohUwWEMH2XWWBGsCgBg@mail.gmail.com>

On Tue, Sep 24, 2019 at 4:47 PM Grant Grundler <grundler@chromium.org> wrote:
>
> On Mon, Sep 23, 2019 at 7:47 PM Hayes Wang <hayeswang@realtek.com> wrote:
> >
> > Prashant Malani [mailto:pmalani@chromium.org]
> > > Sent: Tuesday, September 24, 2019 6:27 AM
> > > To: Hayes Wang
> > [...]
> > > -     do {
> > > +     while (1) {
> > >               struct tx_agg *agg;
> > > +             struct net_device *netdev = tp->netdev;
> > >
> > >               if (skb_queue_empty(&tp->tx_queue))
> > >                       break;
> > > @@ -2188,26 +2189,25 @@ static void tx_bottom(struct r8152 *tp)
> > >                       break;
> > >
> > >               res = r8152_tx_agg_fill(tp, agg);
> > > -             if (res) {
> > > -                     struct net_device *netdev = tp->netdev;
> > > +             if (!res)
> > > +                     break;
> >
> > I let the loop run continually until an error occurs or the queue is empty.
> > However, you stop the loop when r8152_tx_agg_fill() is successful.
>
> Hayes,
> Are you sure about both assertions?
> The do/while loop exits if "res == 0". Isn't that the same as "!res"?

Hayes,
Sorry, You are correct.

thanks,
grant

>
> > If an error occurs continually, the loop may not be broken.
>
> And what prevents that from happening with the current code?
>
> Should current code break out of the loop in -ENODEV case, right?
>
> That would be more obvious if the code inside the loop were:
>     ...
>     res = r8152_tx_agg_fill(tp, agg);
>     if (res == -ENODEV) {
>        ...
>        break;
>      }
>      if (!res)
>          break;
>     ...
>
> (Or whatever the right code is to "loop until an error occurs or queue
> is empty").
>
> cheers,
> grant
>
> >
> > > -                     if (res == -ENODEV) {
> > > -                             rtl_set_unplug(tp);
> > > -                             netif_device_detach(netdev);
> > > -                     } else {
> > > -                             struct net_device_stats *stats = &netdev->stats;
> > > -                             unsigned long flags;
> > > +             if (res == -ENODEV) {
> > > +                     rtl_set_unplug(tp);
> > > +                     netif_device_detach(netdev);
> > > +             } else {
> > > +                     struct net_device_stats *stats = &netdev->stats;
> > > +                     unsigned long flags;
> > >
> > > -                             netif_warn(tp, tx_err, netdev,
> > > -                                        "failed tx_urb %d\n", res);
> > > -                             stats->tx_dropped += agg->skb_num;
> > > +                     netif_warn(tp, tx_err, netdev,
> > > +                                "failed tx_urb %d\n", res);
> > > +                     stats->tx_dropped += agg->skb_num;
> > >
> > > -                             spin_lock_irqsave(&tp->tx_lock, flags);
> > > -                             list_add_tail(&agg->list, &tp->tx_free);
> > > -                             spin_unlock_irqrestore(&tp->tx_lock, flags);
> > > -                     }
> > > +                     spin_lock_irqsave(&tp->tx_lock, flags);
> > > +                     list_add_tail(&agg->list, &tp->tx_free);
> > > +                     spin_unlock_irqrestore(&tp->tx_lock, flags);
> > >               }
> > > -     } while (res == 0);
> > > +     }
> >
> > I think the behavior is different from the current one.
> >
> > Best Regards,
> > Hayes
> >

^ permalink raw reply

* Re: Fwd: [PATCH] bonding/802.3ad: fix slave initialization states race
From: Jay Vosburgh @ 2019-09-25  0:31 UTC (permalink / raw)
  To: =?UTF-8?B?0JDQu9C10LrRgdC10Lkg0JfQsNGF0LDRgNC+0LI=?=; +Cc: netdev, zhangsha (A)
In-Reply-To: <CAJYOGF_XStpFRkp0jN0um9d9WR1bqGpK2V=UgdnnX2m4YC=5pw@mail.gmail.com>

Алексей Захаров wrote:
[...]
>Right after reboot one of the slaves hangs with actor port state 71
>and partner port state 1.
>It doesn't send lacpdu and seems to be broken.
>Setting link down and up again fixes slave state.
[...]

	I think I see what failed in the first patch, could you test the
following patch?  This one is for net-next, so you'd need to again swap
slave_err / netdev_err for the Ubuntu 4.15 kernel.

	Thanks,

	-J


diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 931d9d935686..5e248588259a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1617,6 +1617,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	if (bond->params.miimon) {
 		if (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS) {
 			if (bond->params.updelay) {
+/*XXX*/slave_info(bond_dev, slave_dev, "BOND_LINK_BACK initial state\n");
 				bond_set_slave_link_state(new_slave,
 							  BOND_LINK_BACK,
 							  BOND_SLAVE_NOTIFY_NOW);
@@ -2086,8 +2087,7 @@ static int bond_miimon_inspect(struct bonding *bond)
 	ignore_updelay = !rcu_dereference(bond->curr_active_slave);
 
 	bond_for_each_slave_rcu(bond, slave, iter) {
-		slave->new_link = BOND_LINK_NOCHANGE;
-		slave->link_new_state = slave->link;
+		bond_propose_link_state(slave, BOND_LINK_NOCHANGE);
 
 		link_state = bond_check_dev_link(bond, slave->dev, 0);
 
@@ -2096,8 +2096,6 @@ static int bond_miimon_inspect(struct bonding *bond)
 			if (link_state)
 				continue;
 
-			bond_propose_link_state(slave, BOND_LINK_FAIL);
-			commit++;
 			slave->delay = bond->params.downdelay;
 			if (slave->delay) {
 				slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n",
@@ -2106,6 +2104,7 @@ static int bond_miimon_inspect(struct bonding *bond)
 					    (bond_is_active_slave(slave) ?
 					     "active " : "backup ") : "",
 					   bond->params.downdelay * bond->params.miimon);
+				slave->link = BOND_LINK_FAIL;
 			}
 			/*FALLTHRU*/
 		case BOND_LINK_FAIL:
@@ -2121,7 +2120,7 @@ static int bond_miimon_inspect(struct bonding *bond)
 			}
 
 			if (slave->delay <= 0) {
-				slave->new_link = BOND_LINK_DOWN;
+				bond_propose_link_state(slave, BOND_LINK_DOWN);
 				commit++;
 				continue;
 			}
@@ -2133,15 +2132,13 @@ static int bond_miimon_inspect(struct bonding *bond)
 			if (!link_state)
 				continue;
 
-			bond_propose_link_state(slave, BOND_LINK_BACK);
-			commit++;
 			slave->delay = bond->params.updelay;
-
 			if (slave->delay) {
 				slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n",
 					   ignore_updelay ? 0 :
 					   bond->params.updelay *
 					   bond->params.miimon);
+				slave->link = BOND_LINK_BACK;
 			}
 			/*FALLTHRU*/
 		case BOND_LINK_BACK:
@@ -2158,7 +2155,7 @@ static int bond_miimon_inspect(struct bonding *bond)
 				slave->delay = 0;
 
 			if (slave->delay <= 0) {
-				slave->new_link = BOND_LINK_UP;
+				bond_propose_link_state(slave, BOND_LINK_UP);
 				commit++;
 				ignore_updelay = false;
 				continue;
@@ -2196,7 +2193,7 @@ static void bond_miimon_commit(struct bonding *bond)
 	struct slave *slave, *primary;
 
 	bond_for_each_slave(bond, slave, iter) {
-		switch (slave->new_link) {
+		switch (slave->link_new_state) {
 		case BOND_LINK_NOCHANGE:
 			/* For 802.3ad mode, check current slave speed and
 			 * duplex again in case its port was disabled after
@@ -2268,8 +2265,8 @@ static void bond_miimon_commit(struct bonding *bond)
 
 		default:
 			slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n",
-				  slave->new_link);
-			slave->new_link = BOND_LINK_NOCHANGE;
+				  slave->link_new_state);
+			bond_propose_link_state(slave, BOND_LINK_NOCHANGE);
 
 			continue;
 		}
@@ -2677,13 +2674,13 @@ static void bond_loadbalance_arp_mon(struct bonding *bond)
 	bond_for_each_slave_rcu(bond, slave, iter) {
 		unsigned long trans_start = dev_trans_start(slave->dev);
 
-		slave->new_link = BOND_LINK_NOCHANGE;
+		bond_propose_link_state(slave, BOND_LINK_NOCHANGE);
 
 		if (slave->link != BOND_LINK_UP) {
 			if (bond_time_in_interval(bond, trans_start, 1) &&
 			    bond_time_in_interval(bond, slave->last_rx, 1)) {
 
-				slave->new_link = BOND_LINK_UP;
+				bond_propose_link_state(slave, BOND_LINK_UP);
 				slave_state_changed = 1;
 
 				/* primary_slave has no meaning in round-robin
@@ -2708,7 +2705,7 @@ static void bond_loadbalance_arp_mon(struct bonding *bond)
 			if (!bond_time_in_interval(bond, trans_start, 2) ||
 			    !bond_time_in_interval(bond, slave->last_rx, 2)) {
 
-				slave->new_link = BOND_LINK_DOWN;
+				bond_propose_link_state(slave, BOND_LINK_DOWN);
 				slave_state_changed = 1;
 
 				if (slave->link_failure_count < UINT_MAX)
@@ -2739,8 +2736,8 @@ static void bond_loadbalance_arp_mon(struct bonding *bond)
 			goto re_arm;
 
 		bond_for_each_slave(bond, slave, iter) {
-			if (slave->new_link != BOND_LINK_NOCHANGE)
-				slave->link = slave->new_link;
+			if (slave->link_new_state != BOND_LINK_NOCHANGE)
+				slave->link = slave->link_new_state;
 		}
 
 		if (slave_state_changed) {
@@ -2763,9 +2760,9 @@ static void bond_loadbalance_arp_mon(struct bonding *bond)
 }
 
 /* Called to inspect slaves for active-backup mode ARP monitor link state
- * changes.  Sets new_link in slaves to specify what action should take
- * place for the slave.  Returns 0 if no changes are found, >0 if changes
- * to link states must be committed.
+ * changes.  Sets proposed link state in slaves to specify what action
+ * should take place for the slave.  Returns 0 if no changes are found, >0
+ * if changes to link states must be committed.
  *
  * Called with rcu_read_lock held.
  */
@@ -2777,12 +2774,12 @@ static int bond_ab_arp_inspect(struct bonding *bond)
 	int commit = 0;
 
 	bond_for_each_slave_rcu(bond, slave, iter) {
-		slave->new_link = BOND_LINK_NOCHANGE;
+		bond_propose_link_state(slave, BOND_LINK_NOCHANGE);
 		last_rx = slave_last_rx(bond, slave);
 
 		if (slave->link != BOND_LINK_UP) {
 			if (bond_time_in_interval(bond, last_rx, 1)) {
-				slave->new_link = BOND_LINK_UP;
+				bond_propose_link_state(slave, BOND_LINK_UP);
 				commit++;
 			}
 			continue;
@@ -2810,7 +2807,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)
 		if (!bond_is_active_slave(slave) &&
 		    !rcu_access_pointer(bond->current_arp_slave) &&
 		    !bond_time_in_interval(bond, last_rx, 3)) {
-			slave->new_link = BOND_LINK_DOWN;
+			bond_propose_link_state(slave, BOND_LINK_DOWN);
 			commit++;
 		}
 
@@ -2823,7 +2820,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)
 		if (bond_is_active_slave(slave) &&
 		    (!bond_time_in_interval(bond, trans_start, 2) ||
 		     !bond_time_in_interval(bond, last_rx, 2))) {
-			slave->new_link = BOND_LINK_DOWN;
+			bond_propose_link_state(slave, BOND_LINK_DOWN);
 			commit++;
 		}
 	}
@@ -2843,7 +2840,7 @@ static void bond_ab_arp_commit(struct bonding *bond)
 	struct slave *slave;
 
 	bond_for_each_slave(bond, slave, iter) {
-		switch (slave->new_link) {
+		switch (slave->link_new_state) {
 		case BOND_LINK_NOCHANGE:
 			continue;
 
@@ -2893,8 +2890,9 @@ static void bond_ab_arp_commit(struct bonding *bond)
 			continue;
 
 		default:
-			slave_err(bond->dev, slave->dev, "impossible: new_link %d on slave\n",
-				  slave->new_link);
+			slave_err(bond->dev, slave->dev,
+				  "impossible: link_new_state %d on slave\n",
+				  slave->link_new_state);
 			continue;
 		}
 
@@ -3133,6 +3131,7 @@ static int bond_slave_netdev_event(unsigned long event,
 		 * let link-monitoring (miimon) set it right when correct
 		 * speeds/duplex are available.
 		 */
+/*XXX*/slave_info(bond_dev, slave_dev, "EVENT %lu llu %lu\n", event, slave->last_link_up);
 		if (bond_update_speed_duplex(slave) &&
 		    BOND_MODE(bond) == BOND_MODE_8023AD) {
 			if (slave->last_link_up)
diff --git a/include/net/bonding.h b/include/net/bonding.h
index f7fe45689142..d416af72404b 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -159,7 +159,6 @@ struct slave {
 	unsigned long target_last_arp_rx[BOND_MAX_ARP_TARGETS];
 	s8     link;		/* one of BOND_LINK_XXXX */
 	s8     link_new_state;	/* one of BOND_LINK_XXXX */
-	s8     new_link;
 	u8     backup:1,   /* indicates backup slave. Value corresponds with
 			      BOND_STATE_ACTIVE and BOND_STATE_BACKUP */
 	       inactive:1, /* indicates inactive slave */
@@ -549,7 +548,7 @@ static inline void bond_propose_link_state(struct slave *slave, int state)
 
 static inline void bond_commit_link_state(struct slave *slave, bool notify)
 {
-	if (slave->link == slave->link_new_state)
+	if (slave->link_new_state == BOND_LINK_NOCHANGE)
 		return;
 
 	slave->link = slave->link_new_state;


---
	-Jay Vosburgh, jay.vosburgh@canonical.com

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox