DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v3 5/5] net/tap: fix netlink socket file descriptor check before close
@ 2020-04-07  4:23 wangyunjian
  2020-04-07 15:35 ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: wangyunjian @ 2020-04-07  4:23 UTC (permalink / raw)
  To: dev; +Cc: keith.wiles, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The "internals->nlsk_fd" is possibly a zero value. Error comparison
should check for negative fd.

Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and actions")
CC: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/tap/rte_eth_tap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 88cd615e0..ff149342b 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2442,7 +2442,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
 	TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u",
 		tuntap_types[internals->type], rte_socket_id());
 
-	if (internals->nlsk_fd) {
+	if (internals->nlsk_fd >= 0) {
 		tap_flow_flush(eth_dev, NULL);
 		tap_flow_implicit_flush(internals, NULL);
 		tap_nl_final(internals->nlsk_fd);
-- 
2.19.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/5] net/tap: fix netlink socket file descriptor check before close
  2020-04-07  4:23 [dpdk-dev] [PATCH v3 5/5] net/tap: fix netlink socket file descriptor check before close wangyunjian
@ 2020-04-07 15:35 ` Ferruh Yigit
  2020-04-08  0:55   ` wangyunjian
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2020-04-07 15:35 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: keith.wiles, jerry.lilijun, xudingke, stable

On 4/7/2020 5:23 AM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The "internals->nlsk_fd" is possibly a zero value. Error comparison
> should check for negative fd.
> 
> Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and actions")
> CC: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  drivers/net/tap/rte_eth_tap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 88cd615e0..ff149342b 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -2442,7 +2442,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
>  	TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u",
>  		tuntap_types[internals->type], rte_socket_id());
>  
> -	if (internals->nlsk_fd) {
> +	if (internals->nlsk_fd >= 0) {

I guess it is unlikely socket() will return 0 as fd, but technically it seems
possible.

'tap_nl_init()' either returns '-1' for error or a valid fd, and this has been
checked as "pmd->nlsk_fd == -1" in other locations, what about doing similar here:

"if (internals->nlsk_fd != -1)"

>  		tap_flow_flush(eth_dev, NULL);
>  		tap_flow_implicit_flush(internals, NULL);
>  		tap_nl_final(internals->nlsk_fd);
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/5] net/tap: fix netlink socket file descriptor check before close
  2020-04-07 15:35 ` Ferruh Yigit
@ 2020-04-08  0:55   ` wangyunjian
  0 siblings, 0 replies; 3+ messages in thread
From: wangyunjian @ 2020-04-08  0:55 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: keith.wiles, Lilijun (Jerry), xudingke, stable

> -----Original Message-----
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Tuesday, April 7, 2020 11:36 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: keith.wiles@intel.com; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3 5/5] net/tap: fix netlink socket file descriptor
> check before close
> 
> On 4/7/2020 5:23 AM, wangyunjian wrote:
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > The "internals->nlsk_fd" is possibly a zero value. Error comparison
> > should check for negative fd.
> >
> > Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and
> > actions")
> > CC: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> >  drivers/net/tap/rte_eth_tap.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/tap/rte_eth_tap.c
> > b/drivers/net/tap/rte_eth_tap.c index 88cd615e0..ff149342b 100644
> > --- a/drivers/net/tap/rte_eth_tap.c
> > +++ b/drivers/net/tap/rte_eth_tap.c
> > @@ -2442,7 +2442,7 @@ rte_pmd_tap_remove(struct rte_vdev_device
> *dev)
> >  	TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u",
> >  		tuntap_types[internals->type], rte_socket_id());
> >
> > -	if (internals->nlsk_fd) {
> > +	if (internals->nlsk_fd >= 0) {
> 
> I guess it is unlikely socket() will return 0 as fd, but technically it seems
> possible.
> 
> 'tap_nl_init()' either returns '-1' for error or a valid fd, and this has been
> checked as "pmd->nlsk_fd == -1" in other locations, what about doing similar
> here:
> 
> "if (internals->nlsk_fd != -1)"

OK, will do this in v4.

Thanks
Yunjian
> 
> >  		tap_flow_flush(eth_dev, NULL);
> >  		tap_flow_implicit_flush(internals, NULL);
> >  		tap_nl_final(internals->nlsk_fd);
> >


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-08  0:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07  4:23 [dpdk-dev] [PATCH v3 5/5] net/tap: fix netlink socket file descriptor check before close wangyunjian
2020-04-07 15:35 ` Ferruh Yigit
2020-04-08  0:55   ` wangyunjian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).