* Re: [PATCH net] bpf: fix bpf_setsockopts return value
From: Lawrence Brakmo @ 2017-08-24 23:45 UTC (permalink / raw)
To: Daniel Borkmann, Yuchung Cheng, davem@davemloft.net
Cc: ncardwell@google.com, cgallek@google.com, netdev@vger.kernel.org
In-Reply-To: <599F6323.2000107@iogearbox.net>
On 8/24/17, 4:37 PM, "Daniel Borkmann" <daniel@iogearbox.net> wrote:
On 08/25/2017 12:48 AM, Yuchung Cheng wrote:
> This patch fixes a bug causing any sock operations to always return EINVAL.
>
> Fixes: a5192c52377e ("bpf: fix to bpf_setsockops").
> Reported-by: Neal Cardwell <ncardwell@google.com>
> Signed-off-by: Yuchung Cheng <ycheng@google.com>
> Acked-by: Neal Cardwell <ncardwell@google.com>
> Acked-by: Craig Gallek <kraig@google.com>
Ohh well, thanks for the fix!
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Thanks! I never checked return values in by bpf test programs
Acked-by: Lawrence Brakmo <brakmo@fb.com>
^ permalink raw reply
* Re: [PATCH net] bpf: fix bpf_setsockopts return value
From: Daniel Borkmann @ 2017-08-24 23:37 UTC (permalink / raw)
To: Yuchung Cheng, davem, brakmo; +Cc: ncardwell, cgallek, netdev
In-Reply-To: <20170824224821.31672-1-ycheng@google.com>
On 08/25/2017 12:48 AM, Yuchung Cheng wrote:
> This patch fixes a bug causing any sock operations to always return EINVAL.
>
> Fixes: a5192c52377e ("bpf: fix to bpf_setsockops").
> Reported-by: Neal Cardwell <ncardwell@google.com>
> Signed-off-by: Yuchung Cheng <ycheng@google.com>
> Acked-by: Neal Cardwell <ncardwell@google.com>
> Acked-by: Craig Gallek <kraig@google.com>
Ohh well, thanks for the fix!
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply
* [PATCH net-next] tg3: Be drop monitor friendly
From: Florian Fainelli @ 2017-08-24 23:25 UTC (permalink / raw)
To: netdev
Cc: edumazet, davem, Florian Fainelli, Siva Reddy Kallam,
Prashant Sreedharan, Michael Chan, open list
tg3_tx() does the normal packet TX completion,
tigon3_dma_hwbug_workaround() needs to allocate a new SKB that is
suitable for the DMA hardware bug, and finally tg3_free_rings() is doing
ring cleanup. Use dev_consume_skb_any() for these 3 locations to be SKB
drop monitor friendly.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index d600c41fb1dc..8b8da7e32e24 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -6587,7 +6587,7 @@ static void tg3_tx(struct tg3_napi *tnapi)
pkts_compl++;
bytes_compl += skb->len;
- dev_kfree_skb_any(skb);
+ dev_consume_skb_any(skb);
if (unlikely(tx_bug)) {
tg3_tx_recover(tp);
@@ -7829,7 +7829,7 @@ static int tigon3_dma_hwbug_workaround(struct tg3_napi *tnapi,
}
}
- dev_kfree_skb_any(skb);
+ dev_consume_skb_any(skb);
*pskb = new_skb;
return ret;
}
@@ -8543,7 +8543,7 @@ static void tg3_free_rings(struct tg3 *tp)
tg3_tx_skb_unmap(tnapi, i,
skb_shinfo(skb)->nr_frags - 1);
- dev_kfree_skb_any(skb);
+ dev_consume_skb_any(skb);
}
netdev_tx_reset_queue(netdev_get_tx_queue(tp->dev, j));
}
--
2.9.3
^ permalink raw reply related
* Re: [PATCH] isdn: hisax: fix buffer overflow check
From: Arnd Bergmann @ 2017-08-24 23:15 UTC (permalink / raw)
To: Karsten Keil, David S. Miller
Cc: Arnd Bergmann, Networking, Linux Kernel Mailing List
In-Reply-To: <20170824225931.1602326-1-arnd@arndb.de>
On Fri, Aug 25, 2017 at 12:58 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> gcc-8 warns about a corner case that can overflow a memcpy buffer when a
> length variable is negative. While the code checks for an overly large
> value, it does not check for a negative length that would get turned
> into a large positive number:
>
> In function 'memcpy',
> inlined from 'skb_put_data' at include/linux/skbuff.h:2042:2,
> inlined from 'l3dss1_cmd_global' at drivers/isdn/hisax/l3dss1.c:2219:4:
> include/linux/string.h:348:9: error: '__builtin_memcpy' reading 266 or more bytes from a region of size 265 [-Werror=stringop-overflow=]
>
> In function 'memcpy',
> inlined from 'skb_put_data' at include/linux/skbuff.h:2042:2,
> inlined from 'l3ni1_cmd_global' at drivers/isdn/hisax/l3ni1.c:2079:4:
> include/linux/string.h:348:9: error: '__builtin_memcpy' reading between 266 and 4294967295 bytes from a region of size 265 [-Werror=stringop-overflow=]
>
> It's not clear to me whether the warning should be here, or if this
> is another case of an optimization step in gcc causing a warning about
> something that would otherwise be silently ignored. Either way, making
> the length 'unsigned int' instead ensures that no overflow can happen
> here, and avoids the warning. The same code exists in two files, so I'm
> patching both the same way.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Sorry, I sent this out too early (trying to get fixes posted before my
vacation), please ignore this patch, it doesn't fix all the warnings I get
for this overflow problem.
Arnd
^ permalink raw reply
* [PATCH net-next] net: mv643xx_eth: Be drop monitor friendly
From: Florian Fainelli @ 2017-08-24 23:04 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, andrew, Florian Fainelli, Sebastian Hesselbarth,
open list
txq_reclaim() does the normal transmit queue reclamation and
rxq_deinit() does the RX ring cleanup, none of these are packet drops,
so use dev_consume_skb() for both locations.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 9c94ea9b2b80..7655616bffef 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1123,7 +1123,7 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
struct sk_buff *skb = __skb_dequeue(&txq->tx_skb);
if (!WARN_ON(!skb))
- dev_kfree_skb(skb);
+ dev_consume_skb(skb);
}
if (cmd_sts & ERROR_SUMMARY) {
@@ -2026,7 +2026,7 @@ static void rxq_deinit(struct rx_queue *rxq)
for (i = 0; i < rxq->rx_ring_size; i++) {
if (rxq->rx_skb[i]) {
- dev_kfree_skb(rxq->rx_skb[i]);
+ dev_consume_skb(rxq->rx_skb[i]);
rxq->rx_desc_count--;
}
}
--
2.9.3
^ permalink raw reply related
* [PATCH net] net: systemport: Free DMA coherent descriptors on errors
From: Florian Fainelli @ 2017-08-24 23:01 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, Florian Fainelli
In case bcm_sysport_init_tx_ring() is not able to allocate ring->cbs, we
would return with an error, and call bcm_sysport_fini_tx_ring() and it
would see that ring->cbs is NULL and do nothing. This would leak the
coherent DMA descriptor area, so we need to free it on error before
returning.
Reported-by: Eric Dumazet <edumazet@gmail.com>
Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index e6add99cc31c..c28fa5a8734c 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1346,6 +1346,8 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,
ring->cbs = kcalloc(size, sizeof(struct bcm_sysport_cb), GFP_KERNEL);
if (!ring->cbs) {
+ dma_free_coherent(kdev, sizeof(struct dma_desc),
+ ring->desc_cpu, ring->desc_dma);
netif_err(priv, hw, priv->netdev, "CB allocation failed\n");
return -ENOMEM;
}
--
2.9.3
^ permalink raw reply related
* [PATCH] isdn: hisax: fix buffer overflow check
From: Arnd Bergmann @ 2017-08-24 22:58 UTC (permalink / raw)
To: Karsten Keil, David S. Miller; +Cc: Arnd Bergmann, netdev, linux-kernel
gcc-8 warns about a corner case that can overflow a memcpy buffer when a
length variable is negative. While the code checks for an overly large
value, it does not check for a negative length that would get turned
into a large positive number:
In function 'memcpy',
inlined from 'skb_put_data' at include/linux/skbuff.h:2042:2,
inlined from 'l3dss1_cmd_global' at drivers/isdn/hisax/l3dss1.c:2219:4:
include/linux/string.h:348:9: error: '__builtin_memcpy' reading 266 or more bytes from a region of size 265 [-Werror=stringop-overflow=]
In function 'memcpy',
inlined from 'skb_put_data' at include/linux/skbuff.h:2042:2,
inlined from 'l3ni1_cmd_global' at drivers/isdn/hisax/l3ni1.c:2079:4:
include/linux/string.h:348:9: error: '__builtin_memcpy' reading between 266 and 4294967295 bytes from a region of size 265 [-Werror=stringop-overflow=]
It's not clear to me whether the warning should be here, or if this
is another case of an optimization step in gcc causing a warning about
something that would otherwise be silently ignored. Either way, making
the length 'unsigned int' instead ensures that no overflow can happen
here, and avoids the warning. The same code exists in two files, so I'm
patching both the same way.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/isdn/hisax/l3dss1.c | 3 ++-
drivers/isdn/hisax/l3ni1.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c
index 18a3484b1f7e..85cef7a2e709 100644
--- a/drivers/isdn/hisax/l3dss1.c
+++ b/drivers/isdn/hisax/l3dss1.c
@@ -2168,7 +2168,8 @@ static int l3dss1_cmd_global(struct PStack *st, isdn_ctrl *ic)
{ u_char id;
u_char temp[265];
u_char *p = temp;
- int i, l, proc_len;
+ int i;
+ unsigned int l, proc_len;
struct sk_buff *skb;
struct l3_process *pc = NULL;
diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c
index ea311e7df48e..99e0ba5d49a1 100644
--- a/drivers/isdn/hisax/l3ni1.c
+++ b/drivers/isdn/hisax/l3ni1.c
@@ -2024,7 +2024,8 @@ static int l3ni1_cmd_global(struct PStack *st, isdn_ctrl *ic)
{ u_char id;
u_char temp[265];
u_char *p = temp;
- int i, l, proc_len;
+ int i;
+ unsigned int l, proc_len;
struct sk_buff *skb;
struct l3_process *pc = NULL;
--
2.9.0
^ permalink raw reply related
* [PATCH net] net: bcmgenet: Be drop monitor friendly
From: Florian Fainelli @ 2017-08-24 22:56 UTC (permalink / raw)
To: netdev; +Cc: davem, opendmb, edumazet, pgynther, jaedon.shin, Florian Fainelli
There are 3 spots where we call dev_kfree_skb() but we are actually
just doing a normal SKB consumption: __bcmgenet_tx_reclaim() for normal
TX reclamation, bcmgenet_alloc_rx_buffers() during the initial RX ring
setup and bcmgenet_free_rx_buffers() during RX ring cleanup.
Fixes: d6707bec5986 ("net: bcmgenet: rewrite bcmgenet_rx_refill()")
Fixes: f48bed16a756 ("net: bcmgenet: Free skb after last Tx frag")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
David, I tagged these two commits, but this can actually go back
to when the driver was first merged. Let me know if you would want
me to provide -stable backports against other trees.
Thanks!
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index a981c4ee9d72..fea3f9a5fb2d 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1360,7 +1360,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
if (skb) {
pkts_compl++;
bytes_compl += GENET_CB(skb)->bytes_sent;
- dev_kfree_skb_any(skb);
+ dev_consume_skb_any(skb);
}
txbds_processed++;
@@ -1875,7 +1875,7 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv,
cb = ring->cbs + i;
skb = bcmgenet_rx_refill(priv, cb);
if (skb)
- dev_kfree_skb_any(skb);
+ dev_consume_skb_any(skb);
if (!cb->skb)
return -ENOMEM;
}
@@ -1894,7 +1894,7 @@ static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
skb = bcmgenet_free_rx_cb(&priv->pdev->dev, cb);
if (skb)
- dev_kfree_skb_any(skb);
+ dev_consume_skb_any(skb);
}
}
--
2.9.3
^ permalink raw reply related
* RE: [PATCH net-next v3 2/7] netvsc: fix warnings reported by lockdep
From: Stephen Hemminger @ 2017-08-24 22:50 UTC (permalink / raw)
To: David Woodhouse, Stephen Hemminger, KY Srinivasan, Haiyang Zhang
Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org
In-Reply-To: <1503563809.7572.90.camel@infradead.org>
These are false positives; lockdep is complaining about things that are safe
It is just that annotations were missing or incorrect.
-----Original Message-----
From: David Woodhouse [mailto:dwmw2@infradead.org]
Sent: Thursday, August 24, 2017 1:37 AM
To: Stephen Hemminger <stephen@networkplumber.org>; KY Srinivasan <kys@microsoft.com>; Haiyang Zhang <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>
Cc: devel@linuxdriverproject.org; netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/7] netvsc: fix warnings reported by lockdep
On Fri, 2017-07-28 at 08:59 -0700, Stephen Hemminger wrote:
> This includes a bunch of fixups for issues reported by
> lockdep.
> * ethtool routines can assume RTNL
> * send is done with RCU lock (and BH disable)
> * avoid refetching internal device struct (netvsc)
> instead pass it as a parameter.
>
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
The subject and the commit message are inconsistent — is this fixing
*warnings* (i.e. shut up a false positive), or is it fixing *issues*?
It looks like it's actually fixing issues, not just warnings?
It's really useful to get that right.
FWIW the reason I'm looking in my netdev@ folder for lockdep warning
fixes is because I was trying to confirm whether the commit message in
https://patchwork.kernel.org/patch/4372391/ is actually telling the
truth or not — in that case I think it *is* just a false positive being
shut up (and thus it's OK to say "fix warning"), not really fixing a
true issue.
^ permalink raw reply
* [PATCH net] bpf: fix bpf_setsockopts return value
From: Yuchung Cheng @ 2017-08-24 22:48 UTC (permalink / raw)
To: davem, brakmo; +Cc: ncardwell, cgallek, netdev, Yuchung Cheng
This patch fixes a bug causing any sock operations to always return EINVAL.
Fixes: a5192c52377e ("bpf: fix to bpf_setsockops").
Reported-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Craig Gallek <kraig@google.com>
---
net/core/filter.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 6280a602604c..8eb81e5fae08 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2872,7 +2872,6 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
ret = -EINVAL;
}
}
- ret = -EINVAL;
#endif
} else {
ret = -EINVAL;
--
2.14.1.342.g6490525c54-goog
^ permalink raw reply related
* Re: [PATCH net-next 3/3 v7] drivers: net: ethernet: qualcomm: rmnet: Initial implementation
From: Subash Abhinov Kasiviswanathan @ 2017-08-24 22:45 UTC (permalink / raw)
To: David Miller
Cc: netdev, fengguang.wu, dcbw, jiri, stephen, David.Laight, marcel
In-Reply-To: <20170824.121559.882635807428126397.davem@davemloft.net>
>> +
>> +CFLAGS_rmnet.o := -I$(src)
>
> You do not need this CFLAGS rule, the local include files are included
> using "" double quotes so it uses the local directory always.
Hi David
I'll remove this.
>> +static void rmnet_free_later(struct work_struct *work)
>> +{
>> + struct rmnet_free_work *fwork;
>> +
>> + fwork = container_of(work, struct rmnet_free_work, work);
>> +
>> + rtnl_lock();
>> + rmnet_delink(fwork->rmnet_dev, NULL);
>> + rtnl_unlock();
>> +
>> + kfree(fwork);
>> +}
>
> This is racy and doesn't work properly.
>
> When you schedule this work, the RTNL mutex is dropped. Meanwhile
> another request can come in the associate this device.
>
> Your work function will still run and erroneously unlink the object.
>
> Furthermore, during this time that the RTNL mutex is dropped, people
> will see the unassociated device in the lists.
>
> You have to atomically remove the object from all possible locations
> which provide external visibility of that object, before the RTNL
> mutex is dropped.
>
> So you can defer the freeing, but you cannot defer the unlink
> operation.
I had incorrectly assumed earlier that the check in rtnl_newlink for
NLM_F_EXCL would guard against the scenario of re-associating a
device which was unlinked.
>
> You probably need to move to RCU as well in order for all of this to
> work properly since scans of the lists occur in the data path which
> is completely asynchronous and not protected by the RTNL mutex.
I'll remove all the rtnl locks and checks and switch to rcu and post
an update.
^ permalink raw reply
* Re: [iproute PATCH v3 0/6] Covscan: Misc fixes
From: Stephen Hemminger @ 2017-08-24 22:30 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
In-Reply-To: <20170824094131.2963-1-phil@nwl.cc>
On Thu, 24 Aug 2017 11:41:25 +0200
Phil Sutter <phil@nwl.cc> wrote:
> This series collects patches from v1 addressing miscellaneous issues
> detected by covscan.
>
> Changes since v2:
> - Dropped patch 1 since v2 discussion is still inconclusive.
> - Replaced patch 2 by a more appropriate one given feedback from v2.
>
> Phil Sutter (6):
> ss: Make struct tcpstat fields 'timer' and 'timeout' unsigned
> ss: Make sure scanned index value to unix_state_map is sane
> netem/maketable: Check return value of fscanf()
> lib/bpf: Check return value of write()
> lib/fs: Fix and simplify make_path()
> lib/libnetlink: Don't pass NULL parameter to memcpy()
>
> lib/bpf.c | 3 ++-
> lib/fs.c | 20 +++++---------------
> lib/libnetlink.c | 6 ++++--
> misc/ss.c | 11 +++++------
> netem/maketable.c | 4 ++--
> 5 files changed, 18 insertions(+), 26 deletions(-)
>
Applied this group
^ permalink raw reply
* Re: [iproute PATCH v3 6/6] lib/libnetlink: Don't pass NULL parameter to memcpy()
From: Stephen Hemminger @ 2017-08-24 22:29 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
In-Reply-To: <20170824094131.2963-7-phil@nwl.cc>
On Thu, 24 Aug 2017 11:41:31 +0200
Phil Sutter <phil@nwl.cc> wrote:
> Both addattr_l() and rta_addattr_l() may be called with NULL data
> pointer and 0 alen parameters. Avoid calling memcpy() in that case.
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> lib/libnetlink.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/libnetlink.c b/lib/libnetlink.c
> index 874e660be7eb4..fbe719ee10449 100644
> --- a/lib/libnetlink.c
> +++ b/lib/libnetlink.c
> @@ -871,7 +871,8 @@ int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
> rta = NLMSG_TAIL(n);
> rta->rta_type = type;
> rta->rta_len = len;
> - memcpy(RTA_DATA(rta), data, alen);
> + if (alen)
> + memcpy(RTA_DATA(rta), data, alen);
> n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
> return 0;
> }
> @@ -958,7 +959,8 @@ int rta_addattr_l(struct rtattr *rta, int maxlen, int type,
> subrta = (struct rtattr *)(((char *)rta) + RTA_ALIGN(rta->rta_len));
> subrta->rta_type = type;
> subrta->rta_len = len;
> - memcpy(RTA_DATA(subrta), data, alen);
> + if (alen)
> + memcpy(RTA_DATA(subrta), data, alen);
> rta->rta_len = NLMSG_ALIGN(rta->rta_len) + RTA_ALIGN(len);
> return 0;
> }
Ok, applied. You never know when GCC language experts might decide
to exploit undefined behavior.
^ permalink raw reply
* [PATCH net] net: systemport: Be drop monitor friendly
From: Florian Fainelli @ 2017-08-24 22:20 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, Florian Fainelli
Utilize dev_consume_skb_any(cb->skb) in bcm_sysport_free_cb() which is
used when a TX packet is completed, as well as when the RX ring is
cleaned on shutdown. None of these two cases are packet drops, so be
drop monitor friendly.
Suggested-by: Eric Dumazet <edumazet@gmail.com>
Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index dc3052751bc1..e6add99cc31c 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -597,7 +597,7 @@ static int bcm_sysport_set_coalesce(struct net_device *dev,
static void bcm_sysport_free_cb(struct bcm_sysport_cb *cb)
{
- dev_kfree_skb_any(cb->skb);
+ dev_consume_skb_any(cb->skb);
cb->skb = NULL;
dma_unmap_addr_set(cb, dma_addr, 0);
}
--
2.9.3
^ permalink raw reply related
* Re: [iproute PATCH v4 0/6] Covscan: Fixes for string termination
From: Stephen Hemminger @ 2017-08-24 22:16 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
In-Reply-To: <20170824095150.5469-1-phil@nwl.cc>
On Thu, 24 Aug 2017 11:51:44 +0200
Phil Sutter <phil@nwl.cc> wrote:
> This series collects patches from v1 dealing with code potentially
> leaving string buffers unterminated. This does not include situations
> where it happens for parsed interface names since an overall solution
> was attempted for that and it's state is still unclear due to lack of
> feedback from upstream.
>
> Changes since v3:
> - Dropped patch 2 since upstream discussion in v3 is not conclusive yet.
>
> Phil Sutter (6):
> ipntable: Avoid memory allocation for filter.name
> lib/fs: Fix format string in find_fs_mount()
> lib/inet_proto: Review inet_proto_{a2n,n2a}()
> lnstat_util: Simplify alloc_and_open() a bit
> tc/m_xt: Fix for potential string buffer overflows
> lib/ll_map: Choose size of new cache items at run-time
>
> ip/ipntable.c | 6 +++---
> lib/fs.c | 2 +-
> lib/inet_proto.c | 24 +++++++++++++-----------
> lib/ll_map.c | 4 ++--
> misc/lnstat_util.c | 7 ++-----
> tc/m_xt.c | 7 ++++---
> 6 files changed, 25 insertions(+), 25 deletions(-)
>
Applied.
^ permalink raw reply
* Re: [PATCH net-next 09/13] net: mvpp2: dynamic reconfiguration of the PHY mode
From: Russell King - ARM Linux @ 2017-08-24 22:16 UTC (permalink / raw)
To: Andrew Lunn
Cc: Antoine Tenart, davem, kishon, jason, sebastian.hesselbarth,
gregory.clement, thomas.petazzoni, nadavh, linux-kernel, mw,
stefanc, miquel.raynal, netdev
In-Reply-To: <20170824174519.GC18700@lunn.ch>
On Thu, Aug 24, 2017 at 07:45:19PM +0200, Andrew Lunn wrote:
> > The 88x3310 driver in the kernel knows about these combinations and
> > sets the phy interface parameter correctly depending on whether the
> > PHY has configured itself for copper at whatever speed or SFP+.
>
> So when the PHY decides to swap from copper to fibre etc, is the
> phylib state machine kept up to date. Does it see a down, followed by
> an up?
I'd have to re-check to make sure, but I believe it does, because the
negotiation is held off on the "other" media until the currently active
link has gone down.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
^ permalink raw reply
* Re: [PATCH v4] net: sunrpc: svcsock: fix NULL-pointer exception
From: J. Bruce Fields @ 2017-08-24 22:13 UTC (permalink / raw)
To: Jeff Layton
Cc: Vadim Lomovtsev, trond.myklebust-7I+n7zu2hftEKMMhf/gKZA,
anna.schumaker-HgOvQuBEEgTQT0dZR+AlfA,
davem-fT/PcQaiUtIeIZ0/mPfg9Q, linux-nfs-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
pabeni-H+wXaHxf7aLQT0dZR+AlfA
In-Reply-To: <1503484422.5294.0.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On Wed, Aug 23, 2017 at 06:33:42AM -0400, Jeff Layton wrote:
> I think this one looks fine. Bruce, do you mind picking this one up? It
> might also be reasonable for stable...
Yep, thanks to you both, I'll plan to send a pull request tonight or
tomorrow.
--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [Patch net-next] net_sched: remove tc class reference counting
From: Cong Wang @ 2017-08-24 22:09 UTC (permalink / raw)
To: David Miller; +Cc: Linux Kernel Network Developers, Jamal Hadi Salim
In-Reply-To: <20170824.123220.2250866539237700218.davem@davemloft.net>
On Thu, Aug 24, 2017 at 12:32 PM, David Miller <davem@davemloft.net> wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Tue, 22 Aug 2017 21:38:10 -0700
>
>> For TC classes, their ->get() and ->put() are always paired, and the
>> reference counting is completely useless, because:
>>
>> 1) For class modification and dumping paths, we already hold RTNL lock,
>> so all of these ->get(),->change(),->put() are atomic.
>>
>> 2) For filter bindiing/unbinding, we use other reference counter than
>> this one, and they should have RTNL lock too.
>>
>> 3) For ->qlen_notify(), it is special because it is called on ->enqueue()
>> path, but we already hold qdisc tree lock there, and we hold this
>> tree lock when graft or delete the class too, so it should not be gone
>> or changed until we release the tree lock.
>>
>> Therefore, this patch removes ->get() and ->put(), but:
>>
>> 1) Adds a new ->find() to find the pointer to a class by classid, no
>> refcnt.
>>
>> 2) Move the original class destroy upon the last refcnt into ->delete(),
>> right after releasing tree lock. This is fine because the class is
>> already removed from hash when holding the lock.
>>
>> For those who also use ->put() as ->unbind(), just rename them to reflect
>> this change.
>>
>> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
>> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>
> This one looks good to me.
>
> Jamal, please give it a quick look over and review.
>
Hold on, I spot a problem near ->delete(), need a fix like
I did for tc actions...
The reason why I didn't catch it in my test is actually we
don't notify delete event for classes when deleting the
whole tree.
Anyway, v2 is coming.
^ permalink raw reply
* [PATCH] cfg80211: Use tabs for identation
From: Himanshu Jha @ 2017-08-24 22:02 UTC (permalink / raw)
To: johannes; +Cc: davem, linux-wireless, netdev, linux-kernel, Himanshu Jha
Removed whitespaces and added necessary tabs conforming to coding style.
Issue found using checkpatch.pl
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
net/wireless/chan.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index b8aa5a7..13c95e5 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -984,9 +984,9 @@ int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
void
cfg80211_get_chan_state(struct wireless_dev *wdev,
- struct ieee80211_channel **chan,
- enum cfg80211_chan_mode *chanmode,
- u8 *radar_detect)
+ struct ieee80211_channel **chan,
+ enum cfg80211_chan_mode *chanmode,
+ u8 *radar_detect)
{
int ret;
--
2.7.4
^ permalink raw reply related
* Re: [iproute PATCH v4 0/4] Covscan: Fix potential NULL pointer dereferences
From: Stephen Hemminger @ 2017-08-24 21:51 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
In-Reply-To: <20170824094634.4093-1-phil@nwl.cc>
On Thu, 24 Aug 2017 11:46:30 +0200
Phil Sutter <phil@nwl.cc> wrote:
> This series collects patches from v1 which eliminate possible cases of
> NULL pointer dereferences.
>
> Changes since v3:
> - Dropped upstream rejected patch 2.
>
> Phil Sutter (4):
> ifstat, nstat: Check fdopen() return value
> tc/q_netem: Don't dereference possibly NULL pointer
> tc/tc_filter: Make sure filter name is not empty
> tipc/bearer: Prevent NULL pointer dereference
>
> misc/ifstat.c | 16 +++++++++++-----
> misc/nstat.c | 16 +++++++++++-----
> tc/q_netem.c | 3 ++-
> tc/tc_filter.c | 3 +++
> tipc/bearer.c | 2 +-
> 5 files changed, 28 insertions(+), 12 deletions(-)
>
Applied. Thanks
^ permalink raw reply
* Re: [PATCH net] virtio_net: be drop monitor friend
From: Michael S. Tsirkin @ 2017-08-24 21:42 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, Jason Wang
In-Reply-To: <1503590569.2499.81.camel@edumazet-glaptop3.roam.corp.google.com>
On Thu, Aug 24, 2017 at 09:02:49AM -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> This change is needed to not fool drop monitor.
> (perf record ... -e skb:kfree_skb )
>
> Packets were properly sent and are consumed after TX completion.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/net/virtio_net.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 98f17b05c68b..b06169ea60dc 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1058,7 +1058,7 @@ static void free_old_xmit_skbs(struct send_queue *sq)
> bytes += skb->len;
> packets++;
>
> - dev_kfree_skb_any(skb);
> + dev_consume_skb_any(skb);
> }
>
> /* Avoid overhead when no packets have been processed
>
^ permalink raw reply
* [PATCH] strparser: initialize all callbacks
From: Eric Biggers @ 2017-08-24 21:38 UTC (permalink / raw)
To: netdev
Cc: David S . Miller, linux-kernel, Eric Biggers, Dmitry Vyukov,
Tom Herbert
From: Eric Biggers <ebiggers@google.com>
commit bbb03029a899 ("strparser: Generalize strparser") added more
function pointers to 'struct strp_callbacks'; however, kcm_attach() was
not updated to initialize them. This could cause the ->lock() and/or
->unlock() function pointers to be set to garbage values, causing a
crash in strp_work().
Fix the bug by moving the callback structs into static memory, so
unspecified members are zeroed. Also constify them while we're at it.
This bug was found by syzkaller, which encountered the following splat:
IP: 0x55
PGD 3b1ca067
P4D 3b1ca067
PUD 3b12f067
PMD 0
Oops: 0010 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 2 PID: 1194 Comm: kworker/u8:1 Not tainted 4.13.0-rc4-next-20170811 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Workqueue: kstrp strp_work
task: ffff88006bb0e480 task.stack: ffff88006bb10000
RIP: 0010:0x55
RSP: 0018:ffff88006bb17540 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffff88006ce4bd60 RCX: 0000000000000000
RDX: 1ffff1000d9c97bd RSI: 0000000000000000 RDI: ffff88006ce4bc48
RBP: ffff88006bb17558 R08: ffffffff81467ab2 R09: 0000000000000000
R10: ffff88006bb17438 R11: ffff88006bb17940 R12: ffff88006ce4bc48
R13: ffff88003c683018 R14: ffff88006bb17980 R15: ffff88003c683000
FS: 0000000000000000(0000) GS:ffff88006de00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000055 CR3: 000000003c145000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
process_one_work+0xbf3/0x1bc0 kernel/workqueue.c:2098
worker_thread+0x223/0x1860 kernel/workqueue.c:2233
kthread+0x35e/0x430 kernel/kthread.c:231
ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
Code: Bad RIP value.
RIP: 0x55 RSP: ffff88006bb17540
CR2: 0000000000000055
---[ end trace f0e4920047069cee ]---
Here is a C reproducer (requires CONFIG_BPF_SYSCALL=y and
CONFIG_AF_KCM=y):
#include <linux/bpf.h>
#include <linux/kcm.h>
#include <linux/types.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <unistd.h>
static const struct bpf_insn bpf_insns[3] = {
{ .code = 0xb7 }, /* BPF_MOV64_IMM(0, 0) */
{ .code = 0x95 }, /* BPF_EXIT_INSN() */
};
static const union bpf_attr bpf_attr = {
.prog_type = 1,
.insn_cnt = 2,
.insns = (uintptr_t)&bpf_insns,
.license = (uintptr_t)"",
};
int main(void)
{
int bpf_fd = syscall(__NR_bpf, BPF_PROG_LOAD,
&bpf_attr, sizeof(bpf_attr));
int inet_fd = socket(AF_INET, SOCK_STREAM, 0);
int kcm_fd = socket(AF_KCM, SOCK_DGRAM, 0);
ioctl(kcm_fd, SIOCKCMATTACH,
&(struct kcm_attach) { .fd = inet_fd, .bpf_fd = bpf_fd });
}
Fixes: bbb03029a899 ("strparser: Generalize strparser")
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Tom Herbert <tom@quantonium.net>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
Documentation/networking/strparser.txt | 2 +-
include/net/strparser.h | 2 +-
kernel/bpf/sockmap.c | 10 +++++-----
net/kcm/kcmsock.c | 11 +++++------
net/strparser/strparser.c | 2 +-
5 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/Documentation/networking/strparser.txt b/Documentation/networking/strparser.txt
index fe01302471ae..13081b3decef 100644
--- a/Documentation/networking/strparser.txt
+++ b/Documentation/networking/strparser.txt
@@ -35,7 +35,7 @@ Functions
=========
strp_init(struct strparser *strp, struct sock *sk,
- struct strp_callbacks *cb)
+ const struct strp_callbacks *cb)
Called to initialize a stream parser. strp is a struct of type
strparser that is allocated by the upper layer. sk is the TCP
diff --git a/include/net/strparser.h b/include/net/strparser.h
index 4fe966a0ad92..7dc131d62ad5 100644
--- a/include/net/strparser.h
+++ b/include/net/strparser.h
@@ -138,7 +138,7 @@ void strp_done(struct strparser *strp);
void strp_stop(struct strparser *strp);
void strp_check_rcv(struct strparser *strp);
int strp_init(struct strparser *strp, struct sock *sk,
- struct strp_callbacks *cb);
+ const struct strp_callbacks *cb);
void strp_data_ready(struct strparser *strp);
int strp_process(struct strparser *strp, struct sk_buff *orig_skb,
unsigned int orig_offset, size_t orig_len,
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index 78b2bb9370ac..617c239590c2 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -368,12 +368,12 @@ static int smap_read_sock_done(struct strparser *strp, int err)
static int smap_init_sock(struct smap_psock *psock,
struct sock *sk)
{
- struct strp_callbacks cb;
+ static const struct strp_callbacks cb = {
+ .rcv_msg = smap_read_sock_strparser,
+ .parse_msg = smap_parse_func_strparser,
+ .read_sock_done = smap_read_sock_done,
+ };
- memset(&cb, 0, sizeof(cb));
- cb.rcv_msg = smap_read_sock_strparser;
- cb.parse_msg = smap_parse_func_strparser;
- cb.read_sock_done = smap_read_sock_done;
return strp_init(&psock->strp, sk, &cb);
}
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 88ce73288247..48e993b2dbcf 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1376,7 +1376,11 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
struct kcm_psock *psock = NULL, *tpsock;
struct list_head *head;
int index = 0;
- struct strp_callbacks cb;
+ static const struct strp_callbacks cb = {
+ .rcv_msg = kcm_rcv_strparser,
+ .parse_msg = kcm_parse_func_strparser,
+ .read_sock_done = kcm_read_sock_done,
+ };
int err;
csk = csock->sk;
@@ -1391,11 +1395,6 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
psock->sk = csk;
psock->bpf_prog = prog;
- cb.rcv_msg = kcm_rcv_strparser;
- cb.abort_parser = NULL;
- cb.parse_msg = kcm_parse_func_strparser;
- cb.read_sock_done = kcm_read_sock_done;
-
err = strp_init(&psock->strp, csk, &cb);
if (err) {
kmem_cache_free(kcm_psockp, psock);
diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
index 434aa6637a52..d4ea46a5f233 100644
--- a/net/strparser/strparser.c
+++ b/net/strparser/strparser.c
@@ -472,7 +472,7 @@ static void strp_sock_unlock(struct strparser *strp)
}
int strp_init(struct strparser *strp, struct sock *sk,
- struct strp_callbacks *cb)
+ const struct strp_callbacks *cb)
{
if (!cb || !cb->rcv_msg || !cb->parse_msg)
--
2.14.1.342.g6490525c54-goog
^ permalink raw reply related
* Re: [PATCH][next] net: hinic: fix comparison of a uint16_t type with -1
From: David Miller @ 2017-08-24 21:32 UTC (permalink / raw)
To: colin.king; +Cc: aviad.krawczyk, netdev, kernel-janitors, linux-kernel
In-Reply-To: <20170823153936.22857-1-colin.king@canonical.com>
From: Colin King <colin.king@canonical.com>
Date: Wed, 23 Aug 2017 16:39:36 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> The comparison of hw_ioctxt.rx_buf_sz_idx == -1 is always false because
> rx_buf_sz_idx is a uint16_t. Fix this by explicitly casting -1 to uint16_t.
>
> Detected by CoverityScan, CID#1454559 ("Operands don't affect result")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
> index 09dec6de8dd5..71e26070fb7f 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
> @@ -352,7 +352,7 @@ static int set_hw_ioctxt(struct hinic_hwdev *hwdev, unsigned int rq_depth,
> }
> }
>
> - if (hw_ioctxt.rx_buf_sz_idx == -1)
> + if (hw_ioctxt.rx_buf_sz_idx == (uint16_t)-1)
> return -EINVAL;
>
> hw_ioctxt.sq_depth = ilog2(sq_depth);
This is really silly.
The code in question is trying to convert a size (HINIC_RX_BUF_SZ)
into a table index, using a loop.
It should just compute this at compile time and do away with this
overly confusing code.
Even a switch statement would be much better and the compiler
would optimize the whole away into a single assignment in
the generated code.
^ permalink raw reply
* [PATCH] staging: rtlwifi: Improve debugging by using debugfs
From: Larry Finger @ 2017-08-24 21:28 UTC (permalink / raw)
To: gregkh
Cc: netdev, devel, Larry Finger, Ping-Ke Shih, Yan-Hsuan Chuang,
Birming Chiu, Shaofu, Steven Ting
The changes in this commit are also being sent to the main rtlwifi
drivers in wireless-next; however, these changes will also be useful for
any debugging of r8822be before it gets moved into the main tree.
Use debugfs to dump register and btcoex status, and also write registers
and h2c.
We create topdir in /sys/kernel/debug/rtlwifi/, and use the MAC address
as subdirectory with several entries to dump mac_reg, bb_reg, rf_reg etc.
An example is
/sys/kernel/debug/rtlwifi/00-11-22-33-44-55-66/mac_0
This change permits examination of device registers in a dynamic manner,
a feature not available with the current debug mechanism.
We use seq_file to replace RT_TRACE to dump status, then we can use 'cat'
to access btcoex's status through debugfs.
(i.e. /sys/kernel/debug/rtlwifi/00-11-22-33-44-55-66/btcoex)
Other related changes are
1. implement btc_disp_dbg_msg() to access btcoex's common status.
2. remove obsolete field bt_exist
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Yan-Hsuan Chuang <yhchuang@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
drivers/staging/rtlwifi/debug.c | 226 ++++++++++++++++++++++++----------------
1 file changed, 135 insertions(+), 91 deletions(-)
diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c
index b9fd47aeaa9b..7446d71c41d1 100644
--- a/drivers/staging/rtlwifi/debug.c
+++ b/drivers/staging/rtlwifi/debug.c
@@ -80,9 +80,11 @@ void _rtl_dbg_print_data(struct rtl_priv *rtlpriv, u64 comp, int level,
}
}
-struct rtl_debgufs_priv {
+struct rtl_debugfs_priv {
struct rtl_priv *rtlpriv;
- int (*cb)(struct seq_file *m, void *v);
+ int (*cb_read)(struct seq_file *m, void *v);
+ ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
+ size_t count, loff_t *loff);
u32 cb_data;
};
@@ -90,9 +92,9 @@ static struct dentry *debugfs_topdir;
static int rtl_debug_get_common(struct seq_file *m, void *v)
{
- struct rtl_debgufs_priv *debugfs_priv = m->private;
+ struct rtl_debugfs_priv *debugfs_priv = m->private;
- return debugfs_priv->cb(m, v);
+ return debugfs_priv->cb_read(m, v);
}
static int dl_debug_open_common(struct inode *inode, struct file *file)
@@ -109,7 +111,7 @@ static const struct file_operations file_ops_common = {
static int rtl_debug_get_mac_page(struct seq_file *m, void *v)
{
- struct rtl_debgufs_priv *debugfs_priv = m->private;
+ struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
u32 page = debugfs_priv->cb_data;
int i, n;
@@ -126,8 +128,8 @@ static int rtl_debug_get_mac_page(struct seq_file *m, void *v)
}
#define RTL_DEBUG_IMPL_MAC_SERIES(page, addr) \
-struct rtl_debgufs_priv rtl_debug_priv_mac_ ##page = { \
- .cb = rtl_debug_get_mac_page, \
+struct rtl_debugfs_priv rtl_debug_priv_mac_ ##page = { \
+ .cb_read = rtl_debug_get_mac_page, \
.cb_data = addr, \
}
@@ -150,7 +152,7 @@ RTL_DEBUG_IMPL_MAC_SERIES(17, 0x1700);
static int rtl_debug_get_bb_page(struct seq_file *m, void *v)
{
- struct rtl_debgufs_priv *debugfs_priv = m->private;
+ struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
struct ieee80211_hw *hw = rtlpriv->hw;
u32 page = debugfs_priv->cb_data;
@@ -168,8 +170,8 @@ static int rtl_debug_get_bb_page(struct seq_file *m, void *v)
}
#define RTL_DEBUG_IMPL_BB_SERIES(page, addr) \
-struct rtl_debgufs_priv rtl_debug_priv_bb_ ##page = { \
- .cb = rtl_debug_get_bb_page, \
+struct rtl_debugfs_priv rtl_debug_priv_bb_ ##page = { \
+ .cb_read = rtl_debug_get_bb_page, \
.cb_data = addr, \
}
@@ -192,7 +194,7 @@ RTL_DEBUG_IMPL_BB_SERIES(1f, 0x1f00);
static int rtl_debug_get_reg_rf(struct seq_file *m, void *v)
{
- struct rtl_debgufs_priv *debugfs_priv = m->private;
+ struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
struct ieee80211_hw *hw = rtlpriv->hw;
enum radio_path rfpath = debugfs_priv->cb_data;
@@ -215,8 +217,8 @@ static int rtl_debug_get_reg_rf(struct seq_file *m, void *v)
}
#define RTL_DEBUG_IMPL_RF_SERIES(page, addr) \
-struct rtl_debgufs_priv rtl_debug_priv_rf_ ##page = { \
- .cb = rtl_debug_get_reg_rf, \
+struct rtl_debugfs_priv rtl_debug_priv_rf_ ##page = { \
+ .cb_read = rtl_debug_get_reg_rf, \
.cb_data = addr, \
}
@@ -225,7 +227,7 @@ RTL_DEBUG_IMPL_RF_SERIES(b, RF90_PATH_B);
static int rtl_debug_get_cam_register(struct seq_file *m, void *v)
{
- struct rtl_debgufs_priv *debugfs_priv = m->private;
+ struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
int start = debugfs_priv->cb_data;
u32 target_cmd = 0;
@@ -270,8 +272,8 @@ static int rtl_debug_get_cam_register(struct seq_file *m, void *v)
}
#define RTL_DEBUG_IMPL_CAM_SERIES(page, addr) \
-struct rtl_debgufs_priv rtl_debug_priv_cam_ ##page = { \
- .cb = rtl_debug_get_cam_register, \
+struct rtl_debugfs_priv rtl_debug_priv_cam_ ##page = { \
+ .cb_read = rtl_debug_get_cam_register, \
.cb_data = addr, \
}
@@ -281,7 +283,7 @@ RTL_DEBUG_IMPL_CAM_SERIES(3, 22);
static int rtl_debug_get_btcoex(struct seq_file *m, void *v)
{
- struct rtl_debgufs_priv *debugfs_priv = m->private;
+ struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
if (rtlpriv->cfg->ops->get_btc_status())
@@ -293,8 +295,8 @@ static int rtl_debug_get_btcoex(struct seq_file *m, void *v)
return 0;
}
-static struct rtl_debgufs_priv rtl_debug_priv_btcoex = {
- .cb = rtl_debug_get_btcoex,
+static struct rtl_debugfs_priv rtl_debug_priv_btcoex = {
+ .cb_read = rtl_debug_get_btcoex,
.cb_data = 0,
};
@@ -302,18 +304,15 @@ static ssize_t rtl_debugfs_set_write_reg(struct file *filp,
const char __user *buffer,
size_t count, loff_t *loff)
{
- struct rtl_debgufs_priv *debugfs_priv = filp->private_data;
+ struct rtl_debugfs_priv *debugfs_priv = filp->private_data;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
- struct ieee80211_hw *hw = rtlpriv->hw;
char tmp[32 + 1];
int tmp_len;
u32 addr, val, len;
int num;
- if (count < 3) {
- /*printk("argument size is less than 3\n");*/
+ if (count < 3)
return -EFAULT;
- }
tmp_len = (count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count);
@@ -322,57 +321,11 @@ static ssize_t rtl_debugfs_set_write_reg(struct file *filp,
tmp[tmp_len] = '\0';
- /* write H2C */
- if (!strncmp(tmp, "h2c", 3)) {
- u8 h2c_len, h2c_data_packed[8];
- int h2c_data[8]; /* idx 0: cmd */
- int i;
-
- h2c_len = sscanf(tmp + 3, "%X %X %X %X %X %X %X %X",
- &h2c_data[0], &h2c_data[1],
- &h2c_data[2], &h2c_data[3],
- &h2c_data[4], &h2c_data[5],
- &h2c_data[6], &h2c_data[7]);
-
- if (h2c_len <= 0)
- return count;
-
- for (i = 0; i < h2c_len; i++)
- h2c_data_packed[i] = (u8)h2c_data[i];
-
- rtlpriv->cfg->ops->fill_h2c_cmd(hw, h2c_data_packed[0],
- h2c_len - 1,
- &h2c_data_packed[1]);
-
- return count;
- }
-
- /* write RF register */
- if (!strncmp(tmp, "rf", 2)) {
- int path;
- u32 addr, bitmask, data;
-
- num = sscanf(tmp + 2, "%X %X %X %X",
- &path, &addr, &bitmask, &data);
-
- if (num != 4) {
- RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
- "Format is <path> <addr> <mask> <data>\n");
- return count;
- }
-
- rtl_set_rfreg(hw, path, addr, bitmask, data);
-
- return count;
- }
-
/* write BB/MAC register */
- num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
+ num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
- if (num != 3) {
- /*printk("invalid write_reg parameter!\n");*/
+ if (num != 3)
return count;
- }
switch (len) {
case 1:
@@ -392,27 +345,115 @@ static ssize_t rtl_debugfs_set_write_reg(struct file *filp,
return count;
}
-static int rtl_debugfs_open(struct inode *inode, struct file *filp)
+static struct rtl_debugfs_priv rtl_debug_priv_write_reg = {
+ .cb_write = rtl_debugfs_set_write_reg,
+};
+
+static ssize_t rtl_debugfs_set_write_h2c(struct file *filp,
+ const char __user *buffer,
+ size_t count, loff_t *loff)
{
- filp->private_data = inode->i_private;
+ struct rtl_debugfs_priv *debugfs_priv = filp->private_data;
+ struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
+ struct ieee80211_hw *hw = rtlpriv->hw;
+ char tmp[32 + 1];
+ int tmp_len;
+ u8 h2c_len, h2c_data_packed[8];
+ int h2c_data[8]; /* idx 0: cmd */
+ int i;
- return 0;
+ if (count < 3)
+ return -EFAULT;
+
+ tmp_len = (count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count);
+
+ if (!buffer || copy_from_user(tmp, buffer, tmp_len))
+ return count;
+
+ tmp[tmp_len] = '\0';
+
+ h2c_len = sscanf(tmp, "%X %X %X %X %X %X %X %X",
+ &h2c_data[0], &h2c_data[1],
+ &h2c_data[2], &h2c_data[3],
+ &h2c_data[4], &h2c_data[5],
+ &h2c_data[6], &h2c_data[7]);
+
+ if (h2c_len <= 0)
+ return count;
+
+ for (i = 0; i < h2c_len; i++)
+ h2c_data_packed[i] = (u8)h2c_data[i];
+
+ rtlpriv->cfg->ops->fill_h2c_cmd(hw, h2c_data_packed[0],
+ h2c_len - 1,
+ &h2c_data_packed[1]);
+
+ return count;
+}
+
+static struct rtl_debugfs_priv rtl_debug_priv_write_h2c = {
+ .cb_write = rtl_debugfs_set_write_h2c,
+};
+
+static ssize_t rtl_debugfs_set_write_rfreg(struct file *filp,
+ const char __user *buffer,
+ size_t count, loff_t *loff)
+{
+ struct rtl_debugfs_priv *debugfs_priv = filp->private_data;
+ struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
+ struct ieee80211_hw *hw = rtlpriv->hw;
+ char tmp[32 + 1];
+ int tmp_len;
+ int num;
+ int path;
+ u32 addr, bitmask, data;
+
+ if (count < 3)
+ return -EFAULT;
+
+ tmp_len = (count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count);
+
+ if (!buffer || copy_from_user(tmp, buffer, tmp_len))
+ return count;
+
+ tmp[tmp_len] = '\0';
+
+ num = sscanf(tmp, "%X %X %X %X",
+ &path, &addr, &bitmask, &data);
+
+ if (num != 4) {
+ RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
+ "Format is <path> <addr> <mask> <data>\n");
+ return count;
+ }
+
+ rtl_set_rfreg(hw, path, addr, bitmask, data);
+
+ return count;
}
+static struct rtl_debugfs_priv rtl_debug_priv_write_rfreg = {
+ .cb_write = rtl_debugfs_set_write_rfreg,
+};
+
static int rtl_debugfs_close(struct inode *inode, struct file *filp)
{
return 0;
}
-static struct rtl_debgufs_priv rtl_debug_priv_write_reg = {
- .cb = NULL,
- .cb_data = 0,
-};
+static ssize_t rtl_debugfs_common_write(struct file *filp,
+ const char __user *buffer,
+ size_t count, loff_t *loff)
+{
+ struct rtl_debugfs_priv *debugfs_priv = filp->private_data;
+
+ return debugfs_priv->cb_write(filp, buffer, count, loff);
+}
-static const struct file_operations file_ops_write_reg = {
+static const struct file_operations file_ops_common_write = {
.owner = THIS_MODULE,
- .write = rtl_debugfs_set_write_reg,
- .open = rtl_debugfs_open,
+ .write = rtl_debugfs_common_write,
+ .open = simple_open,
.release = rtl_debugfs_close,
};
@@ -420,7 +461,7 @@ static ssize_t rtl_debugfs_phydm_cmd(struct file *filp,
const char __user *buffer,
size_t count, loff_t *loff)
{
- struct rtl_debgufs_priv *debugfs_priv = filp->private_data;
+ struct rtl_debugfs_priv *debugfs_priv = filp->private_data;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
char tmp[64];
@@ -444,7 +485,7 @@ static ssize_t rtl_debugfs_phydm_cmd(struct file *filp,
static int rtl_debug_get_phydm_cmd(struct seq_file *m, void *v)
{
- struct rtl_debgufs_priv *debugfs_priv = m->private;
+ struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
if (rtlpriv->dbg.msg_buf)
@@ -456,7 +497,7 @@ static int rtl_debug_get_phydm_cmd(struct seq_file *m, void *v)
static int rtl_debugfs_open_rw(struct inode *inode, struct file *filp)
{
if (filp->f_mode & FMODE_READ)
- single_open(filp, rtl_debug_get_phydm_cmd, inode->i_private);
+ single_open(filp, rtl_debug_get_common, inode->i_private);
else
filp->private_data = inode->i_private;
@@ -471,18 +512,19 @@ static int rtl_debugfs_close_rw(struct inode *inode, struct file *filp)
return 0;
}
-static struct rtl_debgufs_priv rtl_debug_priv_phydm_cmd = {
- .cb = NULL,
+static struct rtl_debugfs_priv rtl_debug_priv_phydm_cmd = {
+ .cb_read = rtl_debug_get_phydm_cmd,
+ .cb_write = rtl_debugfs_phydm_cmd,
.cb_data = 0,
};
-static const struct file_operations file_ops_phydm_cmd = {
+static const struct file_operations file_ops_common_rw = {
.owner = THIS_MODULE,
.open = rtl_debugfs_open_rw,
.release = rtl_debugfs_close_rw,
.read = seq_read,
.llseek = seq_lseek,
- .write = rtl_debugfs_phydm_cmd,
+ .write = rtl_debugfs_common_write,
};
#define RTL_DEBUGFS_ADD_CORE(name, mode, fopname) \
@@ -499,9 +541,9 @@ static const struct file_operations file_ops_phydm_cmd = {
#define RTL_DEBUGFS_ADD(name) \
RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0444, common)
#define RTL_DEBUGFS_ADD_W(name) \
- RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0222, write_reg)
+ RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0222, common_write)
#define RTL_DEBUGFS_ADD_RW(name) \
- RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0666, phydm_cmd)
+ RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0666, common_rw)
void rtl_debug_add_one(struct ieee80211_hw *hw)
{
@@ -565,6 +607,8 @@ void rtl_debug_add_one(struct ieee80211_hw *hw)
RTL_DEBUGFS_ADD(btcoex);
RTL_DEBUGFS_ADD_W(write_reg);
+ RTL_DEBUGFS_ADD_W(write_h2c);
+ RTL_DEBUGFS_ADD_W(write_rfreg);
RTL_DEBUGFS_ADD_RW(phydm_cmd);
}
--
2.12.3
^ permalink raw reply related
* Re: [PATCH net-next 1/3] gre: refactor the gre_fb_xmit
From: David Miller @ 2017-08-24 21:16 UTC (permalink / raw)
To: u9012063; +Cc: netdev
In-Reply-To: <1503500157-3717-1-git-send-email-u9012063@gmail.com>
Please repost this series with a proper "[PATCH net-next 0/3] ..." header
posting.
Thank you.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox