All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/2] RDS: memory allocated must be align to 8
@ 2016-04-07 11:57 Shamir Rabinovitch
  2016-04-07 11:57 ` [PATCH v4 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 4k Shamir Rabinovitch
  2016-04-08 19:44 ` [PATCH v4 1/2] RDS: memory allocated must be align to 8 santosh shilimkar
  0 siblings, 2 replies; 6+ messages in thread
From: Shamir Rabinovitch @ 2016-04-07 11:57 UTC (permalink / raw)
  To: rds-devel, netdev; +Cc: davem, shamir.rabinovitch, santosh.shilimkar

Fix issue in 'rds_ib_cong_recv' when accessing unaligned memory
allocated by 'rds_page_remainder_alloc' using uint64_t pointer.

Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
---
 net/rds/page.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/rds/page.c b/net/rds/page.c
index 616f21f..e2b5a58 100644
--- a/net/rds/page.c
+++ b/net/rds/page.c
@@ -135,8 +135,8 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
 			if (rem->r_offset != 0)
 				rds_stats_inc(s_page_remainder_hit);
 
-			rem->r_offset += bytes;
-			if (rem->r_offset == PAGE_SIZE) {
+			rem->r_offset += ALIGN(bytes, 8);
+			if (rem->r_offset >= PAGE_SIZE) {
 				__free_page(rem->r_page);
 				rem->r_page = NULL;
 			}
-- 
1.7.1

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

* [PATCH v4 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 4k
  2016-04-07 11:57 [PATCH v4 1/2] RDS: memory allocated must be align to 8 Shamir Rabinovitch
@ 2016-04-07 11:57 ` Shamir Rabinovitch
  2016-04-08 19:39   ` santosh shilimkar
  2016-04-08 19:44 ` [PATCH v4 1/2] RDS: memory allocated must be align to 8 santosh shilimkar
  1 sibling, 1 reply; 6+ messages in thread
From: Shamir Rabinovitch @ 2016-04-07 11:57 UTC (permalink / raw)
  To: rds-devel, netdev; +Cc: davem, shamir.rabinovitch, santosh.shilimkar

When PAGE_SIZE > 4k single page can contain 2 RDS fragments. If
'rds_ib_cong_recv' ignore the RDS fragment offset in to the page it
then read the data fragment as far congestion map update and lead to
corruption of the RDS connection far congestion map.

Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
---
 net/rds/ib_recv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 977fb86..abc8cc8 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -796,7 +796,7 @@ static void rds_ib_cong_recv(struct rds_connection *conn,
 
 		addr = kmap_atomic(sg_page(&frag->f_sg));
 
-		src = addr + frag_off;
+		src = addr + frag->f_sg.offset + frag_off;
 		dst = (void *)map->m_page_addrs[map_page] + map_off;
 		for (k = 0; k < to_copy; k += 8) {
 			/* Record ports that became uncongested, ie
-- 
1.7.1

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

* Re: [PATCH v4 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 4k
  2016-04-07 11:57 ` [PATCH v4 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 4k Shamir Rabinovitch
@ 2016-04-08 19:39   ` santosh shilimkar
  0 siblings, 0 replies; 6+ messages in thread
From: santosh shilimkar @ 2016-04-08 19:39 UTC (permalink / raw)
  To: Shamir Rabinovitch, rds-devel, netdev; +Cc: davem

On 4/7/2016 4:57 AM, Shamir Rabinovitch wrote:
> When PAGE_SIZE > 4k single page can contain 2 RDS fragments. If
> 'rds_ib_cong_recv' ignore the RDS fragment offset in to the page it
> then read the data fragment as far congestion map update and lead to
> corruption of the RDS connection far congestion map.
>
> Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

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

* Re: [PATCH v4 1/2] RDS: memory allocated must be align to 8
  2016-04-07 11:57 [PATCH v4 1/2] RDS: memory allocated must be align to 8 Shamir Rabinovitch
  2016-04-07 11:57 ` [PATCH v4 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 4k Shamir Rabinovitch
@ 2016-04-08 19:44 ` santosh shilimkar
  2016-04-08 20:10   ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: santosh shilimkar @ 2016-04-08 19:44 UTC (permalink / raw)
  To: Shamir Rabinovitch, rds-devel, netdev; +Cc: davem

On 4/7/2016 4:57 AM, Shamir Rabinovitch wrote:
> Fix issue in 'rds_ib_cong_recv' when accessing unaligned memory
> allocated by 'rds_page_remainder_alloc' using uint64_t pointer.
>
Sorry I still didn't follow this change still. What exactly is the
problem.

> Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
> ---
>   net/rds/page.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/rds/page.c b/net/rds/page.c
> index 616f21f..e2b5a58 100644
> --- a/net/rds/page.c
> +++ b/net/rds/page.c
> @@ -135,8 +135,8 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
>   			if (rem->r_offset != 0)
>   				rds_stats_inc(s_page_remainder_hit);
>
> -			rem->r_offset += bytes;
> -			if (rem->r_offset == PAGE_SIZE) {
> +			rem->r_offset += ALIGN(bytes, 8);
> +			if (rem->r_offset >= PAGE_SIZE) {
>   				__free_page(rem->r_page);
>   				rem->r_page = NULL;
>   			}
>

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

* Re: [PATCH v4 1/2] RDS: memory allocated must be align to 8
  2016-04-08 19:44 ` [PATCH v4 1/2] RDS: memory allocated must be align to 8 santosh shilimkar
@ 2016-04-08 20:10   ` David Miller
  2016-04-08 20:55     ` santosh shilimkar
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2016-04-08 20:10 UTC (permalink / raw)
  To: santosh.shilimkar; +Cc: shamir.rabinovitch, rds-devel, netdev

From: santosh shilimkar <santosh.shilimkar@oracle.com>
Date: Fri, 8 Apr 2016 12:44:39 -0700

> On 4/7/2016 4:57 AM, Shamir Rabinovitch wrote:
>> Fix issue in 'rds_ib_cong_recv' when accessing unaligned memory
>> allocated by 'rds_page_remainder_alloc' using uint64_t pointer.
>>
> Sorry I still didn't follow this change still. What exactly is the
> problem.

You can't stop the offset at non-8byte intervals, because the chunks
being used in these arenas can have 64-bit values in it, which must be
8-byte aligned.

It looks extremely obvious to me.

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

* Re: [PATCH v4 1/2] RDS: memory allocated must be align to 8
  2016-04-08 20:10   ` David Miller
@ 2016-04-08 20:55     ` santosh shilimkar
  0 siblings, 0 replies; 6+ messages in thread
From: santosh shilimkar @ 2016-04-08 20:55 UTC (permalink / raw)
  To: David Miller; +Cc: shamir.rabinovitch, rds-devel, netdev

On 4/8/2016 1:10 PM, David Miller wrote:
> From: santosh shilimkar <santosh.shilimkar@oracle.com>
> Date: Fri, 8 Apr 2016 12:44:39 -0700
>
>> On 4/7/2016 4:57 AM, Shamir Rabinovitch wrote:
>>> Fix issue in 'rds_ib_cong_recv' when accessing unaligned memory
>>> allocated by 'rds_page_remainder_alloc' using uint64_t pointer.
>>>
>> Sorry I still didn't follow this change still. What exactly is the
>> problem.
>
> You can't stop the offset at non-8byte intervals, because the chunks
> being used in these arenas can have 64-bit values in it, which must be
> 8-byte aligned.
>
I see. Thanks for explaining it Dave.
Its fine to apply then.
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

Regards,
Santosh

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 11:57 [PATCH v4 1/2] RDS: memory allocated must be align to 8 Shamir Rabinovitch
2016-04-07 11:57 ` [PATCH v4 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 4k Shamir Rabinovitch
2016-04-08 19:39   ` santosh shilimkar
2016-04-08 19:44 ` [PATCH v4 1/2] RDS: memory allocated must be align to 8 santosh shilimkar
2016-04-08 20:10   ` David Miller
2016-04-08 20:55     ` santosh shilimkar

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.