linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg-uk2M96/98Pc@public.gmane.org>
To: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [rdma-next, 06/31] IB/ipoib: Avoid memory leak if neigh destination was changed
Date: Mon, 18 Dec 2017 15:40:48 -0700	[thread overview]
Message-ID: <20171218224048.GA28327@ziepe.ca> (raw)
In-Reply-To: <20171114125218.20477-7-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

On Tue, Nov 14, 2017 at 02:51:53PM +0200, Leon Romanovsky wrote:
> From: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> 
> If from some reason the SM responses to path query request with response
> that doesn't contain the exact SGID, ipoib should warn and change that
> part of the response before push it to the path record DB.
> Otherwise, new record will be added to the path record DB with no access
> to them from the ipoib.
> 
> Demonstration of the bug is as the follow:
> ipoib wants to send to GID fe80:0000:0000:0000:0002:c903:00ef:5ee2, it
> creates new record in the DB with that gid as a key, and issues a new
> request to the sm.
> Now, the SM from some reason returns path-record with other SGID (for
> example, fe80:0000:0000:0001:0002:c903:00ef:5ee2 that contains the local
> subnet prefix) now ipoib will overwrite the current entry with the new
> one, and if new request to the original GID arrives ipoib  will not find
> it in the DB (was overwritten) and will create new record that in its
> turn will also be overwritten by the response from the SM, and so on
> till the driver eats all the device memory.
> 
> Signed-off-by: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>  drivers/infiniband/ulp/ipoib/ipoib_main.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 12b7f911f0e5..b173d618c59c 100644
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> @@ -775,6 +775,16 @@ static void path_rec_completion(int status,
>  	spin_lock_irqsave(&priv->lock, flags);
>  
>  	if (!IS_ERR_OR_NULL(ah)) {
> +		/* check there is no mismatch from the request */
> +		if (memcmp(pathrec->dgid.raw, path->pathrec.dgid.raw,
> +			   sizeof(union ib_gid))) {
> +			pr_warn("%s got PathRec for gid %pI6 while asked for %pI6\n",
> +				dev->name, pathrec->dgid.raw, path->pathrec.dgid.raw);
> +			/* overwrite the response from the sm  before copy to the db */
> +			memcpy(pathrec->dgid.raw, path->pathrec.dgid.raw,
> +			       sizeof(union ib_gid));
> +		}
> +
>  		path->pathrec = *pathrec;

I applied this, but converted the pr_warn to ipoib_dbg (it is not an
error for the SA to change the DGID), reworded the commit message and
comment:

		/*
		 * pathrec.dgid is used as the database key from the LLADDR,
		 * it must remain unchanged even if the SA returns a different
		 * GID to use in the AH.
		 */
		if (memcmp(pathrec->dgid.raw, path->pathrec.dgid.raw,
			   sizeof(union ib_gid))) {
			ipoib_dbg(
				priv,
				"%s got PathRec for gid %pI6 while asked for %pI6\n",
				dev->name, pathrec->dgid.raw,
				path->pathrec.dgid.raw);
			memcpy(pathrec->dgid.raw, path->pathrec.dgid.raw,
			       sizeof(union ib_gid));
		}
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-12-18 22:40 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 12:51 [PATCH rdma-next 00/31] RDMA fixes and refactoring for 4.15 Leon Romanovsky
     [not found] ` <20171114125218.20477-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 12:51   ` [PATCH rdma-next 01/31] IB/core: Fix do not add RoCEv2 default GID when IPv6 is disabled Leon Romanovsky
     [not found]     ` <20171114125218.20477-2-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:25       ` Or Gerlitz
     [not found]         ` <CAJ3xEMgZBzak5V68AV4VFsPgrKOueXcCduHWBJQ-j=1+TBT+iA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 22:17           ` Parav Pandit
2017-11-15  0:18       ` Jason Gunthorpe
     [not found]         ` <20171115001817.GH25894-uk2M96/98Pc@public.gmane.org>
2017-11-15  3:59           ` Parav Pandit
     [not found]             ` <VI1PR0502MB300800ABA04E768A68684608D1290-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-15  4:40               ` Jason Gunthorpe
     [not found]                 ` <20171115044049.GK25894-uk2M96/98Pc@public.gmane.org>
2017-11-17  2:40                   ` Parav Pandit
2017-12-18 20:48       ` [rdma-next, " Jason Gunthorpe
     [not found]         ` <20171218204818.GA18725-uk2M96/98Pc@public.gmane.org>
2017-12-19 13:11           ` Leon Romanovsky
2017-11-14 12:51   ` [PATCH rdma-next 02/31] IB/{core/cm}: Fix dmac query for IPv6 link local destination Leon Romanovsky
     [not found]     ` <20171114125218.20477-3-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-12-18 20:38       ` [rdma-next, " Jason Gunthorpe
2017-11-14 12:51   ` [PATCH rdma-next 03/31] IB/core: Depend on IPv6 stack to resolve link local address Leon Romanovsky
     [not found]     ` <20171114125218.20477-4-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-15  0:32       ` Jason Gunthorpe
     [not found]         ` <20171115003238.GI25894-uk2M96/98Pc@public.gmane.org>
2017-11-15  4:04           ` Parav Pandit
     [not found]             ` <VI1PR0502MB30080133A617972DC6F362F1D1290-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-15  4:41               ` Jason Gunthorpe
     [not found]                 ` <20171115044129.GL25894-uk2M96/98Pc@public.gmane.org>
2017-11-16  2:21                   ` Parav Pandit
2017-11-14 12:51   ` [PATCH rdma-next 04/31] IB/core: Avoid exporting module internal function Leon Romanovsky
2017-11-14 12:51   ` [PATCH rdma-next 05/31] IB/mlx4: Remove unused ibpd parameter Leon Romanovsky
2017-11-14 12:51   ` [PATCH rdma-next 06/31] IB/ipoib: Avoid memory leak if neigh destination was changed Leon Romanovsky
     [not found]     ` <20171114125218.20477-7-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:51       ` Or Gerlitz
     [not found]         ` <CAJ3xEMjPD-MwKHknnYVBzzhSoxCFWE2i9jOCC500yEn5pFXarg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-15  5:11           ` Leon Romanovsky
2017-11-15  0:15       ` Jason Gunthorpe
     [not found]         ` <20171115001510.GG25894-uk2M96/98Pc@public.gmane.org>
2017-11-15  7:01           ` Erez Shitrit
     [not found]             ` <CAAk-MO-QQj3_H2CZuCCOCU51tWwdCfkvhh-Q3LqrKM=Su2Q+Kg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-15 15:39               ` Jason Gunthorpe
     [not found]                 ` <20171115153946.GP25894-uk2M96/98Pc@public.gmane.org>
2017-11-16  8:30                   ` Erez Shitrit
     [not found]                     ` <CAAk-MO-nMs-+RtK_QOxPzq7uCA9hpG30ho52v4CSRPZ6769=1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-16 17:28                       ` Håkon Bugge
     [not found]                         ` <3321F53B-3534-4433-B627-80959DEA1850-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-11-16 18:17                           ` Jason Gunthorpe
2017-11-16 18:13                       ` Jason Gunthorpe
2017-12-18 22:40       ` Jason Gunthorpe [this message]
2017-11-14 12:51   ` [PATCH rdma-next 07/31] IB/ipoib: Update pathrec field if not valid record Leon Romanovsky
2017-11-14 12:51   ` [PATCH rdma-next 08/31] RDMA/cma: Fix consider size of destination address Leon Romanovsky
     [not found]     ` <20171114125218.20477-9-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:18       ` Or Gerlitz
     [not found]         ` <CAJ3xEMiA7G48_boRVJK336n2DNT8voJVJMiT-qhqpfXqz7aNxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-15  5:25           ` Leon Romanovsky
2017-11-14 12:51   ` [PATCH rdma-next 09/31] IB/core: Make sure that PSN does not overflow Leon Romanovsky
     [not found]     ` <20171114125218.20477-10-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:23       ` Or Gerlitz
     [not found]         ` <CAJ3xEMj+QYJs7cTaP7-Z2WGoPZN2ujh+_2sQhW7ZKg0ZGjQacg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 23:44           ` Jason Gunthorpe
2017-12-27 22:44       ` Jason Gunthorpe
2017-11-14 12:51   ` [PATCH rdma-next 10/31] IB/core: Fix memory leak in cm_req_handler error flows Leon Romanovsky
     [not found]     ` <20171114125218.20477-11-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:27       ` Or Gerlitz
2017-11-14 12:51   ` [PATCH rdma-next 11/31] IB/cm: Add debug prints to ib_cm Leon Romanovsky
     [not found]     ` <20171114125218.20477-12-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:10       ` Or Gerlitz
2017-11-14 12:51   ` [PATCH rdma-next 12/31] IB/umem: Fix use of npages/nmap fields Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 13/31] RDMA/cma: Set default GID type as RoCE when resolving RoCE route Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 14/31] RDMA/cma: Simplify netdev check Leon Romanovsky
     [not found]     ` <20171114125218.20477-15-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-19  8:30       ` Knut Omang
     [not found]         ` <1516350659.4593.6.camel-6miFZF/5cTBuMpJDpNschA@public.gmane.org>
2018-01-19 19:38           ` Jason Gunthorpe
2017-11-14 12:52   ` [PATCH rdma-next 15/31] RDMA/cma: Avoid setting path record type twice Leon Romanovsky
     [not found]     ` <20171114125218.20477-16-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-19  8:33       ` Knut Omang
2017-11-14 12:52   ` [PATCH rdma-next 16/31] RDMA/cma: Introduce and use helper functions to init work Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 17/31] IB/core: Avoid unnecessary type cast Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 18/31] IB/core: Refactor to avoid unnecessary check on GID lookup miss Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 19/31] IB/rxe: Avoid passing unused index pointer which is optional Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 20/31] IB/core: Avoid exporting module internal ib_find_gid_by_filter() Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 21/31] RDMA/core: Avoid redundant memcpy in resolving address Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 22/31] IB/core: Removed unused function Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 23/31] RDMA/{core, cma}: Simplify rdma_translate_ip Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 24/31] RDMA/core: Avoid copying ifindex twice Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 25/31] IB/{core, ipoib}: Simplify ib_find_gid to search only for IB link layer Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 26/31] IB/{cm, umad}: Fix honor av init error Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 27/31] IB/cm: Fix honor address handle attribute " Leon Romanovsky
     [not found]     ` <20171114125218.20477-28-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:14       ` Or Gerlitz
     [not found]         ` <CAJ3xEMjPsD7+YnN80A7Z3WjxEey20=TYKpxrRK_mRhKVMEnA8Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 22:13           ` Parav Pandit
     [not found]             ` <VI1PR0502MB3008514AED6DA3E970381088D1280-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-14 22:18               ` Or Gerlitz
     [not found]                 ` <CAJ3xEMg6bJt0obWHrSae86ZUN7RgCYqWJJiQXw9on82P=zO_VA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 22:27                   ` Parav Pandit
     [not found]                     ` <VI1PR0502MB300851A707AFA9DEC77B232ED1280-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-14 23:38                       ` Jason Gunthorpe
     [not found]                         ` <20171114233841.GC25894-uk2M96/98Pc@public.gmane.org>
2017-11-15  5:31                           ` Leon Romanovsky
     [not found]                             ` <20171115053155.GO18825-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-11-15  7:59                               ` Or Gerlitz
     [not found]                                 ` <CAJ3xEMiB6VUp1Kb9HBS5jkqnYN61UP6DYNxqs1T8qGLCUGELcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-15  8:20                                   ` Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 28/31] IB/cm: Fix avoid sleep while spin lock is held Leon Romanovsky
     [not found]     ` <20171114125218.20477-29-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:15       ` Or Gerlitz
     [not found]         ` <CAJ3xEMixWZvCVDYTK1-2w0pYdy65HExvN2ae7y=hAkk6htrETg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 22:16           ` Parav Pandit
     [not found]             ` <VI1PR0502MB3008970D8D6034E4A2D952DED1280-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-14 22:21               ` Or Gerlitz
     [not found]                 ` <CAJ3xEMhdp_2BYPA+s+We5Qgatye8hNLUYGnZu0ZimpPb86U-VQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 22:32                   ` Parav Pandit
     [not found]                     ` <VI1PR0502MB300897A41317A06FFA5CC329D1280-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-15  7:52                       ` Or Gerlitz
     [not found]                         ` <CAJ3xEMiQc_am=rqYg2TyNqU1s9uGSE-wcVxGmW244x8XJNDuyg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-15 23:10                           ` Parav Pandit
     [not found]                             ` <VI1PR0502MB30081717A7E8BEC1B7CFD471D1290-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-16  4:48                               ` Leon Romanovsky
2017-11-16 11:50                               ` Or Gerlitz
     [not found]                                 ` <CAJ3xEMhjV9b5-WVe4QOO41KniK0ogBRukXX1T1bjw-E+Z5QbDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-18  6:29                                   ` Parav Pandit
2017-11-19  8:42       ` Amrani, Ram
     [not found]         ` <BN3PR07MB2578DF2F9081ED97D5A4351EF82D0-EldUQEzkDQfpW3VS/XPqkOFPX92sqiQdvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-11-19 10:52           ` Leon Romanovsky
     [not found]             ` <20171119105211.GW18825-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-11-19 11:06               ` Or Gerlitz
     [not found]                 ` <CAJ3xEMgjE-MyeBSem=35Bn+JM401z3q7HOTb_eiXyAJuS=X=NA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-19 11:48                   ` Amrani, Ram
2017-11-14 12:52   ` [PATCH rdma-next 29/31] IB/{core, cm, cma, ipoib}: Rename ib_init_ah_from_path to ib_init_ah_attr_from_path Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 30/31] IB/{core, umad, cm}: Rename ib_init_ah_from_wc to ib_init_ah_attr_from_wc Leon Romanovsky
2017-11-14 12:52   ` [PATCH rdma-next 31/31] IB/cm: Refactor to avoid setting path record software only fields Leon Romanovsky
     [not found]     ` <20171114125218.20477-32-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-14 21:13       ` Or Gerlitz
     [not found]         ` <CAJ3xEMhyZQM5dp2VKoiVDz3Q524d_kO=a0PUMJt_xmQK-nkPsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 22:11           ` Parav Pandit
     [not found]             ` <VI1PR0502MB3008CEF7DF9257A4D6AFBD1FD1280-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-15  7:56               ` Or Gerlitz
2017-12-18 23:11   ` [PATCH rdma-next 00/31] RDMA fixes and refactoring for 4.15 Jason Gunthorpe
     [not found]     ` <20171218231120.GH19056-uk2M96/98Pc@public.gmane.org>
2017-12-19 13:35       ` Leon Romanovsky
2017-12-26 18:49       ` Leon Romanovsky
     [not found]         ` <20171226184914.GF10734-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-12-26 19:49           ` Jason Gunthorpe
     [not found]             ` <20171226194926.GH30884-uk2M96/98Pc@public.gmane.org>
2017-12-27  4:58               ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171218224048.GA28327@ziepe.ca \
    --to=jgg-uk2m96/98pc@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).