All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: Get rid of consume_skb when tracing is off
@ 2020-08-21 22:23 Herbert Xu
  2020-08-21 23:40 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Herbert Xu @ 2020-08-21 22:23 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, netdev; +Cc: Neil Horman

The function consume_skb is only meaningful when tracing is enabled.
This patch makes it conditional on CONFIG_TRACEPOINTS.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 46881d902124..e8bca74857a3 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1056,7 +1056,16 @@ void kfree_skb(struct sk_buff *skb);
 void kfree_skb_list(struct sk_buff *segs);
 void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt);
 void skb_tx_error(struct sk_buff *skb);
+
+#ifdef CONFIG_TRACEPOINTS
 void consume_skb(struct sk_buff *skb);
+#else
+static inline void consume_skb(struct sk_buff *skb)
+{
+	return kfree_skb(skb);
+}
+#endif
+
 void __consume_stateless_skb(struct sk_buff *skb);
 void  __kfree_skb(struct sk_buff *skb);
 extern struct kmem_cache *skbuff_head_cache;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7e2e502ef519..593fe73d4993 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -820,6 +820,7 @@ void skb_tx_error(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(skb_tx_error);
 
+#ifdef CONFIG_TRACEPOINTS
 /**
  *	consume_skb - free an skbuff
  *	@skb: buffer to free
@@ -837,6 +838,7 @@ void consume_skb(struct sk_buff *skb)
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(consume_skb);
+#endif
 
 /**
  *	consume_stateless_skb - free an skbuff, assuming it is stateless
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
  2020-08-21 22:23 [PATCH] net: Get rid of consume_skb when tracing is off Herbert Xu
@ 2020-08-21 23:40 ` Eric Dumazet
  2020-08-22  1:08   ` Herbert Xu
  2020-08-22 17:54 ` Neil Horman
  2020-08-24 23:12 ` David Miller
  2 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2020-08-21 23:40 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Jakub Kicinski, netdev; +Cc: Neil Horman



On 8/21/20 3:23 PM, Herbert Xu wrote:
> The function consume_skb is only meaningful when tracing is enabled.
> This patch makes it conditional on CONFIG_TRACEPOINTS.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> 


I am not completely familiar with CONFIG_TRACEPOINTS

Is "perf probe" support requiring it ?

We want the following to be supported.

perf probe consume_skb



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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
  2020-08-21 23:40 ` Eric Dumazet
@ 2020-08-22  1:08   ` Herbert Xu
  0 siblings, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2020-08-22  1:08 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, Jakub Kicinski, netdev, Neil Horman

On Fri, Aug 21, 2020 at 04:40:49PM -0700, Eric Dumazet wrote:
>
> I am not completely familiar with CONFIG_TRACEPOINTS
> 
> Is "perf probe" support requiring it ?

Yes.

perf probe requires CONFIG_KPROBE_EVENTS which selects CONFIG_TRACING
which selects CONFIG_TRACEPOINTS.

> We want the following to be supported.
> 
> perf probe consume_skb

That should continue to work as this patch does not change anything
when CONFIG_TRACEPOINTS is enabled.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
  2020-08-21 22:23 [PATCH] net: Get rid of consume_skb when tracing is off Herbert Xu
  2020-08-21 23:40 ` Eric Dumazet
@ 2020-08-22 17:54 ` Neil Horman
  2020-08-22 19:49   ` David Miller
  2020-08-22 22:47   ` Herbert Xu
  2020-08-24 23:12 ` David Miller
  2 siblings, 2 replies; 9+ messages in thread
From: Neil Horman @ 2020-08-22 17:54 UTC (permalink / raw)
  To: Herbert Xu; +Cc: David S. Miller, Jakub Kicinski, netdev, Neil Horman

On Sat, Aug 22, 2020 at 08:23:29AM +1000, Herbert Xu wrote:
> The function consume_skb is only meaningful when tracing is enabled.
> This patch makes it conditional on CONFIG_TRACEPOINTS.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 46881d902124..e8bca74857a3 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -1056,7 +1056,16 @@ void kfree_skb(struct sk_buff *skb);
>  void kfree_skb_list(struct sk_buff *segs);
>  void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt);
>  void skb_tx_error(struct sk_buff *skb);
> +
> +#ifdef CONFIG_TRACEPOINTS
>  void consume_skb(struct sk_buff *skb);
> +#else
> +static inline void consume_skb(struct sk_buff *skb)
> +{
> +	return kfree_skb(skb);
> +}
> +#endif
> +
Wouldn't it be better to make this:
#define consume_skb(x) kfree_skb(x)
?
Best
Neil

>  void __consume_stateless_skb(struct sk_buff *skb);
>  void  __kfree_skb(struct sk_buff *skb);
>  extern struct kmem_cache *skbuff_head_cache;
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 7e2e502ef519..593fe73d4993 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -820,6 +820,7 @@ void skb_tx_error(struct sk_buff *skb)
>  }
>  EXPORT_SYMBOL(skb_tx_error);
>  
> +#ifdef CONFIG_TRACEPOINTS
>  /**
>   *	consume_skb - free an skbuff
>   *	@skb: buffer to free
> @@ -837,6 +838,7 @@ void consume_skb(struct sk_buff *skb)
>  	__kfree_skb(skb);
>  }
>  EXPORT_SYMBOL(consume_skb);
> +#endif
>  
>  /**
>   *	consume_stateless_skb - free an skbuff, assuming it is stateless
> -- 
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
> 

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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
  2020-08-22 17:54 ` Neil Horman
@ 2020-08-22 19:49   ` David Miller
  2020-08-24 12:17     ` Neil Horman
  2020-08-22 22:47   ` Herbert Xu
  1 sibling, 1 reply; 9+ messages in thread
From: David Miller @ 2020-08-22 19:49 UTC (permalink / raw)
  To: herbert, kuba, netdev, nhorman


From: Neil Horman <nhorman@localhost.localdomain>

Neil, you might want to fix this so people can reply to you :-)

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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
  2020-08-22 17:54 ` Neil Horman
  2020-08-22 19:49   ` David Miller
@ 2020-08-22 22:47   ` Herbert Xu
  1 sibling, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2020-08-22 22:47 UTC (permalink / raw)
  To: Neil Horman; +Cc: David S. Miller, Jakub Kicinski, netdev

On Sat, Aug 22, 2020 at 01:54:19PM -0400, Neil Horman wrote:
>
> Wouldn't it be better to make this:
> #define consume_skb(x) kfree_skb(x)

Either way is fine but I prefer inline functions over macros.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
  2020-08-22 19:49   ` David Miller
@ 2020-08-24 12:17     ` Neil Horman
  0 siblings, 0 replies; 9+ messages in thread
From: Neil Horman @ 2020-08-24 12:17 UTC (permalink / raw)
  To: David Miller; +Cc: herbert, kuba, netdev, nhorman

On Sat, Aug 22, 2020 at 12:49:02PM -0700, David Miller wrote:
> 
> From: Neil Horman <nhorman@localhost.localdomain>
> 
> Neil, you might want to fix this so people can reply to you :-)
Crap, thanks, new computer.

Neil

> 

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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
  2020-08-21 22:23 [PATCH] net: Get rid of consume_skb when tracing is off Herbert Xu
  2020-08-21 23:40 ` Eric Dumazet
  2020-08-22 17:54 ` Neil Horman
@ 2020-08-24 23:12 ` David Miller
  2 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2020-08-24 23:12 UTC (permalink / raw)
  To: herbert; +Cc: kuba, netdev, nhorman

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sat, 22 Aug 2020 08:23:29 +1000

> The function consume_skb is only meaningful when tracing is enabled.
> This patch makes it conditional on CONFIG_TRACEPOINTS.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Fair enough, applied, thanks.

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

* Re: [PATCH] net: Get rid of consume_skb when tracing is off
@ 2020-08-22  2:57 kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2020-08-22  2:57 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200821222329.GA2633@gondor.apana.org.au>
References: <20200821222329.GA2633@gondor.apana.org.au>
TO: Herbert Xu <herbert@gondor.apana.org.au>
TO: "David S. Miller" <davem@davemloft.net>
CC: netdev(a)vger.kernel.org
TO: Jakub Kicinski <kuba@kernel.org>
CC: Neil Horman <nhorman@tuxdriver.com>

Hi Herbert,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on net/master linus/master v5.9-rc1 next-20200821]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Herbert-Xu/net-Get-rid-of-consume_skb-when-tracing-is-off/20200822-062427
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git d0a84e1f38d9d6ae2dfab0b6c2407d667a265aa5
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-randconfig-m021-20200820 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
net/unix/af_unix.c:2402 unix_stream_read_generic() warn: passing freed memory 'skb'
net/unix/af_unix.c:2427 unix_stream_read_generic() error: dereferencing freed memory 'skb'

Old smatch warnings:
net/unix/af_unix.c:1810 unix_dgram_sendmsg() error: double unlocked 'unix_sk(other)->lock' (orig line 1776)
net/unix/af_unix.c:2406 unix_stream_read_generic() warn: passing freed memory 'skb'

# https://github.com/0day-ci/linux/commit/f6029670e7c494f4ce36a824519abfe366ddb77f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Herbert-Xu/net-Get-rid-of-consume_skb-when-tracing-is-off/20200822-062427
git checkout f6029670e7c494f4ce36a824519abfe366ddb77f
vim +/skb +2402 net/unix/af_unix.c

2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2246  
06a77b07e3b44a WANG Cong            2016-11-17  2247  static int unix_stream_read_generic(struct unix_stream_read_state *state,
06a77b07e3b44a WANG Cong            2016-11-17  2248  				    bool freezable)
^1da177e4c3f41 Linus Torvalds       2005-04-16  2249  {
7cc05662682da4 Christoph Hellwig    2015-01-28  2250  	struct scm_cookie scm;
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2251  	struct socket *sock = state->socket;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2252  	struct sock *sk = sock->sk;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2253  	struct unix_sock *u = unix_sk(sk);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2254  	int copied = 0;
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2255  	int flags = state->flags;
de1443916791d7 Eric Dumazet         2014-03-25  2256  	int noblock = flags & MSG_DONTWAIT;
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2257  	bool check_creds = false;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2258  	int target;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2259  	int err = 0;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2260  	long timeo;
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2261  	int skip;
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2262  	size_t size = state->size;
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2263  	unsigned int last_len;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2264  
1b92ee3d03af66 Rainer Weikusat      2016-02-08  2265  	if (unlikely(sk->sk_state != TCP_ESTABLISHED)) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2266  		err = -EINVAL;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2267  		goto out;
1b92ee3d03af66 Rainer Weikusat      2016-02-08  2268  	}
^1da177e4c3f41 Linus Torvalds       2005-04-16  2269  
1b92ee3d03af66 Rainer Weikusat      2016-02-08  2270  	if (unlikely(flags & MSG_OOB)) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2271  		err = -EOPNOTSUPP;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2272  		goto out;
1b92ee3d03af66 Rainer Weikusat      2016-02-08  2273  	}
^1da177e4c3f41 Linus Torvalds       2005-04-16  2274  
^1da177e4c3f41 Linus Torvalds       2005-04-16  2275  	target = sock_rcvlowat(sk, flags & MSG_WAITALL, size);
de1443916791d7 Eric Dumazet         2014-03-25  2276  	timeo = sock_rcvtimeo(sk, noblock);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2277  
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2278  	memset(&scm, 0, sizeof(scm));
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2279  
^1da177e4c3f41 Linus Torvalds       2005-04-16  2280  	/* Lock the socket to prevent queue disordering
^1da177e4c3f41 Linus Torvalds       2005-04-16  2281  	 * while sleeps in memcpy_tomsg
^1da177e4c3f41 Linus Torvalds       2005-04-16  2282  	 */
6e1ce3c3451291 Linus Torvalds       2016-09-01  2283  	mutex_lock(&u->iolock);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2284  
a0917e0bc6efc0 Matthew Dawson       2017-08-18  2285  	skip = max(sk_peek_offset(sk, flags), 0);
e9193d60d363e4 Andrey Vagin         2015-10-02  2286  
6eba6a372b501a Eric Dumazet         2008-11-16  2287  	do {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2288  		int chunk;
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2289  		bool drop_skb;
79f632c71bea0d Benjamin Poirier     2013-04-29  2290  		struct sk_buff *skb, *last;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2291  
18eceb818dc37b Rainer Weikusat      2016-02-18  2292  redo:
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2293  		unix_state_lock(sk);
b48732e4a48d80 Mark Salyzyn         2015-05-26  2294  		if (sock_flag(sk, SOCK_DEAD)) {
b48732e4a48d80 Mark Salyzyn         2015-05-26  2295  			err = -ECONNRESET;
b48732e4a48d80 Mark Salyzyn         2015-05-26  2296  			goto unlock;
b48732e4a48d80 Mark Salyzyn         2015-05-26  2297  		}
79f632c71bea0d Benjamin Poirier     2013-04-29  2298  		last = skb = skb_peek(&sk->sk_receive_queue);
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2299  		last_len = last ? last->len : 0;
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2300  again:
6eba6a372b501a Eric Dumazet         2008-11-16  2301  		if (skb == NULL) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2302  			if (copied >= target)
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2303  				goto unlock;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2304  
^1da177e4c3f41 Linus Torvalds       2005-04-16  2305  			/*
^1da177e4c3f41 Linus Torvalds       2005-04-16  2306  			 *	POSIX 1003.1g mandates this order.
^1da177e4c3f41 Linus Torvalds       2005-04-16  2307  			 */
^1da177e4c3f41 Linus Torvalds       2005-04-16  2308  
6eba6a372b501a Eric Dumazet         2008-11-16  2309  			err = sock_error(sk);
6eba6a372b501a Eric Dumazet         2008-11-16  2310  			if (err)
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2311  				goto unlock;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2312  			if (sk->sk_shutdown & RCV_SHUTDOWN)
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2313  				goto unlock;
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2314  
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2315  			unix_state_unlock(sk);
1b92ee3d03af66 Rainer Weikusat      2016-02-08  2316  			if (!timeo) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2317  				err = -EAGAIN;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2318  				break;
1b92ee3d03af66 Rainer Weikusat      2016-02-08  2319  			}
1b92ee3d03af66 Rainer Weikusat      2016-02-08  2320  
6e1ce3c3451291 Linus Torvalds       2016-09-01  2321  			mutex_unlock(&u->iolock);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2322  
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2323  			timeo = unix_stream_data_wait(sk, timeo, last,
06a77b07e3b44a WANG Cong            2016-11-17  2324  						      last_len, freezable);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2325  
3822b5c2fc62e3 Rainer Weikusat      2015-12-16  2326  			if (signal_pending(current)) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2327  				err = sock_intr_errno(timeo);
fa0dc04df259ba Eric Dumazet         2016-01-24  2328  				scm_destroy(&scm);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2329  				goto out;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2330  			}
b3ca9b02b00704 Rainer Weikusat      2011-02-28  2331  
6e1ce3c3451291 Linus Torvalds       2016-09-01  2332  			mutex_lock(&u->iolock);
18eceb818dc37b Rainer Weikusat      2016-02-18  2333  			goto redo;
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2334  unlock:
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2335  			unix_state_unlock(sk);
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2336  			break;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2337  		}
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2338  
e370a723632177 Eric Dumazet         2013-08-08  2339  		while (skip >= unix_skb_len(skb)) {
e370a723632177 Eric Dumazet         2013-08-08  2340  			skip -= unix_skb_len(skb);
79f632c71bea0d Benjamin Poirier     2013-04-29  2341  			last = skb;
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2342  			last_len = skb->len;
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2343  			skb = skb_peek_next(skb, &sk->sk_receive_queue);
79f632c71bea0d Benjamin Poirier     2013-04-29  2344  			if (!skb)
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2345  				goto again;
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2346  		}
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2347  
3c0d2f3780fc94 Miklos Szeredi       2007-06-05  2348  		unix_state_unlock(sk);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2349  
^1da177e4c3f41 Linus Torvalds       2005-04-16  2350  		if (check_creds) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2351  			/* Never glue messages from different writers */
9490f886b19296 Hannes Frederic Sowa 2015-11-26  2352  			if (!unix_skb_scm_eq(skb, &scm))
^1da177e4c3f41 Linus Torvalds       2005-04-16  2353  				break;
0e82e7f6dfeec1 Eric W. Biederman    2013-04-03  2354  		} else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2355  			/* Copy credentials */
7cc05662682da4 Christoph Hellwig    2015-01-28  2356  			scm_set_cred(&scm, UNIXCB(skb).pid, UNIXCB(skb).uid, UNIXCB(skb).gid);
37a9a8df8ce9de Stephen Smalley      2015-06-10  2357  			unix_set_secdata(&scm, skb);
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2358  			check_creds = true;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2359  		}
^1da177e4c3f41 Linus Torvalds       2005-04-16  2360  
^1da177e4c3f41 Linus Torvalds       2005-04-16  2361  		/* Copy address just once */
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2362  		if (state->msg && state->msg->msg_name) {
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2363  			DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr,
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2364  					 state->msg->msg_name);
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2365  			unix_copy_addr(state->msg, skb->sk);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2366  			sunaddr = NULL;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2367  		}
^1da177e4c3f41 Linus Torvalds       2005-04-16  2368  
e370a723632177 Eric Dumazet         2013-08-08  2369  		chunk = min_t(unsigned int, unix_skb_len(skb) - skip, size);
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2370  		skb_get(skb);
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2371  		chunk = state->recv_actor(skb, skip, chunk, state);
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2372  		drop_skb = !unix_skb_len(skb);
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2373  		/* skb is only safe to use if !drop_skb */
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2374  		consume_skb(skb);
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2375  		if (chunk < 0) {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2376  			if (copied == 0)
^1da177e4c3f41 Linus Torvalds       2005-04-16  2377  				copied = -EFAULT;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2378  			break;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2379  		}
^1da177e4c3f41 Linus Torvalds       2005-04-16  2380  		copied += chunk;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2381  		size -= chunk;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2382  
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2383  		if (drop_skb) {
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2384  			/* the skb was touched by a concurrent reader;
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2385  			 * we should not expect anything from this skb
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2386  			 * anymore and assume it invalid - we can be
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2387  			 * sure it was dropped from the socket queue
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2388  			 *
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2389  			 * let's report a short read
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2390  			 */
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2391  			err = 0;
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2392  			break;
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2393  		}
73ed5d25dce035 Hannes Frederic Sowa 2015-11-10  2394  
^1da177e4c3f41 Linus Torvalds       2005-04-16  2395  		/* Mark read part of skb as used */
6eba6a372b501a Eric Dumazet         2008-11-16  2396  		if (!(flags & MSG_PEEK)) {
e370a723632177 Eric Dumazet         2013-08-08  2397  			UNIXCB(skb).consumed += chunk;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2398  
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2399  			sk_peek_offset_bwd(sk, chunk);
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2400  
3c32da19a858fb Kirill Tkhai         2019-12-09  2401  			if (UNIXCB(skb).fp) {
3c32da19a858fb Kirill Tkhai         2019-12-09 @2402  				scm_stat_del(sk, skb);
7cc05662682da4 Christoph Hellwig    2015-01-28  2403  				unix_detach_fds(&scm, skb);
3c32da19a858fb Kirill Tkhai         2019-12-09  2404  			}
^1da177e4c3f41 Linus Torvalds       2005-04-16  2405  
e370a723632177 Eric Dumazet         2013-08-08  2406  			if (unix_skb_len(skb))
^1da177e4c3f41 Linus Torvalds       2005-04-16  2407  				break;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2408  
6f01fd6e6f6809 Eric Dumazet         2012-01-28  2409  			skb_unlink(skb, &sk->sk_receive_queue);
70d4bf6d467a33 Neil Horman          2010-07-20  2410  			consume_skb(skb);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2411  
7cc05662682da4 Christoph Hellwig    2015-01-28  2412  			if (scm.fp)
^1da177e4c3f41 Linus Torvalds       2005-04-16  2413  				break;
6eba6a372b501a Eric Dumazet         2008-11-16  2414  		} else {
^1da177e4c3f41 Linus Torvalds       2005-04-16  2415  			/* It is questionable, see note in unix_dgram_recvmsg.
^1da177e4c3f41 Linus Torvalds       2005-04-16  2416  			 */
^1da177e4c3f41 Linus Torvalds       2005-04-16  2417  			if (UNIXCB(skb).fp)
7cc05662682da4 Christoph Hellwig    2015-01-28  2418  				scm.fp = scm_fp_dup(UNIXCB(skb).fp);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2419  
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2420  			sk_peek_offset_fwd(sk, chunk);
fc0d753641f7b9 Pavel Emelyanov      2012-02-21  2421  
9f389e35674f5b Aaron Conole         2015-09-26  2422  			if (UNIXCB(skb).fp)
9f389e35674f5b Aaron Conole         2015-09-26  2423  				break;
9f389e35674f5b Aaron Conole         2015-09-26  2424  
e9193d60d363e4 Andrey Vagin         2015-10-02  2425  			skip = 0;
9f389e35674f5b Aaron Conole         2015-09-26  2426  			last = skb;
9f389e35674f5b Aaron Conole         2015-09-26 @2427  			last_len = skb->len;
9f389e35674f5b Aaron Conole         2015-09-26  2428  			unix_state_lock(sk);
9f389e35674f5b Aaron Conole         2015-09-26  2429  			skb = skb_peek_next(skb, &sk->sk_receive_queue);
9f389e35674f5b Aaron Conole         2015-09-26  2430  			if (skb)
9f389e35674f5b Aaron Conole         2015-09-26  2431  				goto again;
9f389e35674f5b Aaron Conole         2015-09-26  2432  			unix_state_unlock(sk);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2433  			break;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2434  		}
^1da177e4c3f41 Linus Torvalds       2005-04-16  2435  	} while (size);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2436  
6e1ce3c3451291 Linus Torvalds       2016-09-01  2437  	mutex_unlock(&u->iolock);
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2438  	if (state->msg)
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2439  		scm_recv(sock, state->msg, &scm, flags);
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2440  	else
2b514574f7e88c Hannes Frederic Sowa 2015-05-21  2441  		scm_destroy(&scm);
^1da177e4c3f41 Linus Torvalds       2005-04-16  2442  out:
^1da177e4c3f41 Linus Torvalds       2005-04-16  2443  	return copied ? : err;
^1da177e4c3f41 Linus Torvalds       2005-04-16  2444  }
^1da177e4c3f41 Linus Torvalds       2005-04-16  2445  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

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

end of thread, other threads:[~2020-08-24 23:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 22:23 [PATCH] net: Get rid of consume_skb when tracing is off Herbert Xu
2020-08-21 23:40 ` Eric Dumazet
2020-08-22  1:08   ` Herbert Xu
2020-08-22 17:54 ` Neil Horman
2020-08-22 19:49   ` David Miller
2020-08-24 12:17     ` Neil Horman
2020-08-22 22:47   ` Herbert Xu
2020-08-24 23:12 ` David Miller
2020-08-22  2:57 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.