Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH 3/3] bpf: Make sure that ->comm does not change under us.
From: Alexei Starovoitov @ 2017-10-16 22:10 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Daniel Borkmann, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Alexei Starovoitov

On Mon, Oct 16, 2017 at 2:10 PM, Richard Weinberger <richard@nod.at> wrote:
> Am Montag, 16. Oktober 2017, 23:02:06 CEST schrieb Daniel Borkmann:
>> On 10/16/2017 10:55 PM, Richard Weinberger wrote:
>> > Am Montag, 16. Oktober 2017, 22:50:43 CEST schrieb Daniel Borkmann:
>> >>>           struct task_struct *task = current;
>> >>>
>> >>> + task_lock(task);
>> >>>
>> >>>           strncpy(buf, task->comm, size);
>> >>>
>> >>> + task_unlock(task);
>> >>
>> >> Wouldn't this potentially lead to a deadlock? E.g. you attach yourself
>> >> to task_lock() / spin_lock() / etc, and then the BPF prog triggers the
>> >> bpf_get_current_comm() taking the lock again ...
>> >
>> > Yes, but doesn't the same apply to the use case when I attach to strncpy()
>> > and run bpf_get_current_comm()?
>>
>> You mean due to recursion? In that case trace_call_bpf() would bail out
>> due to the bpf_prog_active counter.
>
> Ah, that's true.
> So, when someone wants to use bpf_get_current_comm() while tracing task_lock,
> we have a problem. I agree.
> On the other hand, without locking the function may return wrong results.

it will surely race with somebody else setting task comm and it's fine.
all of bpf tracing is read-only, so locks are only allowed inside bpf core
bits like maps. Taking core locks like task_lock() is quite scary.
bpf scripts rely on bpf_probe_read() of all sorts of kernel fields
so reading comm here w/o lock is fine.

^ permalink raw reply

* RE: [next-queue PATCH v7 4/6] net/sched: Introduce Credit Based Shaper (CBS) qdisc
From: Vinicius Costa Gomes @ 2017-10-16 22:13 UTC (permalink / raw)
  To: David Laight, 'Ivan Khoronzhuk'
  Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
	jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	andre.guedes@intel.com, ivan.briano@intel.com,
	jesus.sanchez-palencia@intel.com, boon.leong.ong@intel.com,
	richardcochran@gmail.com, henrik@austad.us, levipearson@gmail.com,
	rodney.cummings@ni.com
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DD00979BC@AcuExch.aculab.com>

Hi David,

David Laight <David.Laight@ACULAB.COM> writes:

[...]

>> > index 099bf5528fed..41e349df4bf4 100644
>> > --- a/include/uapi/linux/pkt_sched.h
>> > +++ b/include/uapi/linux/pkt_sched.h
>> > @@ -871,4 +871,22 @@ struct tc_pie_xstats {
>> >  	__u32 maxq;             /* maximum queue size */
>> >  	__u32 ecn_mark;         /* packets marked with ecn*/
>> >  };
>> > +
>> > +/* CBS */
>> > +struct tc_cbs_qopt {
>> > +	__u8 offload;
>
> You probably don't want unnamed padding in a uapi structure.

Yeah, this needs to be fixed.

>
>> > +	__s32 hicredit;
>> > +	__s32 locredit;
>> > +	__s32 idleslope;
>> > +	__s32 sendslope;
>> > +};
>> > +
>> > +enum {
>> > +	TCA_CBS_UNSPEC,
>> > +	TCA_CBS_PARMS,
>> > +	__TCA_CBS_MAX,
>> > +};
>> > +
>> > +#define TCA_CBS_MAX (__TCA_CBS_MAX - 1)
>
> Why not:
> 	TCA_CBS_PARMS,
> 	TCA_CBS_NEXT,
> 	TCA_CBS_MAX = TCA_CBS_NEXT - 1,

The way it is proposed, at least is consistent with the rest of the
file. So, if you don't have any stronger reasons, I'd like to keep it
this way.

>
> ...
> 	David


Cheers,

^ permalink raw reply

* Re: [PATCH 3/3] bpf: Make sure that ->comm does not change under us.
From: Daniel Borkmann @ 2017-10-16 22:19 UTC (permalink / raw)
  To: Alexei Starovoitov, Richard Weinberger
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alexei Starovoitov
In-Reply-To: <CAADnVQ+0kTYr2azBW6mDSU6JwWtjWRZVaJQ=ZFmSs3JxCFrrRg@mail.gmail.com>

On 10/17/2017 12:10 AM, Alexei Starovoitov wrote:
> On Mon, Oct 16, 2017 at 2:10 PM, Richard Weinberger <richard@nod.at> wrote:
>> Am Montag, 16. Oktober 2017, 23:02:06 CEST schrieb Daniel Borkmann:
>>> On 10/16/2017 10:55 PM, Richard Weinberger wrote:
>>>> Am Montag, 16. Oktober 2017, 22:50:43 CEST schrieb Daniel Borkmann:
>>>>>>            struct task_struct *task = current;
>>>>>>
>>>>>> + task_lock(task);
>>>>>>
>>>>>>            strncpy(buf, task->comm, size);
>>>>>>
>>>>>> + task_unlock(task);
>>>>>
>>>>> Wouldn't this potentially lead to a deadlock? E.g. you attach yourself
>>>>> to task_lock() / spin_lock() / etc, and then the BPF prog triggers the
>>>>> bpf_get_current_comm() taking the lock again ...
>>>>
>>>> Yes, but doesn't the same apply to the use case when I attach to strncpy()
>>>> and run bpf_get_current_comm()?
>>>
>>> You mean due to recursion? In that case trace_call_bpf() would bail out
>>> due to the bpf_prog_active counter.
>>
>> Ah, that's true.
>> So, when someone wants to use bpf_get_current_comm() while tracing task_lock,
>> we have a problem. I agree.
>> On the other hand, without locking the function may return wrong results.
>
> it will surely race with somebody else setting task comm and it's fine.
> all of bpf tracing is read-only, so locks are only allowed inside bpf core
> bits like maps. Taking core locks like task_lock() is quite scary.
> bpf scripts rely on bpf_probe_read() of all sorts of kernel fields
> so reading comm here w/o lock is fine.

Yeah, and perf_event_comm() -> perf_event_comm_event() out of __set_task_comm()
is having same approach wrt comm read-out.

^ permalink raw reply

* Re: [next-queue PATCH v8 0/6] TSN: Add qdisc based config interface for CBS
From: Vinicius Costa Gomes @ 2017-10-16 22:20 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, intel-wired-lan, jhs, xiyou.wangcong, jiri, andre.guedes,
	ivan.briano, jesus.sanchez-palencia, boon.leong.ong,
	richardcochran, henrik, levipearson, rodney.cummings
In-Reply-To: <20171016.205146.1053238236578937188.davem@davemloft.net>

Hi David,

David Miller <davem@davemloft.net> writes:

> I'm fine with this patch set.  I see it's against Jeff's next-queue, so
> where exactly do you want this to be merged?  My net-next tree?

I think it going through Jeff's next-queue makes more sense.

Anyway, I will send a v9 later today fixing the padding issue that David
Laight pointed out.

>
> Thank you.

Cheers,

^ permalink raw reply

* Re: [PATCH 1/3] bpf: Don't check for current being NULL
From: Richard Weinberger @ 2017-10-16 22:23 UTC (permalink / raw)
  To: Alexei Starovoitov, Al Viro
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Daniel Borkmann, Alexei Starovoitov, linux-arch
In-Reply-To: <CAADnVQJzM3DH_gxAwo2mnGiv7bOsip1TAFF8YGPLx-dqSb1SPQ@mail.gmail.com>

Alexei,

Am Dienstag, 17. Oktober 2017, 00:06:08 CEST schrieb Alexei Starovoitov:
> On Mon, Oct 16, 2017 at 11:18 AM, Richard Weinberger <richard@nod.at> wrote:
> > current is never NULL.
> > 
> > Signed-off-by: Richard Weinberger <richard@nod.at>
> > ---
> > 
> >  kernel/bpf/helpers.c | 12 ------------
> >  1 file changed, 12 deletions(-)
> > 
> > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> > index 3d24e238221e..e8845adcd15e 100644
> > --- a/kernel/bpf/helpers.c
> > +++ b/kernel/bpf/helpers.c
> > @@ -120,9 +120,6 @@ BPF_CALL_0(bpf_get_current_pid_tgid)
> > 
> >  {
> >  
> >         struct task_struct *task = current;
> > 
> > -       if (unlikely(!task))
> > -               return -EINVAL;
> > -
> 
> really? in all context? including irq and nmi?

I would be astonished current is NULL in such a context.

To be sure, let's CC linux-arch.
IIRC I talked also with Al about this and he also assumed that current
cannot be NULL.

Thanks,
//richard

^ permalink raw reply

* Re: [PATCH 1/3] bpf: Don't check for current being NULL
From: Alexei Starovoitov @ 2017-10-16 22:31 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Al Viro, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Daniel Borkmann, Alexei Starovoitov, linux-arch
In-Reply-To: <1838884.qlCOuH57mO@blindfold>

On Tue, Oct 17, 2017 at 12:23:13AM +0200, Richard Weinberger wrote:
> Alexei,
> 
> Am Dienstag, 17. Oktober 2017, 00:06:08 CEST schrieb Alexei Starovoitov:
> > On Mon, Oct 16, 2017 at 11:18 AM, Richard Weinberger <richard@nod.at> wrote:
> > > current is never NULL.
> > > 
> > > Signed-off-by: Richard Weinberger <richard@nod.at>
> > > ---
> > > 
> > >  kernel/bpf/helpers.c | 12 ------------
> > >  1 file changed, 12 deletions(-)
> > > 
> > > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> > > index 3d24e238221e..e8845adcd15e 100644
> > > --- a/kernel/bpf/helpers.c
> > > +++ b/kernel/bpf/helpers.c
> > > @@ -120,9 +120,6 @@ BPF_CALL_0(bpf_get_current_pid_tgid)
> > > 
> > >  {
> > >  
> > >         struct task_struct *task = current;
> > > 
> > > -       if (unlikely(!task))
> > > -               return -EINVAL;
> > > -
> > 
> > really? in all context? including irq and nmi?
> 
> I would be astonished current is NULL in such a context.
> 
> To be sure, let's CC linux-arch.
> IIRC I talked also with Al about this and he also assumed that current
> cannot be NULL.

Hmm I probably mistakenly stole the !current check from somewhere.
Happy to delete all these checks then.

^ permalink raw reply

* [PATCH v2 net-next] tcp: Check daddr_cache before use in tracepoint
From: David Ahern @ 2017-10-16 22:32 UTC (permalink / raw)
  To: netdev; +Cc: xiyou.wangcong, David Ahern

Running perf in one window to capture tcp_retransmit_skb tracepoint:
    $ perf record -e tcp:tcp_retransmit_skb -a

And causing a retransmission on an active TCP session (e.g., dropping
packets in the receiver, changing MTU on the interface to 500 and back
to 1500) triggers a panic:

[   58.543144] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
[   58.545300] IP: perf_trace_tcp_retransmit_skb+0xd0/0x145
[   58.546770] PGD 0 P4D 0
[   58.547472] Oops: 0000 [#1] SMP
[   58.548328] Modules linked in: vrf
[   58.549262] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.0-rc4+ #26
[   58.551004] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[   58.554560] task: ffffffff81a0e540 task.stack: ffffffff81a00000
[   58.555817] RIP: 0010:perf_trace_tcp_retransmit_skb+0xd0/0x145
[   58.557137] RSP: 0018:ffff88003fc03d68 EFLAGS: 00010282
[   58.558292] RAX: 0000000000000000 RBX: ffffe8ffffc0ec80 RCX: ffff880038543098
[   58.559850] RDX: 0400000000000000 RSI: ffff88003fc03d70 RDI: ffff88003fc14b68
[   58.561099] RBP: ffff88003fc03da8 R08: 0000000000000000 R09: ffffea0000d3224a
[   58.562005] R10: ffff88003fc03db8 R11: 0000000000000010 R12: ffff8800385428c0
[   58.562930] R13: ffffe8ffffc0e478 R14: ffffffff81a93a40 R15: ffff88003d4f0c00
[   58.563845] FS:  0000000000000000(0000) GS:ffff88003fc00000(0000) knlGS:0000000000000000
[   58.564873] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.565613] CR2: 0000000000000008 CR3: 000000003d68f004 CR4: 00000000000606f0
[   58.566538] Call Trace:
[   58.566865]  <IRQ>
[   58.567140]  __tcp_retransmit_skb+0x4ab/0x4c6
[   58.567704]  ? tcp_set_ca_state+0x22/0x3f
[   58.568231]  tcp_retransmit_skb+0x14/0xa3
[   58.568754]  tcp_retransmit_timer+0x472/0x5e3
[   58.569324]  ? tcp_write_timer_handler+0x1e9/0x1e9
[   58.569946]  tcp_write_timer_handler+0x95/0x1e9
[   58.570548]  tcp_write_timer+0x2a/0x58

Check that daddr_cache is non-NULL before de-referencing.

Fixes: e086101b150a ("tcp: add a tracepoint for tcp retransmission")
Signed-off-by: David Ahern <dsahern@gmail.com>
---
v2
- remove np and get addresses from sock_common
 
 include/trace/events/tcp.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 1ffab6d96e94..f51c130f1e0f 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -27,7 +27,6 @@ TRACE_EVENT(tcp_retransmit_skb,
 	),
 
 	TP_fast_assign(
-		struct ipv6_pinfo *np = inet6_sk(sk);
 		struct inet_sock *inet = inet_sk(sk);
 		struct in6_addr *pin6;
 		__be32 *p32;
@@ -44,11 +43,12 @@ TRACE_EVENT(tcp_retransmit_skb,
 		p32 = (__be32 *) __entry->daddr;
 		*p32 =  inet->inet_daddr;
 
-		if (np) {
+		/* IPv6 socket ? */
+		if (inet6_sk(sk)) {
 			pin6 = (struct in6_addr *)__entry->saddr_v6;
-			*pin6 = np->saddr;
+			*pin6 = sk->sk_v6_rcv_saddr;
 			pin6 = (struct in6_addr *)__entry->daddr_v6;
-			*pin6 = *(np->daddr_cache);
+			*pin6 = sk->sk_v6_daddr;
 		} else {
 			pin6 = (struct in6_addr *)__entry->saddr_v6;
 			ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
-- 
2.1.4

^ permalink raw reply related

* Re: [PATCH net-next] tcp: Use pI6c in tcp tracepoint
From: Alexei Starovoitov @ 2017-10-16 22:33 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, xiyou.wangcong
In-Reply-To: <1508189042-19591-1-git-send-email-dsahern@gmail.com>

On Mon, Oct 16, 2017 at 02:24:02PM -0700, David Ahern wrote:
> The compact form for IPv6 addresses is more user friendly than the full
> version. For example:
>    compact: 2001:db8:1::1
>       full: 2001:0db8:0001:0000:0000:0000:0000:0004i
> 
> Update the tcp tracepoint to show the compact form.
> 
> Signed-off-by: David Ahern <dsahern@gmail.com>

nice improvement.
Acked-by: Alexei Starovoitov <ast@kernel.org>

^ permalink raw reply

* Re: [PATCH net-next] virtio_net: implement VIRTIO_CONFIG_S_NEEDS_RESET
From: Willem de Bruijn @ 2017-10-16 22:34 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Network Development, David Miller, Jason Wang, virtualization,
	Willem de Bruijn
In-Reply-To: <20171016191806-mutt-send-email-mst@kernel.org>

On Mon, Oct 16, 2017 at 12:38 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Mon, Oct 16, 2017 at 12:04:57PM -0400, Willem de Bruijn wrote:
>> On Mon, Oct 16, 2017 at 11:31 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
>> > On Mon, Oct 16, 2017 at 11:03:18AM -0400, Willem de Bruijn wrote:
>> >> >> +static int virtnet_reset(struct virtnet_info *vi)
>> >> >> +{
>> >> >> +     struct virtio_device *dev = vi->vdev;
>> >> >> +     int ret;
>> >> >> +
>> >> >> +     virtio_config_disable(dev);
>> >> >> +     dev->failed = dev->config->get_status(dev) & VIRTIO_CONFIG_S_FAILED;
>> >> >> +     virtnet_freeze_down(dev, true);
>> >> >> +     remove_vq_common(vi);
>> >> >> +
>> >> >> +     virtio_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
>> >> >> +     virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER);
>> >> >> +
>> >> >> +     ret = virtio_finalize_features(dev);
>> >> >> +     if (ret)
>> >> >> +             goto err;
>> >> >> +
>> >> >> +     ret = virtnet_restore_up(dev);
>> >> >> +     if (ret)
>> >> >> +             goto err;
>> >> >> +
>> >> >> +     ret = virtnet_set_queues(vi, vi->curr_queue_pairs);
>> >> >> +     if (ret)
>> >> >> +             goto err;
>> >> >> +
>> >> >> +     virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
>> >> >> +     virtio_config_enable(dev);
>> >> >> +     return 0;
>> >> >> +
>> >> >> +err:
>> >> >> +     virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
>> >> >> +     return ret;
>> >> >> +}
>> >> >> +
>> >> >>  static int virtnet_set_guest_offloads(struct virtnet_info *vi, u64 offloads)
>> >> >>  {
>> >> >>       struct scatterlist sg;
>> >> >
>> >> > I have a question here though. How do things like MAC address
>> >> > get restored?
>> >> >
>> >> > What about the rx mode?
>> >> >
>> >> > vlans?
>> >>
>> >> The function as is releases and reinitializes only ring state.
>> >> Device configuration such as mac and vlan persist across
>> >> the reset.
>> >
>> > What gave you this impression? Take a look at e.g. this
>> > code in qemu:
>> >
>> > static void virtio_net_reset(VirtIODevice *vdev)
>> > {
>> >     VirtIONet *n = VIRTIO_NET(vdev);
>> >
>> >     /* Reset back to compatibility mode */
>> >     n->promisc = 1;
>> >     n->allmulti = 0;
>> >     n->alluni = 0;
>> >     n->nomulti = 0;
>> >     n->nouni = 0;
>> >     n->nobcast = 0;
>> >     /* multiqueue is disabled by default */
>> >     n->curr_queues = 1;
>> >     timer_del(n->announce_timer);
>> >     n->announce_counter = 0;
>> >     n->status &= ~VIRTIO_NET_S_ANNOUNCE;
>> >
>> >     /* Flush any MAC and VLAN filter table state */
>> >     n->mac_table.in_use = 0;
>> >     n->mac_table.first_multi = 0;
>> >     n->mac_table.multi_overflow = 0;
>> >     n->mac_table.uni_overflow = 0;
>> >     memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);
>> >     memcpy(&n->mac[0], &n->nic->conf->macaddr, sizeof(n->mac));
>> >     qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
>> >     memset(n->vlans, 0, MAX_VLAN >> 3);
>> > }
>> >
>> > So device seems to lose all state, you have to re-program it.
>>
>> Oh, indeed! The guest does not reset its state, so it might
>> be out of sync with the host after the operation. Was this not
>> an issue when previously resetting in the context of xdp?
>
> I suspect it was broken back then, too.

Okay. I guess that in principle this is all programmable through
virtnet_set_rx_mode, virtnet_vlan_rx_add_vid, etc. But it's a
lot more complex than just restoring virtnet_reset. Will need to
be careful about concurrency issues at the least. Similar to the
ones you point out below.

>
>> >> > Also, it seems that LINK_ANNOUNCE requests will get ignored
>> >> > even if they got set before the reset, leading to downtime.
>> >>
>> >> Do you mean act on VIRTIO_NET_F_GUEST_ANNOUNCE
>> >> requests? That flag is tested and netdev_notify_peers
>> >> called before resetting virtio ring state.
>> >
>> > Yes but I wonder if there's a race where announce
>> > is set after it is read but before NEED_RESET is read.
>> >
>> > Re-reading status from the config before reset
>> > might be necessary.
>>
>> Thanks, I'll have a look. Perhaps a host should simply not
>> request a reset while it is waiting for an announce ack.
>
> It's one option though we can't make this change for existing hosts.
> We also have the reverse condition where announce is requested after
> NEED_RESET is set.

^ permalink raw reply

* Re: [PATCH v2 net-next] tcp: Check daddr_cache before use in tracepoint
From: Cong Wang @ 2017-10-16 22:35 UTC (permalink / raw)
  To: David Ahern; +Cc: Linux Kernel Network Developers
In-Reply-To: <1508193127-17626-1-git-send-email-dsahern@gmail.com>

On Mon, Oct 16, 2017 at 3:32 PM, David Ahern <dsahern@gmail.com> wrote:
> Running perf in one window to capture tcp_retransmit_skb tracepoint:
>     $ perf record -e tcp:tcp_retransmit_skb -a
>
> And causing a retransmission on an active TCP session (e.g., dropping
> packets in the receiver, changing MTU on the interface to 500 and back
> to 1500) triggers a panic:
>
> [   58.543144] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
> [   58.545300] IP: perf_trace_tcp_retransmit_skb+0xd0/0x145
> [   58.546770] PGD 0 P4D 0
> [   58.547472] Oops: 0000 [#1] SMP
> [   58.548328] Modules linked in: vrf
> [   58.549262] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.0-rc4+ #26
> [   58.551004] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
> [   58.554560] task: ffffffff81a0e540 task.stack: ffffffff81a00000
> [   58.555817] RIP: 0010:perf_trace_tcp_retransmit_skb+0xd0/0x145
> [   58.557137] RSP: 0018:ffff88003fc03d68 EFLAGS: 00010282
> [   58.558292] RAX: 0000000000000000 RBX: ffffe8ffffc0ec80 RCX: ffff880038543098
> [   58.559850] RDX: 0400000000000000 RSI: ffff88003fc03d70 RDI: ffff88003fc14b68
> [   58.561099] RBP: ffff88003fc03da8 R08: 0000000000000000 R09: ffffea0000d3224a
> [   58.562005] R10: ffff88003fc03db8 R11: 0000000000000010 R12: ffff8800385428c0
> [   58.562930] R13: ffffe8ffffc0e478 R14: ffffffff81a93a40 R15: ffff88003d4f0c00
> [   58.563845] FS:  0000000000000000(0000) GS:ffff88003fc00000(0000) knlGS:0000000000000000
> [   58.564873] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   58.565613] CR2: 0000000000000008 CR3: 000000003d68f004 CR4: 00000000000606f0
> [   58.566538] Call Trace:
> [   58.566865]  <IRQ>
> [   58.567140]  __tcp_retransmit_skb+0x4ab/0x4c6
> [   58.567704]  ? tcp_set_ca_state+0x22/0x3f
> [   58.568231]  tcp_retransmit_skb+0x14/0xa3
> [   58.568754]  tcp_retransmit_timer+0x472/0x5e3
> [   58.569324]  ? tcp_write_timer_handler+0x1e9/0x1e9
> [   58.569946]  tcp_write_timer_handler+0x95/0x1e9
> [   58.570548]  tcp_write_timer+0x2a/0x58
>
> Check that daddr_cache is non-NULL before de-referencing.
>
> Fixes: e086101b150a ("tcp: add a tracepoint for tcp retransmission")
> Signed-off-by: David Ahern <dsahern@gmail.com>

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>

^ permalink raw reply

* WARNING in tcp_update_reordering
From: David Ahern @ 2017-10-16 22:38 UTC (permalink / raw)
  To: Eric Dumazet, netdev@vger.kernel.org

I need to throw this one over the fence. I triggered the trace below
testing changes to the tcp tracepoint. It is not readily reproducible
and does not appear to be correlated to the perf session.

Triggered by the following:
  ssh into VM and run 'top -d1'
  in host, drop tcp packets:
    $ sudo iptables -I INPUT -i br1 -p tcp -j DROP
  and then 5 - 7 seconds later remove the rule:
    $ sudo iptables -D INPUT -i br1 -p tcp -j DROP

[   73.695849] ------------[ cut here ]------------
[   73.697258] WARNING: CPU: 1 PID: 0 at
/home/dsa/kernel-2.git/net/ipv4/tcp_input.c:889
tcp_update_reordering+0x4/0x72
[   73.700306] Modules linked in: vrf
[   73.701316] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.14.0-rc4+ #43
[   73.703170] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[   73.706040] task: ffff88003e132180 task.stack: ffffc90000078000
[   73.707769] RIP: 0010:tcp_update_reordering+0x4/0x72
[   73.709209] RSP: 0018:ffff88003fd039c0 EFLAGS: 00010282
[   73.710702] RAX: 0000000000000004 RBX: ffff88003c7be800 RCX:
0000000000000004
[   73.711797] RDX: 0000000000000000 RSI: 00000000fffffffb RDI:
ffff88003c7be800
[   73.712809] RBP: ffff88003fd03a38 R08: 0000000000000000 R09:
0000000000000000
[   73.713831] R10: ffff88003fd03a90 R11: 0000000000000000 R12:
ffff88003fd03a90
[   73.714846] R13: 0000000000000000 R14: ffff88003c7bef40 R15:
ffff88003c7bef48
[   73.715871] FS:  0000000000000000(0000) GS:ffff88003fd00000(0000)
knlGS:0000000000000000
[   73.717016] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   73.717823] CR2: 000056441f284000 CR3: 000000003d7ba002 CR4:
00000000000606e0
[   73.718834] Call Trace:
[   73.719193]  <IRQ>
[   73.719497]  ? tcp_sacktag_write_queue+0x533/0x5ab
[   73.720180]  ? tcp_mtu_to_mss+0xd/0x1c
[   73.720718]  tcp_ack+0x320/0xd21
[   73.721189]  tcp_rcv_established+0x251/0x2c2
[   73.721799]  tcp_v4_do_rcv+0x9a/0x169
[   73.722328]  tcp_v4_rcv+0x55c/0x7bb
[   73.722841]  ip_local_deliver_finish+0xc0/0x141
[   73.723486]  ip_local_deliver+0xa5/0xae
[   73.724038]  ? xfrm4_policy_check.constprop.10+0x52/0x52
[   73.724787]  ip_rcv_finish+0x2de/0x35c
[   73.725326]  ip_rcv+0x271/0x2ea
[   73.725787]  ? deliver_ptype_list_skb+0x48/0x69
[   73.726430]  __netif_receive_skb_core+0x326/0x54a
[   73.727112]  ? kvm_clock_read+0x1e/0x20
[   73.727664]  ? kvm_clock_get_cycles+0x9/0xb
[   73.728257]  __netif_receive_skb+0x16/0x6d
[   73.728837]  ? __netif_receive_skb+0x16/0x6d
[   73.729446]  netif_receive_skb_internal+0x4d/0xa3
[   73.730116]  napi_gro_receive+0x75/0xcc
[   73.730667]  receive_buf+0xa05/0xa16
[   73.731192]  ? vring_unmap_one+0x1a/0x68
[   73.731754]  virtnet_poll+0x103/0x1b1
[   73.732284]  net_rx_action+0xdb/0x249
[   73.732814]  __do_softirq+0xfc/0x26b
[   73.733332]  irq_exit+0x51/0x92
[   73.733788]  do_IRQ+0x98/0xb0
[   73.734225]  common_interrupt+0x93/0x93
[   73.734779]  </IRQ>
[   73.735095] RIP: 0010:native_safe_halt+0x6/0x8
[   73.735726] RSP: 0018:ffffc9000007bea8 EFLAGS: 00000246 ORIG_RAX:
ffffffffffffff6e
[   73.736784] RAX: 0000000000000000 RBX: 0000000000000000 RCX:
ffff88003fd10ca0
[   73.737776] RDX: 00000000000101ba RSI: 0000000000000001 RDI:
0000000000000001
[   73.738780] RBP: ffffc9000007bea8 R08: ffff88003d48a900 R09:
0000000000000200
[   73.739777] R10: 0000000000000003 R11: 0000000000000001 R12:
0000000000000000
[   73.740779] R13: ffff88003e132180 R14: ffff88003e132180 R15:
ffff88003e132180
[   73.741781]  default_idle+0x1a/0x2d
[   73.742285]  arch_cpu_idle+0xa/0xc
[   73.742784]  default_idle_call+0x19/0x1b
[   73.743352]  do_idle+0xd7/0x1a9
[   73.743807]  cpu_startup_entry+0x1a/0x1c
[   73.744371]  start_secondary+0x11e/0x120
[   73.744930]  secondary_startup_64+0xa5/0xa5
[   73.745526] Code: 02 74 0b 48 c7 87 e0 06 00 00 00 00 00 00 8a 97 2c
06 00 00 83 e0 0d c1 e0 04 5d 83 e2 0f 09 d0 88 87 2c 06 00 00 c3 85 f6
79 03 <0f> ff c3 3b b7 10 06 00 00 55 48 89 e5 41 54 41 89 d4 53 48 89
[   73.748142] ---[ end trace 730e0fcd13f383bc ]---

^ permalink raw reply

* Re: [PATCH net-next v6 1/5] bpf: Add file mode configuration into bpf maps
From: Daniel Borkmann @ 2017-10-16 22:59 UTC (permalink / raw)
  To: Chenbo Feng, netdev, SELinux, linux-security-module
  Cc: Jeffrey Vander Stoep, Alexei Starovoitov, lorenzo,
	Stephen Smalley, James Morris, Paul Moore, Chenbo Feng
In-Reply-To: <20171016191135.8046-2-chenbofeng.kernel@gmail.com>

On 10/16/2017 09:11 PM, Chenbo Feng wrote:
> From: Chenbo Feng <fengc@google.com>
>
> Introduce the map read/write flags to the eBPF syscalls that returns the
> map fd. The flags is used to set up the file mode when construct a new
> file descriptor for bpf maps. To not break the backward capability, the
> f_flags is set to O_RDWR if the flag passed by syscall is 0. Otherwise
> it should be O_RDONLY or O_WRONLY. When the userspace want to modify or
> read the map content, it will check the file mode to see if it is
> allowed to make the change.
>
> Signed-off-by: Chenbo Feng <fengc@google.com>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

^ permalink raw reply

* Re: [PATCH net-next v6 2/5] bpf: Add tests for eBPF file mode
From: Daniel Borkmann @ 2017-10-16 23:00 UTC (permalink / raw)
  To: Chenbo Feng, netdev, SELinux, linux-security-module
  Cc: Jeffrey Vander Stoep, Alexei Starovoitov, lorenzo,
	Stephen Smalley, James Morris, Paul Moore, Chenbo Feng
In-Reply-To: <20171016191135.8046-3-chenbofeng.kernel@gmail.com>

On 10/16/2017 09:11 PM, Chenbo Feng wrote:
> From: Chenbo Feng <fengc@google.com>
>
> Two related tests are added into bpf selftest to test read only map and
> write only map. The tests verified the read only and write only flags
> are working on hash maps.
>
> Signed-off-by: Chenbo Feng <fengc@google.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

^ permalink raw reply

* Re: net-next: WARNING: CPU: 0 PID: 1544 at net/ipv4/tcp_input.c:889
From: Andrei Vagin @ 2017-10-16 23:11 UTC (permalink / raw)
  To: Linux Kernel Network Developers, Eric Dumazet
In-Reply-To: <CANaxB-ymK1yfoK2312JZQH5h2=+50YBfO9oEnE1MJ=n=S_461Q@mail.gmail.com>

Hi Eric,

Could you take a look at this warning? It may be related with your
recent patches. First time we saw this warning 7 days ago
(net-next/master) and now we see it regularly.

I printed tp->fackets_out and state->reord  before the warnings and
here are values for them:
tp->fackets_out = -1 state->reord = 4

In my case, this warning is triggered for connections which have been
restored by CRIU.

Let me know if you need any other information. I can reproduce this
bugs for an hour.

Thanks,
Andrei

On Mon, Oct 9, 2017 at 11:07 AM, Andrei Vagin <avagin@gmail.com> wrote:
> Hello,
>
> We run CRIU tests on a daily basis for net-next and today they
> triggered a following warning:
>
>
> [   58.827039] ------------[ cut here ]------------
> [   58.827078] WARNING: CPU: 0 PID: 1544 at net/ipv4/tcp_input.c:889
> tcp_update_reordering+0x9f/0xb0
> [   58.827083] Modules linked in:
> [   58.827095] CPU: 0 PID: 1544 Comm: sshd Not tainted 4.14.0-rc3+ #1
> [   58.827101] Hardware name: Google Google Compute Engine/Google
> Compute Engine, BIOS Google 01/01/2011
> [   58.827106] task: ffff90f2633dcc80 task.stack: ffffb0e302800000
> [   58.827112] RIP: 0010:tcp_update_reordering+0x9f/0xb0
> [   58.827117] RSP: 0018:ffffb0e302803b28 EFLAGS: 00010282
> [   58.827126] RAX: 00000000fffffffd RBX: ffff90f29136e840 RCX: 0000000000000003
> [   58.827131] RDX: 0000000000000000 RSI: 00000000fffffffd RDI: ffff90f29136de80
> [   58.827136] RBP: ffffb0e302803b28 R08: 0000000000000044 R09: 00000000e59da6c6
> [   58.827142] R10: ffffb0e302803b68 R11: 00000000e59da70a R12: 00000000e59da6c6
> [   58.827147] R13: ffff90f29136e848 R14: ffff90f29136de80 R15: 0000000000000002
> [   58.827153] FS:  00007f52e8452840(0000) GS:ffff90f29fc00000(0000)
> knlGS:0000000000000000
> [   58.827158] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   58.827163] CR2: 000014727db10a10 CR3: 00000001d0967000 CR4: 00000000001406f0
> [   58.827172] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [   58.827177] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> [   58.827182] Call Trace:
> [   58.827191]  tcp_sacktag_write_queue+0x54d/0x860
> [   58.827206]  tcp_ack+0xa71/0x1360
> [   58.827229]  tcp_rcv_established+0x1da/0x560
> [   58.827241]  tcp_v4_do_rcv+0x139/0x1d0
> [   58.827251]  __release_sock+0x6d/0x110
> [   58.827260]  release_sock+0x30/0xb0
> [   58.827267]  tcp_sendmsg+0x37/0x50
> [   58.827276]  inet_sendmsg+0x45/0x1e0
> [   58.827287]  sock_sendmsg+0x38/0x50
> [   58.827295]  sock_write_iter+0x7e/0xd0
> [   58.827311]  __vfs_write+0xd4/0x150
> [   58.827325]  vfs_write+0xcd/0x1d0
> [   58.827332]  ? trace_hardirqs_on_caller+0x11f/0x190
> [   58.827341]  SyS_write+0x49/0xa0
> [   58.827353]  entry_SYSCALL_64_fastpath+0x23/0xc2
> [   58.827360] RIP: 0033:0x7f52e6186710
> [   58.827365] RSP: 002b:00007fffd37723b8 EFLAGS: 00000246 ORIG_RAX:
> 0000000000000001
> [   58.827375] RAX: ffffffffffffffda RBX: 000000002e3e9273 RCX: 00007f52e6186710
> [   58.827380] RDX: 0000000000000044 RSI: 0000557474a3e160 RDI: 0000000000000003
> [   58.827385] RBP: 00007f52e7237240 R08: 0000000000000006 R09: 0000000000000001
> [   58.827390] R10: 0000000000004da8 R11: 0000000000000246 R12: 000000005bb2be1e
> [   58.827396] R13: 00000000e9218d7d R14: 0000000059b77fb7 R15: 00000000505bdd2c
> [   58.827414] Code: b8 1d 00 00 00 c0 ea 04 84 d2 74 0b 89 d0 c1 e0
> 1e c1 f8 1f 83 c0 1c 48 8b 57 30 48 98 48 8b 92 00 02 00 00 65 48 ff
> 04 c2 5d c3 <0f> ff 5d c3 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f
> 44 00
> [   58.827724] ---[ end trace b8d78168bbc71c1f ]---
>
> Here is a fill log:
> https://travis-ci.org/avagin/linux/jobs/285457708

^ permalink raw reply

* [net-next:master 277/285] include/trace/events/xdp.h:91:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
From: kbuild test robot @ 2017-10-16 23:27 UTC (permalink / raw)
  To: Steven Rostedt (VMware); +Cc: kbuild-all, netdev

[-- Attachment #1: Type: text/plain, Size: 25064 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
head:   e4467f2e2442e15cf047c2e7b91cb44a643cb149
commit: 9185a610f8f7f1b4e4d28c9de27d1969cf58e0f1 [277/285] tracing: bpf: Hide bpf trace events when they are not used
config: i386-randconfig-x0-10170550 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        git checkout 9185a610f8f7f1b4e4d28c9de27d1969cf58e0f1
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/trace/events/xdp.h:9:0,
                    from include/linux/bpf_trace.h:5,
                    from drivers/net/ethernet/mellanox/mlx5/core/en_rx.c:37:
>> include/trace/events/xdp.h:91:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:187:34: note: in definition of macro '__DECLARE_TRACE'
     static inline void trace_##name(proto)    \
                                     ^~~~~
>> include/linux/tracepoint.h:352:24: note: in expansion of macro 'PARAMS'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
                           ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
>> include/trace/events/xdp.h:87:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
    ^~~~~~~~~~~~
>> include/trace/events/xdp.h:88:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
>> include/trace/events/xdp.h:91:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:203:38: note: in definition of macro '__DECLARE_TRACE'
     register_trace_##name(void (*probe)(data_proto), void *data) \
                                         ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
>> include/trace/events/xdp.h:87:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
    ^~~~~~~~~~~~
>> include/trace/events/xdp.h:88:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
>> include/trace/events/xdp.h:91:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:209:43: note: in definition of macro '__DECLARE_TRACE'
     register_trace_prio_##name(void (*probe)(data_proto), void *data,\
                                              ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
>> include/trace/events/xdp.h:87:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
    ^~~~~~~~~~~~
>> include/trace/events/xdp.h:88:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
>> include/trace/events/xdp.h:91:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:216:40: note: in definition of macro '__DECLARE_TRACE'
     unregister_trace_##name(void (*probe)(data_proto), void *data) \
                                           ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
>> include/trace/events/xdp.h:87:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
    ^~~~~~~~~~~~
>> include/trace/events/xdp.h:88:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
>> include/trace/events/xdp.h:91:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:222:46: note: in definition of macro '__DECLARE_TRACE'
     check_trace_callback_type_##name(void (*cb)(data_proto)) \
                                                 ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
>> include/trace/events/xdp.h:87:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
    ^~~~~~~~~~~~
>> include/trace/events/xdp.h:88:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:99:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:187:34: note: in definition of macro '__DECLARE_TRACE'
     static inline void trace_##name(proto)    \
                                     ^~~~~
>> include/linux/tracepoint.h:352:24: note: in expansion of macro 'PARAMS'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
                           ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
   include/trace/events/xdp.h:95:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
    ^~~~~~~~~~~~
   include/trace/events/xdp.h:96:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:99:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:203:38: note: in definition of macro '__DECLARE_TRACE'
     register_trace_##name(void (*probe)(data_proto), void *data) \
                                         ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
   include/trace/events/xdp.h:95:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
    ^~~~~~~~~~~~
   include/trace/events/xdp.h:96:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:99:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:209:43: note: in definition of macro '__DECLARE_TRACE'
     register_trace_prio_##name(void (*probe)(data_proto), void *data,\
                                              ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
   include/trace/events/xdp.h:95:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
    ^~~~~~~~~~~~
   include/trace/events/xdp.h:96:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:99:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:216:40: note: in definition of macro '__DECLARE_TRACE'
     unregister_trace_##name(void (*probe)(data_proto), void *data) \
                                           ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
   include/trace/events/xdp.h:95:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
    ^~~~~~~~~~~~
   include/trace/events/xdp.h:96:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:99:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:222:46: note: in definition of macro '__DECLARE_TRACE'
     check_trace_callback_type_##name(void (*cb)(data_proto)) \
                                                 ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:477:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:477:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
   include/trace/events/xdp.h:95:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
    ^~~~~~~~~~~~
   include/trace/events/xdp.h:96:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:113:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:187:34: note: in definition of macro '__DECLARE_TRACE'
     static inline void trace_##name(proto)    \
                                     ^~~~~
>> include/linux/tracepoint.h:352:24: note: in expansion of macro 'PARAMS'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
                           ^~~~~~
   include/linux/tracepoint.h:481:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:481:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
>> include/trace/events/xdp.h:109:1: note: in expansion of macro 'DEFINE_EVENT_PRINT'
    DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map,
    ^~~~~~~~~~~~~~~~~~
   include/trace/events/xdp.h:110:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:113:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:203:38: note: in definition of macro '__DECLARE_TRACE'
     register_trace_##name(void (*probe)(data_proto), void *data) \
                                         ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:481:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:481:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~
>> include/trace/events/xdp.h:109:1: note: in expansion of macro 'DEFINE_EVENT_PRINT'
    DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map,
    ^~~~~~~~~~~~~~~~~~
   include/trace/events/xdp.h:110:2: note: in expansion of macro 'TP_PROTO'
     TP_PROTO(const struct net_device *dev,
     ^~~~~~~~
   include/trace/events/xdp.h:113:17: warning: 'struct bpf_map' declared inside parameter list will not be visible outside of this definition or declaration
       const struct bpf_map *map, u32 map_index),
                    ^
   include/linux/tracepoint.h:209:43: note: in definition of macro '__DECLARE_TRACE'
     register_trace_prio_##name(void (*probe)(data_proto), void *data,\
                                              ^~~~~~~~~~
   include/linux/tracepoint.h:354:4: note: in expansion of macro 'PARAMS'
       PARAMS(void *__data, proto),   \
       ^~~~~~
   include/linux/tracepoint.h:481:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:481:22: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                         ^~~~~~

vim +91 include/trace/events/xdp.h

a67edbf4f Daniel Borkmann        2017-01-25    6  
a67edbf4f Daniel Borkmann        2017-01-25    7  #include <linux/netdevice.h>
a67edbf4f Daniel Borkmann        2017-01-25    8  #include <linux/filter.h>
a67edbf4f Daniel Borkmann        2017-01-25   @9  #include <linux/tracepoint.h>
a67edbf4f Daniel Borkmann        2017-01-25   10  
a67edbf4f Daniel Borkmann        2017-01-25   11  #define __XDP_ACT_MAP(FN)	\
a67edbf4f Daniel Borkmann        2017-01-25   12  	FN(ABORTED)		\
a67edbf4f Daniel Borkmann        2017-01-25   13  	FN(DROP)		\
a67edbf4f Daniel Borkmann        2017-01-25   14  	FN(PASS)		\
5acaee0a8 John Fastabend         2017-07-17   15  	FN(TX)			\
5acaee0a8 John Fastabend         2017-07-17   16  	FN(REDIRECT)
a67edbf4f Daniel Borkmann        2017-01-25   17  
a67edbf4f Daniel Borkmann        2017-01-25   18  #define __XDP_ACT_TP_FN(x)	\
a67edbf4f Daniel Borkmann        2017-01-25   19  	TRACE_DEFINE_ENUM(XDP_##x);
a67edbf4f Daniel Borkmann        2017-01-25   20  #define __XDP_ACT_SYM_FN(x)	\
a67edbf4f Daniel Borkmann        2017-01-25   21  	{ XDP_##x, #x },
a67edbf4f Daniel Borkmann        2017-01-25   22  #define __XDP_ACT_SYM_TAB	\
a67edbf4f Daniel Borkmann        2017-01-25   23  	__XDP_ACT_MAP(__XDP_ACT_SYM_FN) { -1, 0 }
a67edbf4f Daniel Borkmann        2017-01-25   24  __XDP_ACT_MAP(__XDP_ACT_TP_FN)
a67edbf4f Daniel Borkmann        2017-01-25   25  
a67edbf4f Daniel Borkmann        2017-01-25   26  TRACE_EVENT(xdp_exception,
a67edbf4f Daniel Borkmann        2017-01-25   27  
a67edbf4f Daniel Borkmann        2017-01-25   28  	TP_PROTO(const struct net_device *dev,
a67edbf4f Daniel Borkmann        2017-01-25   29  		 const struct bpf_prog *xdp, u32 act),
a67edbf4f Daniel Borkmann        2017-01-25   30  
a67edbf4f Daniel Borkmann        2017-01-25   31  	TP_ARGS(dev, xdp, act),
a67edbf4f Daniel Borkmann        2017-01-25   32  
a67edbf4f Daniel Borkmann        2017-01-25   33  	TP_STRUCT__entry(
b06337dfd Jesper Dangaard Brouer 2017-08-29   34  		__field(int, prog_id)
a67edbf4f Daniel Borkmann        2017-01-25   35  		__field(u32, act)
315ec3990 Jesper Dangaard Brouer 2017-08-24   36  		__field(int, ifindex)
a67edbf4f Daniel Borkmann        2017-01-25   37  	),
a67edbf4f Daniel Borkmann        2017-01-25   38  
a67edbf4f Daniel Borkmann        2017-01-25   39  	TP_fast_assign(
b06337dfd Jesper Dangaard Brouer 2017-08-29   40  		__entry->prog_id	= xdp->aux->id;
a67edbf4f Daniel Borkmann        2017-01-25   41  		__entry->act		= act;
315ec3990 Jesper Dangaard Brouer 2017-08-24   42  		__entry->ifindex	= dev->ifindex;
a67edbf4f Daniel Borkmann        2017-01-25   43  	),
a67edbf4f Daniel Borkmann        2017-01-25   44  
b06337dfd Jesper Dangaard Brouer 2017-08-29   45  	TP_printk("prog_id=%d action=%s ifindex=%d",
b06337dfd Jesper Dangaard Brouer 2017-08-29   46  		  __entry->prog_id,
315ec3990 Jesper Dangaard Brouer 2017-08-24   47  		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
315ec3990 Jesper Dangaard Brouer 2017-08-24   48  		  __entry->ifindex)
a67edbf4f Daniel Borkmann        2017-01-25   49  );
a67edbf4f Daniel Borkmann        2017-01-25   50  
8d3b778ff Jesper Dangaard Brouer 2017-08-29   51  DECLARE_EVENT_CLASS(xdp_redirect_template,
5acaee0a8 John Fastabend         2017-07-17   52  
a87358558 Jesper Dangaard Brouer 2017-08-24   53  	TP_PROTO(const struct net_device *dev,
c31e5a487 Jesper Dangaard Brouer 2017-08-29   54  		 const struct bpf_prog *xdp,
8d3b778ff Jesper Dangaard Brouer 2017-08-29   55  		 int to_ifindex, int err,
8d3b778ff Jesper Dangaard Brouer 2017-08-29   56  		 const struct bpf_map *map, u32 map_index),
5acaee0a8 John Fastabend         2017-07-17   57  
8d3b778ff Jesper Dangaard Brouer 2017-08-29   58  	TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
5acaee0a8 John Fastabend         2017-07-17   59  
5acaee0a8 John Fastabend         2017-07-17   60  	TP_STRUCT__entry(
b06337dfd Jesper Dangaard Brouer 2017-08-29   61  		__field(int, prog_id)
5acaee0a8 John Fastabend         2017-07-17   62  		__field(u32, act)
a87358558 Jesper Dangaard Brouer 2017-08-24   63  		__field(int, ifindex)
4c03bdd7b Jesper Dangaard Brouer 2017-08-17   64  		__field(int, err)
8d3b778ff Jesper Dangaard Brouer 2017-08-29   65  		__field(int, to_ifindex)
8d3b778ff Jesper Dangaard Brouer 2017-08-29   66  		__field(u32, map_id)
8d3b778ff Jesper Dangaard Brouer 2017-08-29   67  		__field(int, map_index)
5acaee0a8 John Fastabend         2017-07-17   68  	),
5acaee0a8 John Fastabend         2017-07-17   69  
5acaee0a8 John Fastabend         2017-07-17   70  	TP_fast_assign(
b06337dfd Jesper Dangaard Brouer 2017-08-29   71  		__entry->prog_id	= xdp->aux->id;
c31e5a487 Jesper Dangaard Brouer 2017-08-29   72  		__entry->act		= XDP_REDIRECT;
a87358558 Jesper Dangaard Brouer 2017-08-24   73  		__entry->ifindex	= dev->ifindex;
4c03bdd7b Jesper Dangaard Brouer 2017-08-17   74  		__entry->err		= err;
8d3b778ff Jesper Dangaard Brouer 2017-08-29   75  		__entry->to_ifindex	= to_ifindex;
8d3b778ff Jesper Dangaard Brouer 2017-08-29   76  		__entry->map_id		= map ? map->id : 0;
8d3b778ff Jesper Dangaard Brouer 2017-08-29   77  		__entry->map_index	= map_index;
5acaee0a8 John Fastabend         2017-07-17   78  	),
5acaee0a8 John Fastabend         2017-07-17   79  
59a308967 Jesper Dangaard Brouer 2017-08-29   80  	TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d",
b06337dfd Jesper Dangaard Brouer 2017-08-29   81  		  __entry->prog_id,
4c03bdd7b Jesper Dangaard Brouer 2017-08-17   82  		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
8d3b778ff Jesper Dangaard Brouer 2017-08-29   83  		  __entry->ifindex, __entry->to_ifindex,
59a308967 Jesper Dangaard Brouer 2017-08-29   84  		  __entry->err)
5acaee0a8 John Fastabend         2017-07-17   85  );
8d3b778ff Jesper Dangaard Brouer 2017-08-29   86  
8d3b778ff Jesper Dangaard Brouer 2017-08-29  @87  DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
8d3b778ff Jesper Dangaard Brouer 2017-08-29  @88  	TP_PROTO(const struct net_device *dev,
8d3b778ff Jesper Dangaard Brouer 2017-08-29   89  		 const struct bpf_prog *xdp,
8d3b778ff Jesper Dangaard Brouer 2017-08-29   90  		 int to_ifindex, int err,
8d3b778ff Jesper Dangaard Brouer 2017-08-29  @91  		 const struct bpf_map *map, u32 map_index),
8d3b778ff Jesper Dangaard Brouer 2017-08-29   92  	TP_ARGS(dev, xdp, to_ifindex, err, map, map_index)
8d3b778ff Jesper Dangaard Brouer 2017-08-29   93  );
8d3b778ff Jesper Dangaard Brouer 2017-08-29   94  
f5836ca5e Jesper Dangaard Brouer 2017-08-29   95  DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
f5836ca5e Jesper Dangaard Brouer 2017-08-29   96  	TP_PROTO(const struct net_device *dev,
f5836ca5e Jesper Dangaard Brouer 2017-08-29   97  		 const struct bpf_prog *xdp,
f5836ca5e Jesper Dangaard Brouer 2017-08-29   98  		 int to_ifindex, int err,
f5836ca5e Jesper Dangaard Brouer 2017-08-29   99  		 const struct bpf_map *map, u32 map_index),
f5836ca5e Jesper Dangaard Brouer 2017-08-29  100  	TP_ARGS(dev, xdp, to_ifindex, err, map, map_index)
f5836ca5e Jesper Dangaard Brouer 2017-08-29  101  );
f5836ca5e Jesper Dangaard Brouer 2017-08-29  102  
f5836ca5e Jesper Dangaard Brouer 2017-08-29  103  #define _trace_xdp_redirect(dev, xdp, to)		\
f5836ca5e Jesper Dangaard Brouer 2017-08-29  104  	 trace_xdp_redirect(dev, xdp, to, 0, NULL, 0);
f5836ca5e Jesper Dangaard Brouer 2017-08-29  105  
f5836ca5e Jesper Dangaard Brouer 2017-08-29  106  #define _trace_xdp_redirect_err(dev, xdp, to, err)	\
f5836ca5e Jesper Dangaard Brouer 2017-08-29  107  	 trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0);
f5836ca5e Jesper Dangaard Brouer 2017-08-29  108  
59a308967 Jesper Dangaard Brouer 2017-08-29 @109  DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map,
59a308967 Jesper Dangaard Brouer 2017-08-29  110  	TP_PROTO(const struct net_device *dev,
59a308967 Jesper Dangaard Brouer 2017-08-29  111  		 const struct bpf_prog *xdp,
59a308967 Jesper Dangaard Brouer 2017-08-29  112  		 int to_ifindex, int err,
59a308967 Jesper Dangaard Brouer 2017-08-29  113  		 const struct bpf_map *map, u32 map_index),
59a308967 Jesper Dangaard Brouer 2017-08-29  114  	TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
59a308967 Jesper Dangaard Brouer 2017-08-29  115  	TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
59a308967 Jesper Dangaard Brouer 2017-08-29  116  		  " map_id=%d map_index=%d",
59a308967 Jesper Dangaard Brouer 2017-08-29  117  		  __entry->prog_id,
59a308967 Jesper Dangaard Brouer 2017-08-29  118  		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
59a308967 Jesper Dangaard Brouer 2017-08-29  119  		  __entry->ifindex, __entry->to_ifindex,
59a308967 Jesper Dangaard Brouer 2017-08-29  120  		  __entry->err,
59a308967 Jesper Dangaard Brouer 2017-08-29  121  		  __entry->map_id, __entry->map_index)
59a308967 Jesper Dangaard Brouer 2017-08-29  122  );
59a308967 Jesper Dangaard Brouer 2017-08-29  123  

:::::: The code at line 91 was first introduced by commit
:::::: 8d3b778ff544b369f0847e6c15f3e73057298aa4 xdp: tracepoint xdp_redirect also need a map argument

:::::: TO: Jesper Dangaard Brouer <brouer@redhat.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34237 bytes --]

^ permalink raw reply

* Re: pull-request: mac80211 2017-10-16
From: Jason A. Donenfeld @ 2017-10-16 23:30 UTC (permalink / raw)
  To: Johannes Berg; +Cc: David Miller, netdev, linux-wireless
In-Reply-To: <20171016134618.30810-1-johannes@sipsolutions.net>

Mobile phone right now, so not able to write patch, but you probably
should be using crypto_memneq for comparing those two keys, not
memcmp.

Jason

^ permalink raw reply

* [net-next:master 272/285] ERROR: "netdev_txq_to_tc" [net/sched/sch_mqprio.ko] undefined!
From: kbuild test robot @ 2017-10-16 23:32 UTC (permalink / raw)
  To: Alexander Duyck; +Cc: kbuild-all, netdev

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
head:   e4467f2e2442e15cf047c2e7b91cb44a643cb149
commit: 32302902ff093891d8e64439cbb8ceae83e21ef8 [272/285] mqprio: Reserve last 32 classid values for HW traffic classes and misc IDs
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        git checkout 32302902ff093891d8e64439cbb8ceae83e21ef8
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "netdev_txq_to_tc" [net/sched/sch_mqprio.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40205 bytes --]

^ permalink raw reply

* Re: Linux 4.12+ memory leak on router with i40e NICs
From: Paweł Staszewski @ 2017-10-16 23:34 UTC (permalink / raw)
  To: Pavlos Parissis, Alexander Duyck
  Cc: Anders K. Pedersen | Cohaesio, netdev@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org, alexander.h.duyck@intel.com
In-Reply-To: <3d783736-a474-d9e3-2de2-e35c765f8249@itcare.pl>



W dniu 2017-10-16 o 18:26, Paweł Staszewski pisze:
>
>
> W dniu 2017-10-16 o 13:20, Pavlos Parissis pisze:
>> On 15/10/2017 02:58 πμ, Alexander Duyck wrote:
>>> Hi Pawel,
>>>
>>> To clarify is that Dave Miller's tree or Linus's that you are talking
>>> about? If it is Dave's tree how long ago was it you pulled it since I
>>> think the fix was just pushed by Jeff Kirsher a few days ago.
>>>
>>> The issue should be fixed in the following commit:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/drivers/net/ethernet/intel/i40e/i40e_txrx.c?id=2b9478ffc550f17c6cd8c69057234e91150f5972 
>>>
>>>
>>
>> Do you know when it is going to be available on net-next and 
>> linux-stable repos?
>>
>> Cheers,
>> Pavlos
>>
>>
> I will make some tests today night with "net" git tree where this 
> patch is included.
> Starting from 0:00 CET
> :)
>
>
Upgraded and looks like problem is not solved with that patch
Currently running system with
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/
kernel

Still about 0.5GB of memory is leaking somewhere

Also can confirm that the latest kernel where memory is not leaking 
(with use i40e driver intel 710 cards) is 4.11.12
With kernel 4.11.12 - after hour no change in memory usage.

also checked that with ixgbe instead of i40e with same  net.git kernel 
there is no memleak - after hour same memory usage - so for 100% this is 
i40e driver problem.

^ permalink raw reply

* [PATCH] mac80211: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-16 23:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Johannes Berg, David S. Miller, linux-wireless, netdev,
	linux-kernel

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 net/mac80211/ibss.c         |  7 +++----
 net/mac80211/ieee80211_i.h  |  3 ++-
 net/mac80211/led.c          | 11 ++++++-----
 net/mac80211/main.c         |  3 +--
 net/mac80211/mesh.c         | 27 ++++++++++++---------------
 net/mac80211/mesh.h         |  2 +-
 net/mac80211/mesh_hwmp.c    |  4 ++--
 net/mac80211/mesh_pathtbl.c |  3 +--
 net/mac80211/mlme.c         | 32 ++++++++++++++------------------
 net/mac80211/ocb.c          | 10 +++++-----
 net/mac80211/sta_info.c     |  7 +++----
 11 files changed, 50 insertions(+), 59 deletions(-)

diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index e9c6aa3ed05b..db07e0de9a03 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1711,10 +1711,10 @@ void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata)
 	sdata_unlock(sdata);
 }
 
-static void ieee80211_ibss_timer(unsigned long data)
+static void ieee80211_ibss_timer(struct timer_list *t)
 {
 	struct ieee80211_sub_if_data *sdata =
-		(struct ieee80211_sub_if_data *) data;
+		from_timer(sdata, t, u.ibss.timer);
 
 	ieee80211_queue_work(&sdata->local->hw, &sdata->work);
 }
@@ -1723,8 +1723,7 @@ void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata)
 {
 	struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
 
-	setup_timer(&ifibss->timer, ieee80211_ibss_timer,
-		    (unsigned long) sdata);
+	timer_setup(&ifibss->timer, ieee80211_ibss_timer, 0);
 	INIT_LIST_HEAD(&ifibss->incomplete_stations);
 	spin_lock_init(&ifibss->incomplete_lock);
 	INIT_WORK(&ifibss->csa_connection_drop_work,
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 68f874e73561..885d00b41911 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1057,6 +1057,7 @@ struct tpt_led_trigger {
 	const struct ieee80211_tpt_blink *blink_table;
 	unsigned int blink_table_len;
 	struct timer_list timer;
+	struct ieee80211_local *local;
 	unsigned long prev_traffic;
 	unsigned long tx_bytes, rx_bytes;
 	unsigned int active, want;
@@ -1932,7 +1933,7 @@ static inline int ieee80211_ac_from_tid(int tid)
 
 void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
 void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
-void ieee80211_dynamic_ps_timer(unsigned long data);
+void ieee80211_dynamic_ps_timer(struct timer_list *t);
 void ieee80211_send_nullfunc(struct ieee80211_local *local,
 			     struct ieee80211_sub_if_data *sdata,
 			     bool powersave);
diff --git a/net/mac80211/led.c b/net/mac80211/led.c
index 0505845b7ab8..ba0b507ea691 100644
--- a/net/mac80211/led.c
+++ b/net/mac80211/led.c
@@ -248,10 +248,10 @@ static unsigned long tpt_trig_traffic(struct ieee80211_local *local,
 	return DIV_ROUND_UP(delta, 1024 / 8);
 }
 
-static void tpt_trig_timer(unsigned long data)
+static void tpt_trig_timer(struct timer_list *t)
 {
-	struct ieee80211_local *local = (void *)data;
-	struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
+	struct tpt_led_trigger *tpt_trig = from_timer(tpt_trig, t, timer);
+	struct ieee80211_local *local = tpt_trig->local;
 	struct led_classdev *led_cdev;
 	unsigned long on, off, tpt;
 	int i;
@@ -306,8 +306,9 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
 	tpt_trig->blink_table = blink_table;
 	tpt_trig->blink_table_len = blink_table_len;
 	tpt_trig->want = flags;
+	tpt_trig->local = local;
 
-	setup_timer(&tpt_trig->timer, tpt_trig_timer, (unsigned long)local);
+	timer_setup(&tpt_trig->timer, tpt_trig_timer, 0);
 
 	local->tpt_led_trigger = tpt_trig;
 
@@ -326,7 +327,7 @@ static void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
 	tpt_trig_traffic(local, tpt_trig);
 	tpt_trig->running = true;
 
-	tpt_trig_timer((unsigned long)local);
+	tpt_trig_timer(&tpt_trig->timer);
 	mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ));
 }
 
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 8aa1f5b6a051..e054a2fd8d38 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -633,8 +633,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
 		  ieee80211_dynamic_ps_enable_work);
 	INIT_WORK(&local->dynamic_ps_disable_work,
 		  ieee80211_dynamic_ps_disable_work);
-	setup_timer(&local->dynamic_ps_timer,
-		    ieee80211_dynamic_ps_timer, (unsigned long) local);
+	timer_setup(&local->dynamic_ps_timer, ieee80211_dynamic_ps_timer, 0);
 
 	INIT_WORK(&local->sched_scan_stopped_work,
 		  ieee80211_sched_scan_stopped_work);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 7a76c4a6df30..5e27364e10ac 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -37,9 +37,10 @@ void ieee80211s_stop(void)
 	kmem_cache_destroy(rm_cache);
 }
 
-static void ieee80211_mesh_housekeeping_timer(unsigned long data)
+static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
 {
-	struct ieee80211_sub_if_data *sdata = (void *) data;
+	struct ieee80211_sub_if_data *sdata =
+		from_timer(sdata, t, u.mesh.housekeeping_timer);
 	struct ieee80211_local *local = sdata->local;
 	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 
@@ -528,18 +529,18 @@ int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,
 	return 0;
 }
 
-static void ieee80211_mesh_path_timer(unsigned long data)
+static void ieee80211_mesh_path_timer(struct timer_list *t)
 {
 	struct ieee80211_sub_if_data *sdata =
-		(struct ieee80211_sub_if_data *) data;
+		from_timer(sdata, t, u.mesh.mesh_path_timer);
 
 	ieee80211_queue_work(&sdata->local->hw, &sdata->work);
 }
 
-static void ieee80211_mesh_path_root_timer(unsigned long data)
+static void ieee80211_mesh_path_root_timer(struct timer_list *t)
 {
 	struct ieee80211_sub_if_data *sdata =
-		(struct ieee80211_sub_if_data *) data;
+		from_timer(sdata, t, u.mesh.mesh_path_root_timer);
 	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 
 	set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
@@ -1442,9 +1443,8 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
 	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 	static u8 zero_addr[ETH_ALEN] = {};
 
-	setup_timer(&ifmsh->housekeeping_timer,
-		    ieee80211_mesh_housekeeping_timer,
-		    (unsigned long) sdata);
+	timer_setup(&ifmsh->housekeeping_timer,
+		    ieee80211_mesh_housekeeping_timer, 0);
 
 	ifmsh->accepting_plinks = true;
 	atomic_set(&ifmsh->mpaths, 0);
@@ -1458,12 +1458,9 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
 
 	mesh_pathtbl_init(sdata);
 
-	setup_timer(&ifmsh->mesh_path_timer,
-		    ieee80211_mesh_path_timer,
-		    (unsigned long) sdata);
-	setup_timer(&ifmsh->mesh_path_root_timer,
-		    ieee80211_mesh_path_root_timer,
-		    (unsigned long) sdata);
+	timer_setup(&ifmsh->mesh_path_timer, ieee80211_mesh_path_timer, 0);
+	timer_setup(&ifmsh->mesh_path_root_timer,
+		    ieee80211_mesh_path_root_timer, 0);
 	INIT_LIST_HEAD(&ifmsh->preq_queue.list);
 	skb_queue_head_init(&ifmsh->ps.bc_buf);
 	spin_lock_init(&ifmsh->mesh_preq_queue_lock);
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index 465b7853edc0..ee56f18cad3f 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -296,7 +296,7 @@ void mesh_path_tx_pending(struct mesh_path *mpath);
 int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);
 void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);
 int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
-void mesh_path_timer(unsigned long data);
+void mesh_path_timer(struct timer_list *t);
 void mesh_path_flush_by_nexthop(struct sta_info *sta);
 void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
 			     struct sk_buff *skb);
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 146ec6c0f12f..4f7826d7b47c 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -1194,9 +1194,9 @@ int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
 	return err;
 }
 
-void mesh_path_timer(unsigned long data)
+void mesh_path_timer(struct timer_list *t)
 {
-	struct mesh_path *mpath = (void *) data;
+	struct mesh_path *mpath = from_timer(mpath, t, timer);
 	struct ieee80211_sub_if_data *sdata = mpath->sdata;
 	int ret;
 
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 97269caafecd..86c8dfef56a4 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -399,8 +399,7 @@ struct mesh_path *mesh_path_new(struct ieee80211_sub_if_data *sdata,
 	skb_queue_head_init(&new_mpath->frame_queue);
 	new_mpath->exp_time = jiffies;
 	spin_lock_init(&new_mpath->state_lock);
-	setup_timer(&new_mpath->timer, mesh_path_timer,
-		    (unsigned long) new_mpath);
+	timer_setup(&new_mpath->timer, mesh_path_timer, 0);
 
 	return new_mpath;
 }
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index ee5ca1bc5a20..241b70c2fe0a 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1074,10 +1074,10 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
 }
 EXPORT_SYMBOL(ieee80211_chswitch_done);
 
-static void ieee80211_chswitch_timer(unsigned long data)
+static void ieee80211_chswitch_timer(struct timer_list *t)
 {
 	struct ieee80211_sub_if_data *sdata =
-		(struct ieee80211_sub_if_data *) data;
+		from_timer(sdata, t, u.mgd.chswitch_timer);
 
 	ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work);
 }
@@ -1585,9 +1585,9 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
 	}
 }
 
-void ieee80211_dynamic_ps_timer(unsigned long data)
+void ieee80211_dynamic_ps_timer(struct timer_list *t)
 {
-	struct ieee80211_local *local = (void *) data;
+	struct ieee80211_local *local = from_timer(local, t, dynamic_ps_timer);
 
 	ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work);
 }
@@ -3719,10 +3719,10 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
 	sdata_unlock(sdata);
 }
 
-static void ieee80211_sta_timer(unsigned long data)
+static void ieee80211_sta_timer(struct timer_list *t)
 {
 	struct ieee80211_sub_if_data *sdata =
-		(struct ieee80211_sub_if_data *) data;
+		from_timer(sdata, t, u.mgd.timer);
 
 	ieee80211_queue_work(&sdata->local->hw, &sdata->work);
 }
@@ -3999,10 +3999,10 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
 	sdata_unlock(sdata);
 }
 
-static void ieee80211_sta_bcn_mon_timer(unsigned long data)
+static void ieee80211_sta_bcn_mon_timer(struct timer_list *t)
 {
 	struct ieee80211_sub_if_data *sdata =
-		(struct ieee80211_sub_if_data *) data;
+		from_timer(sdata, t, u.mgd.bcn_mon_timer);
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 
 	if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn)
@@ -4013,10 +4013,10 @@ static void ieee80211_sta_bcn_mon_timer(unsigned long data)
 			     &sdata->u.mgd.beacon_connection_loss_work);
 }
 
-static void ieee80211_sta_conn_mon_timer(unsigned long data)
+static void ieee80211_sta_conn_mon_timer(struct timer_list *t)
 {
 	struct ieee80211_sub_if_data *sdata =
-		(struct ieee80211_sub_if_data *) data;
+		from_timer(sdata, t, u.mgd.conn_mon_timer);
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 	struct ieee80211_local *local = sdata->local;
 
@@ -4147,14 +4147,10 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
 	INIT_WORK(&ifmgd->request_smps_work, ieee80211_request_smps_mgd_work);
 	INIT_DELAYED_WORK(&ifmgd->tdls_peer_del_work,
 			  ieee80211_tdls_peer_del_work);
-	setup_timer(&ifmgd->timer, ieee80211_sta_timer,
-		    (unsigned long) sdata);
-	setup_timer(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer,
-		    (unsigned long) sdata);
-	setup_timer(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer,
-		    (unsigned long) sdata);
-	setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer,
-		    (unsigned long) sdata);
+	timer_setup(&ifmgd->timer, ieee80211_sta_timer, 0);
+	timer_setup(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 0);
+	timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0);
+	timer_setup(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 0);
 	INIT_DELAYED_WORK(&ifmgd->tx_tspec_wk,
 			  ieee80211_sta_handle_tspec_ac_params_wk);
 
diff --git a/net/mac80211/ocb.c b/net/mac80211/ocb.c
index 88e6ebbbe24f..d351dc1162be 100644
--- a/net/mac80211/ocb.c
+++ b/net/mac80211/ocb.c
@@ -150,9 +150,10 @@ void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata)
 	sdata_unlock(sdata);
 }
 
-static void ieee80211_ocb_housekeeping_timer(unsigned long data)
+static void ieee80211_ocb_housekeeping_timer(struct timer_list *t)
 {
-	struct ieee80211_sub_if_data *sdata = (void *)data;
+	struct ieee80211_sub_if_data *sdata =
+		from_timer(sdata, t, u.ocb.housekeeping_timer);
 	struct ieee80211_local *local = sdata->local;
 	struct ieee80211_if_ocb *ifocb = &sdata->u.ocb;
 
@@ -165,9 +166,8 @@ void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata)
 {
 	struct ieee80211_if_ocb *ifocb = &sdata->u.ocb;
 
-	setup_timer(&ifocb->housekeeping_timer,
-		    ieee80211_ocb_housekeeping_timer,
-		    (unsigned long)sdata);
+	timer_setup(&ifocb->housekeeping_timer,
+		    ieee80211_ocb_housekeeping_timer, 0);
 	INIT_LIST_HEAD(&ifocb->incomplete_stations);
 	spin_lock_init(&ifocb->incomplete_lock);
 }
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 9673e157bf8f..877d35796776 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1064,9 +1064,9 @@ int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata,
 	return ret;
 }
 
-static void sta_info_cleanup(unsigned long data)
+static void sta_info_cleanup(struct timer_list *t)
 {
-	struct ieee80211_local *local = (struct ieee80211_local *) data;
+	struct ieee80211_local *local = from_timer(local, t, sta_cleanup);
 	struct sta_info *sta;
 	bool timer_needed = false;
 
@@ -1098,8 +1098,7 @@ int sta_info_init(struct ieee80211_local *local)
 	mutex_init(&local->sta_mtx);
 	INIT_LIST_HEAD(&local->sta_list);
 
-	setup_timer(&local->sta_cleanup, sta_info_cleanup,
-		    (unsigned long)local);
+	timer_setup(&local->sta_cleanup, sta_info_cleanup, 0);
 	return 0;
 }
 
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* [PATCH] rtlwifi: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-16 23:36 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Larry Finger, Chaoming Li, Ping-Ke Shih, Arvind Yadav,
	Souptick Joarder, linux-wireless, netdev, linux-kernel

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Chaoming Li <chaoming_li@realsil.com.cn>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: Ping-Ke Shih <pkshih@realtek.com>
Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: Souptick Joarder <jrdr.linux@gmail.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/wireless/realtek/rtlwifi/base.c         | 21 +++++++++++----------
 drivers/net/wireless/realtek/rtlwifi/base.h         |  4 ++--
 drivers/net/wireless/realtek/rtlwifi/core.c         |  2 +-
 drivers/net/wireless/realtek/rtlwifi/ps.c           |  2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c |  6 ++++--
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.h |  2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c |  6 ++++--
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h |  2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c | 12 ++++--------
 9 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index ea18aa7afecb..ef97a3c36d51 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -461,10 +461,10 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
 	/* <1> timer */
-	setup_timer(&rtlpriv->works.watchdog_timer,
-		    rtl_watch_dog_timer_callback, (unsigned long)hw);
-	setup_timer(&rtlpriv->works.dualmac_easyconcurrent_retrytimer,
-		    rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw);
+	timer_setup(&rtlpriv->works.watchdog_timer,
+		    rtl_watch_dog_timer_callback, 0);
+	timer_setup(&rtlpriv->works.dualmac_easyconcurrent_retrytimer,
+		    rtl_easy_concurrent_retrytimer_callback, 0);
 	/* <2> work queue */
 	rtlpriv->works.hw = hw;
 	rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
@@ -1975,10 +1975,10 @@ void rtl_watchdog_wq_callback(void *data)
 	rtl_scan_list_expire(hw);
 }
 
-void rtl_watch_dog_timer_callback(unsigned long data)
+void rtl_watch_dog_timer_callback(struct timer_list *t)
 {
-	struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_priv *rtlpriv = from_timer(rtlpriv, t, works.watchdog_timer);
+	struct ieee80211_hw *hw = rtlpriv->hw;
 
 	queue_delayed_work(rtlpriv->works.rtl_wq,
 			   &rtlpriv->works.watchdog_wq, 0);
@@ -2084,10 +2084,11 @@ void rtl_c2hcmd_wq_callback(void *data)
 	rtl_c2hcmd_launcher(hw, 1);
 }
 
-void rtl_easy_concurrent_retrytimer_callback(unsigned long data)
+void rtl_easy_concurrent_retrytimer_callback(struct timer_list *t)
 {
-	struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_priv *rtlpriv =
+		from_timer(rtlpriv, t, works.dualmac_easyconcurrent_retrytimer);
+	struct ieee80211_hw *hw = rtlpriv->hw;
 	struct rtl_priv *buddy_priv = rtlpriv->buddy_priv;
 
 	if (buddy_priv == NULL)
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h b/drivers/net/wireless/realtek/rtlwifi/base.h
index b56d1b7f5567..23f1564811b8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -120,7 +120,7 @@ void rtl_init_rx_config(struct ieee80211_hw *hw);
 void rtl_init_rfkill(struct ieee80211_hw *hw);
 void rtl_deinit_rfkill(struct ieee80211_hw *hw);
 
-void rtl_watch_dog_timer_callback(unsigned long data);
+void rtl_watch_dog_timer_callback(struct timer_list *t);
 void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
 
 bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
@@ -169,7 +169,7 @@ int rtl_send_smps_action(struct ieee80211_hw *hw,
 u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie);
 void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len);
 u8 rtl_tid_to_ac(u8 tid);
-void rtl_easy_concurrent_retrytimer_callback(unsigned long data);
+void rtl_easy_concurrent_retrytimer_callback(struct timer_list *t);
 extern struct rtl_global_var rtl_global_var;
 void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation);
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index 294a6b43d1bc..e025cb06443d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -160,7 +160,7 @@ static int rtl_op_start(struct ieee80211_hw *hw)
 	mutex_lock(&rtlpriv->locks.conf_mutex);
 	err = rtlpriv->intf_ops->adapter_start(hw);
 	if (!err)
-		rtl_watch_dog_timer_callback((unsigned long)hw);
+		rtl_watch_dog_timer_callback(&rtlpriv->works.watchdog_timer);
 	mutex_unlock(&rtlpriv->locks.conf_mutex);
 	return err;
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c
index 07ee3096f50e..24c87fae5382 100644
--- a/drivers/net/wireless/realtek/rtlwifi/ps.c
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.c
@@ -55,7 +55,7 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw)
 	rtlpriv->cfg->ops->enable_interrupt(hw);
 
 	/*<enable timer> */
-	rtl_watch_dog_timer_callback((unsigned long)hw);
+	rtl_watch_dog_timer_callback(&rtlpriv->works.watchdog_timer);
 
 	return true;
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c
index f936a491371b..71695639888b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c
@@ -1707,9 +1707,11 @@ static void rtl88e_dm_fast_ant_training(struct ieee80211_hw *hw)
 	}
 }
 
-void rtl88e_dm_fast_antenna_training_callback(unsigned long data)
+void rtl88e_dm_fast_antenna_training_callback(struct timer_list *t)
 {
-	struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
+	struct rtl_priv *rtlpriv =
+		from_timer(rtlpriv, t, works.fast_antenna_training_timer);
+	struct ieee80211_hw *hw = rtlpriv->hw;
 
 	rtl88e_dm_fast_ant_training(hw);
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.h b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.h
index 0fd2bac14db6..50f26a9a97db 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.h
@@ -270,7 +270,7 @@ void rtl88e_dm_set_tx_ant_by_tx_info(struct ieee80211_hw *hw,
 void rtl88e_dm_ant_sel_statistics(struct ieee80211_hw *hw,
 				  u8 antsel_tr_mux, u32 mac_id,
 				  u32 rx_pwdb_all);
-void rtl88e_dm_fast_antenna_training_callback(unsigned long data);
+void rtl88e_dm_fast_antenna_training_callback(struct timer_list *t);
 void rtl88e_dm_init(struct ieee80211_hw *hw);
 void rtl88e_dm_watchdog(struct ieee80211_hw *hw);
 void rtl88e_dm_write_dig(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
index 0ba26d27d11c..49f0ac977dcc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
@@ -252,9 +252,11 @@ static void _rtl88ee_set_fw_ps_rf_off_low_power(struct ieee80211_hw *hw)
 	rpwm_val |= FW_PS_STATE_RF_OFF_LOW_PWR_88E;
 	_rtl88ee_set_fw_clock_off(hw, rpwm_val);
 }
-void rtl88ee_fw_clk_off_timer_callback(unsigned long data)
+void rtl88ee_fw_clk_off_timer_callback(struct timer_list *t)
 {
-	struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
+	struct rtl_priv *rtlpriv = from_timer(rtlpriv, t,
+					      works.fw_clockoff_timer);
+	struct ieee80211_hw *hw = rtlpriv->hw;
 
 	_rtl88ee_set_fw_ps_rf_off_low_power(hw);
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
index d38dbca3c19e..1c3d7aa64aa3 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
@@ -57,6 +57,6 @@ void rtl8188ee_bt_reg_init(struct ieee80211_hw *hw);
 void rtl8188ee_bt_hw_init(struct ieee80211_hw *hw);
 void rtl88ee_suspend(struct ieee80211_hw *hw);
 void rtl88ee_resume(struct ieee80211_hw *hw);
-void rtl88ee_fw_clk_off_timer_callback(unsigned long data);
+void rtl88ee_fw_clk_off_timer_callback(struct timer_list *t);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
index 57e5d5c1d24b..5aa6b5cdc077 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
@@ -189,16 +189,12 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)
 	/*low power */
 	rtlpriv->psc.low_power_enable = false;
 	if (rtlpriv->psc.low_power_enable) {
-		init_timer(&rtlpriv->works.fw_clockoff_timer);
-		setup_timer(&rtlpriv->works.fw_clockoff_timer,
-			    rtl88ee_fw_clk_off_timer_callback,
-			    (unsigned long)hw);
+		timer_setup(&rtlpriv->works.fw_clockoff_timer,
+			    rtl88ee_fw_clk_off_timer_callback, 0);
 	}
 
-	init_timer(&rtlpriv->works.fast_antenna_training_timer);
-	setup_timer(&rtlpriv->works.fast_antenna_training_timer,
-		    rtl88e_dm_fast_antenna_training_callback,
-			(unsigned long)hw);
+	timer_setup(&rtlpriv->works.fast_antenna_training_timer,
+		    rtl88e_dm_fast_antenna_training_callback, 0);
 	return err;
 }
 
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* [PATCH] wireless: qtnfmac: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-16 23:36 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Igor Mitsyanko, Avinash Patil, Sergey Matyukevich, Kamlesh Rath,
	linux-wireless, netdev, linux-kernel

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Igor Mitsyanko <imitsyanko@quantenna.com>
Cc: Avinash Patil <avinashp@quantenna.com>
Cc: Sergey Matyukevich <smatyukevich@quantenna.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: Kamlesh Rath <krath@quantenna.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 7 +++----
 drivers/net/wireless/quantenna/qtnfmac/core.c     | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 32bf72c0399f..ac1b9bd5ed90 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -581,9 +581,9 @@ qtnf_del_station(struct wiphy *wiphy, struct net_device *dev,
 	return ret;
 }
 
-static void qtnf_scan_timeout(unsigned long data)
+static void qtnf_scan_timeout(struct timer_list *t)
 {
-	struct qtnf_wmac *mac = (struct qtnf_wmac *)data;
+	struct qtnf_wmac *mac = from_timer(mac, t, scan_timeout);
 
 	pr_warn("mac%d scan timed out\n", mac->macid);
 	qtnf_scan_done(mac, true);
@@ -602,8 +602,7 @@ qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 		return -EFAULT;
 	}
 
-	mac->scan_timeout.data = (unsigned long)mac;
-	mac->scan_timeout.function = qtnf_scan_timeout;
+	mac->scan_timeout.function = (TIMER_FUNC_TYPE)qtnf_scan_timeout;
 	mod_timer(&mac->scan_timeout,
 		  jiffies + QTNF_SCAN_TIMEOUT_SEC * HZ);
 
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index 5e60180482d1..aa7f146278a7 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -289,7 +289,7 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus,
 		mac->iflist[i].vifid = i;
 		qtnf_sta_list_init(&mac->iflist[i].sta_list);
 		mutex_init(&mac->mac_lock);
-		init_timer(&mac->scan_timeout);
+		setup_timer(&mac->scan_timeout, NULL, 0);
 	}
 
 	qtnf_mac_init_primary_intf(mac);
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* [PATCH] wireless: iwlegacy: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-16 23:37 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Stanislaw Gruszka, linux-wireless, netdev, linux-kernel

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/wireless/intel/iwlegacy/3945-mac.c |  2 +-
 drivers/net/wireless/intel/iwlegacy/3945-rs.c  | 10 +++-------
 drivers/net/wireless/intel/iwlegacy/4965-mac.c |  9 ++++-----
 drivers/net/wireless/intel/iwlegacy/common.c   |  4 ++--
 drivers/net/wireless/intel/iwlegacy/common.h   |  2 +-
 5 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/3945-mac.c b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
index 329f3a63dadd..4b53ebf00c7f 100644
--- a/drivers/net/wireless/intel/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
@@ -3429,7 +3429,7 @@ il3945_setup_deferred_work(struct il_priv *il)
 
 	il3945_hw_setup_deferred_work(il);
 
-	setup_timer(&il->watchdog, il_bg_watchdog, (unsigned long)il);
+	timer_setup(&il->watchdog, il_bg_watchdog, 0);
 
 	tasklet_init(&il->irq_tasklet,
 		     (void (*)(unsigned long))il3945_irq_tasklet,
diff --git a/drivers/net/wireless/intel/iwlegacy/3945-rs.c b/drivers/net/wireless/intel/iwlegacy/3945-rs.c
index b2f35dfbc01b..e8983c6a2b7b 100644
--- a/drivers/net/wireless/intel/iwlegacy/3945-rs.c
+++ b/drivers/net/wireless/intel/iwlegacy/3945-rs.c
@@ -181,9 +181,9 @@ il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta)
 #define IL_AVERAGE_PACKETS             1500
 
 static void
-il3945_bg_rate_scale_flush(unsigned long data)
+il3945_bg_rate_scale_flush(struct timer_list *t)
 {
-	struct il3945_rs_sta *rs_sta = (void *)data;
+	struct il3945_rs_sta *rs_sta = from_timer(rs_sta, t, rate_scale_flush);
 	struct il_priv *il __maybe_unused = rs_sta->il;
 	int unflushed = 0;
 	unsigned long flags;
@@ -360,9 +360,6 @@ il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id)
 	rs_sta->flush_time = RATE_FLUSH;
 	rs_sta->last_tx_packets = 0;
 
-	rs_sta->rate_scale_flush.data = (unsigned long)rs_sta;
-	rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush;
-
 	for (i = 0; i < RATE_COUNT_3945; i++)
 		il3945_clear_win(&rs_sta->win[i]);
 
@@ -415,8 +412,7 @@ il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp)
 	rs_sta = &psta->rs_sta;
 
 	spin_lock_init(&rs_sta->lock);
-	init_timer(&rs_sta->rate_scale_flush);
-
+	timer_setup(&rs_sta->rate_scale_flush, il3945_bg_rate_scale_flush, 0);
 	D_RATE("leave\n");
 
 	return rs_sta;
diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
index 65eba2c24292..de63f2518f23 100644
--- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
@@ -4074,9 +4074,9 @@ il4965_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb)
  * used for calibrating the TXPOWER.
  */
 static void
-il4965_bg_stats_periodic(unsigned long data)
+il4965_bg_stats_periodic(struct timer_list *t)
 {
-	struct il_priv *il = (struct il_priv *)data;
+	struct il_priv *il = from_timer(il, t, stats_periodic);
 
 	if (test_bit(S_EXIT_PENDING, &il->status))
 		return;
@@ -6258,10 +6258,9 @@ il4965_setup_deferred_work(struct il_priv *il)
 
 	INIT_WORK(&il->txpower_work, il4965_bg_txpower_work);
 
-	setup_timer(&il->stats_periodic, il4965_bg_stats_periodic,
-		    (unsigned long)il);
+	timer_setup(&il->stats_periodic, il4965_bg_stats_periodic, 0);
 
-	setup_timer(&il->watchdog, il_bg_watchdog, (unsigned long)il);
+	timer_setup(&il->watchdog, il_bg_watchdog, 0);
 
 	tasklet_init(&il->irq_tasklet,
 		     (void (*)(unsigned long))il4965_irq_tasklet,
diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
index 8d5acda92a9b..558bb16bfd46 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.c
+++ b/drivers/net/wireless/intel/iwlegacy/common.c
@@ -4844,9 +4844,9 @@ il_check_stuck_queue(struct il_priv *il, int cnt)
  * we reset the firmware. If everything is fine just rearm the timer.
  */
 void
-il_bg_watchdog(unsigned long data)
+il_bg_watchdog(struct timer_list *t)
 {
-	struct il_priv *il = (struct il_priv *)data;
+	struct il_priv *il = from_timer(il, t, watchdog);
 	int cnt;
 	unsigned long timeout;
 
diff --git a/drivers/net/wireless/intel/iwlegacy/common.h b/drivers/net/wireless/intel/iwlegacy/common.h
index 18c60c92e3a3..dc6a74a05983 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.h
+++ b/drivers/net/wireless/intel/iwlegacy/common.h
@@ -1832,7 +1832,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd);
  * PCI						     *
  *****************************************************/
 
-void il_bg_watchdog(unsigned long data);
+void il_bg_watchdog(struct timer_list *t);
 u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval);
 __le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon,
 			  u32 beacon_interval);
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* [PATCH net-next 0/4] bpf: move context info out of the verifier
From: Jakub Kicinski @ 2017-10-16 23:40 UTC (permalink / raw)
  To: netdev; +Cc: oss-drivers, alexei.starovoitov, daniel, Jakub Kicinski

Hi!

Daniel pointed out during the review of my previous patchset that
the knowledge about context doesn't really belong directly in the
verifier.  This patch set takes a bit of a drastic approach to
move the info out of there.  I want to be able to use different
set of verifier_ops for program analysis.  To do that, I have
to first move the test_run callback to a separate structure.  Then
verifier ops can be declared in the verifier directly and
different sets can be picked for verification vs analysis.

Jakub Kicinski (4):
  bpf: split verifier and program ops
  bpf: remove the verifier ops from program structure
  bpf: move knowledge about post-translation offsets out of verifier
  bpf: allow access to skb->len from offloads

 include/linux/bpf.h          | 17 ++++++---
 include/linux/bpf_types.h    | 28 +++++++-------
 include/linux/bpf_verifier.h |  1 +
 kernel/bpf/syscall.c         |  6 +--
 kernel/bpf/verifier.c        | 70 +++++++++++++++--------------------
 kernel/trace/bpf_trace.c     | 15 ++++++--
 net/core/filter.c            | 87 +++++++++++++++++++++++++++++++++++++++-----
 7 files changed, 149 insertions(+), 75 deletions(-)

-- 
2.14.1

^ permalink raw reply

* [PATCH net-next 1/4] bpf: split verifier and program ops
From: Jakub Kicinski @ 2017-10-16 23:40 UTC (permalink / raw)
  To: netdev; +Cc: oss-drivers, alexei.starovoitov, daniel, Jakub Kicinski
In-Reply-To: <20171016234056.1964-1-jakub.kicinski@netronome.com>

struct bpf_verifier_ops contains both verifier ops and operations
used later during program's lifetime (test_run).  Split the runtime
ops into a different structure.

BPF_PROG_TYPE() will now append ## _prog_ops or ## _verifier_ops
to the names.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 include/linux/bpf.h       | 15 ++++++++++-----
 include/linux/bpf_types.h | 28 ++++++++++++++--------------
 kernel/bpf/syscall.c      | 16 +++++++++++++---
 kernel/bpf/verifier.c     | 12 ++++++------
 kernel/trace/bpf_trace.c  | 15 ++++++++++++---
 net/core/filter.c         | 45 ++++++++++++++++++++++++++++++++++++---------
 6 files changed, 91 insertions(+), 40 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 4373125de1f3..010bb48fb1d8 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -157,6 +157,11 @@ bpf_ctx_record_field_size(struct bpf_insn_access_aux *aux, u32 size)
 	aux->ctx_field_size = size;
 }
 
+struct bpf_prog_ops {
+	int (*test_run)(struct bpf_prog *prog, const union bpf_attr *kattr,
+			union bpf_attr __user *uattr);
+};
+
 struct bpf_verifier_ops {
 	/* return eBPF function prototype for verification */
 	const struct bpf_func_proto *(*get_func_proto)(enum bpf_func_id func_id);
@@ -172,8 +177,6 @@ struct bpf_verifier_ops {
 				  const struct bpf_insn *src,
 				  struct bpf_insn *dst,
 				  struct bpf_prog *prog, u32 *target_size);
-	int (*test_run)(struct bpf_prog *prog, const union bpf_attr *kattr,
-			union bpf_attr __user *uattr);
 };
 
 struct bpf_prog_aux {
@@ -184,7 +187,8 @@ struct bpf_prog_aux {
 	u32 id;
 	struct latch_tree_node ksym_tnode;
 	struct list_head ksym_lnode;
-	const struct bpf_verifier_ops *ops;
+	const struct bpf_prog_ops *ops;
+	const struct bpf_verifier_ops *vops;
 	struct bpf_map **used_maps;
 	struct bpf_prog *prog;
 	struct user_struct *user;
@@ -279,8 +283,9 @@ int bpf_prog_array_copy_to_user(struct bpf_prog_array __rcu *progs,
 #ifdef CONFIG_BPF_SYSCALL
 DECLARE_PER_CPU(int, bpf_prog_active);
 
-#define BPF_PROG_TYPE(_id, _ops) \
-	extern const struct bpf_verifier_ops _ops;
+#define BPF_PROG_TYPE(_id, _name) \
+	extern const struct bpf_prog_ops _name ## _prog_ops; \
+	extern const struct bpf_verifier_ops _name ## _verifier_ops;
 #define BPF_MAP_TYPE(_id, _ops) \
 	extern const struct bpf_map_ops _ops;
 #include <linux/bpf_types.h>
diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h
index 6f1a567667b8..eeed0e1c3ea4 100644
--- a/include/linux/bpf_types.h
+++ b/include/linux/bpf_types.h
@@ -1,22 +1,22 @@
 /* internal file - do not include directly */
 
 #ifdef CONFIG_NET
-BPF_PROG_TYPE(BPF_PROG_TYPE_SOCKET_FILTER, sk_filter_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_SCHED_CLS, tc_cls_act_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_SCHED_ACT, tc_cls_act_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_XDP, xdp_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_SKB, cg_skb_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_SOCK, cg_sock_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_IN, lwt_inout_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_OUT, lwt_inout_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_XMIT, lwt_xmit_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_SOCK_OPS, sock_ops_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_SK_SKB, sk_skb_prog_ops)
+BPF_PROG_TYPE(BPF_PROG_TYPE_SOCKET_FILTER, sk_filter)
+BPF_PROG_TYPE(BPF_PROG_TYPE_SCHED_CLS, tc_cls_act)
+BPF_PROG_TYPE(BPF_PROG_TYPE_SCHED_ACT, tc_cls_act)
+BPF_PROG_TYPE(BPF_PROG_TYPE_XDP, xdp)
+BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_SKB, cg_skb)
+BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_SOCK, cg_sock)
+BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_IN, lwt_inout)
+BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_OUT, lwt_inout)
+BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_XMIT, lwt_xmit)
+BPF_PROG_TYPE(BPF_PROG_TYPE_SOCK_OPS, sock_ops)
+BPF_PROG_TYPE(BPF_PROG_TYPE_SK_SKB, sk_skb)
 #endif
 #ifdef CONFIG_BPF_EVENTS
-BPF_PROG_TYPE(BPF_PROG_TYPE_KPROBE, kprobe_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_TRACEPOINT, tracepoint_prog_ops)
-BPF_PROG_TYPE(BPF_PROG_TYPE_PERF_EVENT, perf_event_prog_ops)
+BPF_PROG_TYPE(BPF_PROG_TYPE_KPROBE, kprobe)
+BPF_PROG_TYPE(BPF_PROG_TYPE_TRACEPOINT, tracepoint)
+BPF_PROG_TYPE(BPF_PROG_TYPE_PERF_EVENT, perf_event)
 #endif
 
 BPF_MAP_TYPE(BPF_MAP_TYPE_ARRAY, array_map_ops)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index d124e702e040..714c3b758aa7 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -733,9 +733,18 @@ static int map_get_next_key(union bpf_attr *attr)
 	return err;
 }
 
-static const struct bpf_verifier_ops * const bpf_prog_types[] = {
-#define BPF_PROG_TYPE(_id, _ops) \
-	[_id] = &_ops,
+static const struct bpf_prog_ops * const bpf_prog_types[] = {
+#define BPF_PROG_TYPE(_id, _name) \
+	[_id] = & _name ## _prog_ops,
+#define BPF_MAP_TYPE(_id, _ops)
+#include <linux/bpf_types.h>
+#undef BPF_PROG_TYPE
+#undef BPF_MAP_TYPE
+};
+
+static const struct bpf_verifier_ops * const bpf_verifier_ops[] = {
+#define BPF_PROG_TYPE(_id, _name) \
+	[_id] = & _name ## _verifier_ops,
 #define BPF_MAP_TYPE(_id, _ops)
 #include <linux/bpf_types.h>
 #undef BPF_PROG_TYPE
@@ -748,6 +757,7 @@ static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog)
 		return -EINVAL;
 
 	prog->aux->ops = bpf_prog_types[type];
+	prog->aux->vops = bpf_verifier_ops[type];
 	prog->type = type;
 	return 0;
 }
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 9755279d94cb..6fd5edce5fa8 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -856,8 +856,8 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off,
 			*reg_type = info.reg_type;
 			return 0;
 		}
-	} else if (env->prog->aux->ops->is_valid_access &&
-		   env->prog->aux->ops->is_valid_access(off, size, t, &info)) {
+	} else if (env->prog->aux->vops->is_valid_access &&
+		   env->prog->aux->vops->is_valid_access(off, size, t, &info)) {
 		/* A non zero info.ctx_field_size indicates that this field is a
 		 * candidate for later verifier transformation to load the whole
 		 * field and then apply a mask when accessed with a narrower
@@ -1559,8 +1559,8 @@ static int check_call(struct bpf_verifier_env *env, int func_id, int insn_idx)
 		return -EINVAL;
 	}
 
-	if (env->prog->aux->ops->get_func_proto)
-		fn = env->prog->aux->ops->get_func_proto(func_id);
+	if (env->prog->aux->vops->get_func_proto)
+		fn = env->prog->aux->vops->get_func_proto(func_id);
 
 	if (!fn) {
 		verbose(env, "unknown func %s#%d\n", func_id_name(func_id),
@@ -4029,7 +4029,7 @@ static struct bpf_prog *bpf_patch_insn_data(struct bpf_verifier_env *env, u32 of
  */
 static int convert_ctx_accesses(struct bpf_verifier_env *env)
 {
-	const struct bpf_verifier_ops *ops = env->prog->aux->ops;
+	const struct bpf_verifier_ops *ops = env->prog->aux->vops;
 	int i, cnt, size, ctx_field_size, delta = 0;
 	const int insn_cnt = env->prog->len;
 	struct bpf_insn insn_buf[16], *insn;
@@ -4230,7 +4230,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
 			insn      = new_prog->insnsi + i + delta;
 		}
 patch_call_imm:
-		fn = prog->aux->ops->get_func_proto(insn->imm);
+		fn = prog->aux->vops->get_func_proto(insn->imm);
 		/* all functions that have prototype and verifier allowed
 		 * programs to call them, must be real in-kernel functions
 		 */
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 04ea5314f2bc..3126da2f468a 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -561,11 +561,14 @@ static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type
 	return true;
 }
 
-const struct bpf_verifier_ops kprobe_prog_ops = {
+const struct bpf_verifier_ops kprobe_verifier_ops = {
 	.get_func_proto  = kprobe_prog_func_proto,
 	.is_valid_access = kprobe_prog_is_valid_access,
 };
 
+const struct bpf_prog_ops kprobe_prog_ops = {
+};
+
 BPF_CALL_5(bpf_perf_event_output_tp, void *, tp_buff, struct bpf_map *, map,
 	   u64, flags, void *, data, u64, size)
 {
@@ -667,11 +670,14 @@ static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type
 	return true;
 }
 
-const struct bpf_verifier_ops tracepoint_prog_ops = {
+const struct bpf_verifier_ops tracepoint_verifier_ops = {
 	.get_func_proto  = tp_prog_func_proto,
 	.is_valid_access = tp_prog_is_valid_access,
 };
 
+const struct bpf_prog_ops tracepoint_prog_ops = {
+};
+
 static bool pe_prog_is_valid_access(int off, int size, enum bpf_access_type type,
 				    struct bpf_insn_access_aux *info)
 {
@@ -727,8 +733,11 @@ static u32 pe_prog_convert_ctx_access(enum bpf_access_type type,
 	return insn - insn_buf;
 }
 
-const struct bpf_verifier_ops perf_event_prog_ops = {
+const struct bpf_verifier_ops perf_event_verifier_ops = {
 	.get_func_proto		= tp_prog_func_proto,
 	.is_valid_access	= pe_prog_is_valid_access,
 	.convert_ctx_access	= pe_prog_convert_ctx_access,
 };
+
+const struct bpf_prog_ops perf_event_prog_ops = {
+};
diff --git a/net/core/filter.c b/net/core/filter.c
index 140fa9f9c0f4..8cffd1585451 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4313,68 +4313,95 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
 	return insn - insn_buf;
 }
 
-const struct bpf_verifier_ops sk_filter_prog_ops = {
+const struct bpf_verifier_ops sk_filter_verifier_ops = {
 	.get_func_proto		= sk_filter_func_proto,
 	.is_valid_access	= sk_filter_is_valid_access,
 	.convert_ctx_access	= bpf_convert_ctx_access,
 };
 
-const struct bpf_verifier_ops tc_cls_act_prog_ops = {
+const struct bpf_prog_ops sk_filter_prog_ops = {
+};
+
+const struct bpf_verifier_ops tc_cls_act_verifier_ops = {
 	.get_func_proto		= tc_cls_act_func_proto,
 	.is_valid_access	= tc_cls_act_is_valid_access,
 	.convert_ctx_access	= tc_cls_act_convert_ctx_access,
 	.gen_prologue		= tc_cls_act_prologue,
+};
+
+const struct bpf_prog_ops tc_cls_act_prog_ops = {
 	.test_run		= bpf_prog_test_run_skb,
 };
 
-const struct bpf_verifier_ops xdp_prog_ops = {
+const struct bpf_verifier_ops xdp_verifier_ops = {
 	.get_func_proto		= xdp_func_proto,
 	.is_valid_access	= xdp_is_valid_access,
 	.convert_ctx_access	= xdp_convert_ctx_access,
+};
+
+const struct bpf_prog_ops xdp_prog_ops = {
 	.test_run		= bpf_prog_test_run_xdp,
 };
 
-const struct bpf_verifier_ops cg_skb_prog_ops = {
+const struct bpf_verifier_ops cg_skb_verifier_ops = {
 	.get_func_proto		= sk_filter_func_proto,
 	.is_valid_access	= sk_filter_is_valid_access,
 	.convert_ctx_access	= bpf_convert_ctx_access,
+};
+
+const struct bpf_prog_ops cg_skb_prog_ops = {
 	.test_run		= bpf_prog_test_run_skb,
 };
 
-const struct bpf_verifier_ops lwt_inout_prog_ops = {
+const struct bpf_verifier_ops lwt_inout_verifier_ops = {
 	.get_func_proto		= lwt_inout_func_proto,
 	.is_valid_access	= lwt_is_valid_access,
 	.convert_ctx_access	= bpf_convert_ctx_access,
+};
+
+const struct bpf_prog_ops lwt_inout_prog_ops = {
 	.test_run		= bpf_prog_test_run_skb,
 };
 
-const struct bpf_verifier_ops lwt_xmit_prog_ops = {
+const struct bpf_verifier_ops lwt_xmit_verifier_ops = {
 	.get_func_proto		= lwt_xmit_func_proto,
 	.is_valid_access	= lwt_is_valid_access,
 	.convert_ctx_access	= bpf_convert_ctx_access,
 	.gen_prologue		= tc_cls_act_prologue,
+};
+
+const struct bpf_prog_ops lwt_xmit_prog_ops = {
 	.test_run		= bpf_prog_test_run_skb,
 };
 
-const struct bpf_verifier_ops cg_sock_prog_ops = {
+const struct bpf_verifier_ops cg_sock_verifier_ops = {
 	.get_func_proto		= sock_filter_func_proto,
 	.is_valid_access	= sock_filter_is_valid_access,
 	.convert_ctx_access	= sock_filter_convert_ctx_access,
 };
 
-const struct bpf_verifier_ops sock_ops_prog_ops = {
+const struct bpf_prog_ops cg_sock_prog_ops = {
+};
+
+const struct bpf_verifier_ops sock_ops_verifier_ops = {
 	.get_func_proto		= sock_ops_func_proto,
 	.is_valid_access	= sock_ops_is_valid_access,
 	.convert_ctx_access	= sock_ops_convert_ctx_access,
 };
 
-const struct bpf_verifier_ops sk_skb_prog_ops = {
+const struct bpf_prog_ops sock_ops_prog_ops = {
+};
+
+const struct bpf_verifier_ops sk_skb_verifier_ops = {
 	.get_func_proto		= sk_skb_func_proto,
 	.is_valid_access	= sk_skb_is_valid_access,
 	.convert_ctx_access	= bpf_convert_ctx_access,
 	.gen_prologue		= sk_skb_prologue,
 };
 
+const struct bpf_prog_ops sk_skb_prog_ops = {
+};
+
 int sk_detach_filter(struct sock *sk)
 {
 	int ret = -ENOENT;
-- 
2.14.1

^ permalink raw reply related

* [PATCH net-next 2/4] bpf: remove the verifier ops from program structure
From: Jakub Kicinski @ 2017-10-16 23:40 UTC (permalink / raw)
  To: netdev; +Cc: oss-drivers, alexei.starovoitov, daniel, Jakub Kicinski
In-Reply-To: <20171016234056.1964-1-jakub.kicinski@netronome.com>

Since the verifier ops don't have to be associated with
the program for its entire lifetime we can move it to
verifier's struct bpf_verifier_env.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 include/linux/bpf.h          |  1 -
 include/linux/bpf_verifier.h |  1 +
 kernel/bpf/syscall.c         | 10 ----------
 kernel/bpf/verifier.c        | 23 +++++++++++++++++------
 4 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 010bb48fb1d8..1d704dd5765f 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -188,7 +188,6 @@ struct bpf_prog_aux {
 	struct latch_tree_node ksym_tnode;
 	struct list_head ksym_lnode;
 	const struct bpf_prog_ops *ops;
-	const struct bpf_verifier_ops *vops;
 	struct bpf_map **used_maps;
 	struct bpf_prog *prog;
 	struct user_struct *user;
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index f00ef751c1c5..feeaea93d959 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -141,6 +141,7 @@ struct bpf_ext_analyzer_ops {
  */
 struct bpf_verifier_env {
 	struct bpf_prog *prog;		/* eBPF program being verified */
+	const struct bpf_verifier_ops *ops;
 	struct bpf_verifier_stack_elem *head; /* stack of verifier states to be processed */
 	int stack_size;			/* number of states to be processed */
 	bool strict_alignment;		/* perform strict pointer alignment checks */
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 714c3b758aa7..5b2ee50ff2c1 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -742,22 +742,12 @@ static const struct bpf_prog_ops * const bpf_prog_types[] = {
 #undef BPF_MAP_TYPE
 };
 
-static const struct bpf_verifier_ops * const bpf_verifier_ops[] = {
-#define BPF_PROG_TYPE(_id, _name) \
-	[_id] = & _name ## _verifier_ops,
-#define BPF_MAP_TYPE(_id, _ops)
-#include <linux/bpf_types.h>
-#undef BPF_PROG_TYPE
-#undef BPF_MAP_TYPE
-};
-
 static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog)
 {
 	if (type >= ARRAY_SIZE(bpf_prog_types) || !bpf_prog_types[type])
 		return -EINVAL;
 
 	prog->aux->ops = bpf_prog_types[type];
-	prog->aux->vops = bpf_verifier_ops[type];
 	prog->type = type;
 	return 0;
 }
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 6fd5edce5fa8..84b5a00975e4 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -23,6 +23,15 @@
 
 #include "disasm.h"
 
+static const struct bpf_verifier_ops * const bpf_verifier_ops[] = {
+#define BPF_PROG_TYPE(_id, _name) \
+	[_id] = & _name ## _verifier_ops,
+#define BPF_MAP_TYPE(_id, _ops)
+#include <linux/bpf_types.h>
+#undef BPF_PROG_TYPE
+#undef BPF_MAP_TYPE
+};
+
 /* bpf_check() is a static code analyzer that walks eBPF program
  * instruction by instruction and updates register/stack state.
  * All paths of conditional branches are analyzed until 'bpf_exit' insn.
@@ -856,8 +865,8 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off,
 			*reg_type = info.reg_type;
 			return 0;
 		}
-	} else if (env->prog->aux->vops->is_valid_access &&
-		   env->prog->aux->vops->is_valid_access(off, size, t, &info)) {
+	} else if (env->ops->is_valid_access &&
+		   env->ops->is_valid_access(off, size, t, &info)) {
 		/* A non zero info.ctx_field_size indicates that this field is a
 		 * candidate for later verifier transformation to load the whole
 		 * field and then apply a mask when accessed with a narrower
@@ -1559,8 +1568,8 @@ static int check_call(struct bpf_verifier_env *env, int func_id, int insn_idx)
 		return -EINVAL;
 	}
 
-	if (env->prog->aux->vops->get_func_proto)
-		fn = env->prog->aux->vops->get_func_proto(func_id);
+	if (env->ops->get_func_proto)
+		fn = env->ops->get_func_proto(func_id);
 
 	if (!fn) {
 		verbose(env, "unknown func %s#%d\n", func_id_name(func_id),
@@ -4029,7 +4038,7 @@ static struct bpf_prog *bpf_patch_insn_data(struct bpf_verifier_env *env, u32 of
  */
 static int convert_ctx_accesses(struct bpf_verifier_env *env)
 {
-	const struct bpf_verifier_ops *ops = env->prog->aux->vops;
+	const struct bpf_verifier_ops *ops = env->ops;
 	int i, cnt, size, ctx_field_size, delta = 0;
 	const int insn_cnt = env->prog->len;
 	struct bpf_insn insn_buf[16], *insn;
@@ -4230,7 +4239,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
 			insn      = new_prog->insnsi + i + delta;
 		}
 patch_call_imm:
-		fn = prog->aux->vops->get_func_proto(insn->imm);
+		fn = env->ops->get_func_proto(insn->imm);
 		/* all functions that have prototype and verifier allowed
 		 * programs to call them, must be real in-kernel functions
 		 */
@@ -4288,6 +4297,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
 	if (!env->insn_aux_data)
 		goto err_free_env;
 	env->prog = *prog;
+	env->ops = bpf_verifier_ops[env->prog->type];
 
 	/* grab the mutex to protect few globals used by verifier */
 	mutex_lock(&bpf_verifier_lock);
@@ -4400,6 +4410,7 @@ int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops,
 	if (!env->insn_aux_data)
 		goto err_free_env;
 	env->prog = prog;
+	env->ops = bpf_verifier_ops[env->prog->type];
 	env->analyzer_ops = ops;
 	env->analyzer_priv = priv;
 
-- 
2.14.1

^ 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