Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3111548pxb; Tue, 20 Apr 2021 00:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzaMdwB7N6pmbMo6AK7zIufI6dq2o5EG9WPZD2f9gBqNsGG+hBgddnvqvY7zEa18EECJF9 X-Received: by 2002:a17:906:98d6:: with SMTP id zd22mr21783787ejb.17.1618903374502; Tue, 20 Apr 2021 00:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618903374; cv=none; d=google.com; s=arc-20160816; b=m3fRXWJ62VZ3Ou46bIepGc/QrS0CRUS3XTI+drohVu3ZN0SsyXpl8n7zOur9BkG+f2 2NDwxSN2kalQTZcA+t4uQ+QXleWIAD7NGLPp70oANbDBOX5IJkYIsIZcE5OZv4UJ5k6t h1NrSSUsbEZSftzg0DtQbK6yl3Pi03IswupQKoAcy1eZrCL3qjnp4uFmf2GP82OhEd9g ZL/tdEQ5GZW6l1v3aWwt8JQwesJXWJJcDhJN8So2cXQOTnaoWNk3zWZsmNUhV3zjtDwU EHKSoy4koUaLDfdu2kke+Hlq9RepSkM6FhDrjFhuznKpmYgwaL4PFVhkQcICVQTbeXX3 qslA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Fdo4mE/+cjJuC72UnytwwUxZcVyYzOvI58iBPYYyS4o=; b=0X+nAI5AqtvTJdHsCKwMytyw+vZNrTPXFzEOampjLnTU0tHHJ2swLlf/4qe3a9hmg+ 6yETtz//k2PPj5OelzsdcbuvRdvESvU83tYMEDOqprFgOzWvebXHPweZnRzcOVnWM3ce 6WehM6a0/QQBjAYUHVYspcU4G+ss4NCAW+Q2327LffuU4HrKr4MHBH2lvxJOtEDHaw5u jTaJKdk/u4PZhlsG+I1sVYfgCnIlTOwZ/ikEyxYQibbF0VtAWIB6Huxhjv9SC2bUKL1x x0fFuA0CjVj2K4fLIMvKfmwKiLTA2TiEESZVgCuyvteKkuFg0XUJQF2ZBSvSUvRJyNGZ xbpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=JDcuGmSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si9434413edx.594.2021.04.20.00.22.31; Tue, 20 Apr 2021 00:22:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=JDcuGmSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230302AbhDTHWF (ORCPT + 99 others); Tue, 20 Apr 2021 03:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbhDTHV5 (ORCPT ); Tue, 20 Apr 2021 03:21:57 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BAC5C061763 for ; Tue, 20 Apr 2021 00:21:25 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id sd23so48053325ejb.12 for ; Tue, 20 Apr 2021 00:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Fdo4mE/+cjJuC72UnytwwUxZcVyYzOvI58iBPYYyS4o=; b=JDcuGmSnwgEFOWi0Hol09StsvZpHTO8W+O/Gz5MCGTk1hrnPT23hDPfAyBVwJSNZpt czBoQS5EsqxfrGVAbix+Te7AGsP7UXhIx8YFBmygfQto+b48SP2efSg7JWmJOpyukexr FTsu8EMSbjXVSgncFtnRCeoktgRoY0XVLaFrk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Fdo4mE/+cjJuC72UnytwwUxZcVyYzOvI58iBPYYyS4o=; b=T98CAdmTMWqOwioSYgn62GFuRL/bZeaaMr/gSmzKuqRPREi7QeMRx+jH1JoKr4cBvn 3l+rHbVCGbBJjdOa464+v6bLyxg6Jpr/hzdNG8b13yG7L0rLX++tmOo58Jqamn5TXKVR ev+Y5KnrT9Wi0gMLvCPcfuF+aXw0z2CmGt7GOn96IQvsZXuR8YrUUQe0h+4HXRC10hlq YVK5IOYdHSBjdwVKIWAD1/TMKoDuh9ngJ89WKVrBUbKxXZsn7m6g6LkpvRUITEN7AGB/ IEbn1gf3f97H94CSMd/5t+NvKcry7vNdYPmvGj/Luum4bFdwwRqLPE+nWP2dCQqMS05h tcSA== X-Gm-Message-State: AOAM530W9yAyucGz+qVq+oKD/UiSP9L3VU8Mwp9Xi5syZBvVuc2BOEio D5zboeVojo58lVijjPu4bXCePg== X-Received: by 2002:a17:906:4d10:: with SMTP id r16mr25604487eju.169.1618903284093; Tue, 20 Apr 2021 00:21:24 -0700 (PDT) Received: from [192.168.1.149] ([80.208.71.248]) by smtp.gmail.com with ESMTPSA id p3sm11836507ejd.65.2021.04.20.00.21.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Apr 2021 00:21:23 -0700 (PDT) Subject: Re: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems To: "Matthew Wilcox (Oracle)" , brouer@redhat.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, ilias.apalodimas@linaro.org, mcroce@linux.microsoft.com, grygorii.strashko@ti.com, arnd@kernel.org, hch@lst.de, linux-snps-arc@lists.infradead.org, mhocko@kernel.org, mgorman@suse.de References: <20210416230724.2519198-1-willy@infradead.org> <20210416230724.2519198-2-willy@infradead.org> From: Rasmus Villemoes Message-ID: Date: Tue, 20 Apr 2021 09:21:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210416230724.2519198-2-willy@infradead.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/04/2021 01.07, Matthew Wilcox (Oracle) wrote: > 32-bit architectures which expect 8-byte alignment for 8-byte integers > and need 64-bit DMA addresses (arc, arm, mips, ppc) had their struct > page inadvertently expanded in 2019. When the dma_addr_t was added, > it forced the alignment of the union to 8 bytes, which inserted a 4 byte > gap between 'flags' and the union. > > Fix this by storing the dma_addr_t in one or two adjacent unsigned longs. > This restores the alignment to that of an unsigned long, and also fixes a > potential problem where (on a big endian platform), the bit used to denote > PageTail could inadvertently get set, and a racing get_user_pages_fast() > could dereference a bogus compound_head(). > > Fixes: c25fff7171be ("mm: add dma_addr_t to struct page") > Signed-off-by: Matthew Wilcox (Oracle) > --- > include/linux/mm_types.h | 4 ++-- > include/net/page_pool.h | 12 +++++++++++- > net/core/page_pool.c | 12 +++++++----- > 3 files changed, 20 insertions(+), 8 deletions(-) > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 6613b26a8894..5aacc1c10a45 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -97,10 +97,10 @@ struct page { > }; > struct { /* page_pool used by netstack */ > /** > - * @dma_addr: might require a 64-bit value even on > + * @dma_addr: might require a 64-bit value on > * 32-bit architectures. > */ > - dma_addr_t dma_addr; > + unsigned long dma_addr[2]; Shouldn't that member get another name (_dma_addr?) to be sure the buildbots catch every possible (ab)user and get them turned into the new accessors? Sure, page->dma_addr is now "pointer to unsigned long" instead of "dma_addr_t", but who knows if there's a "(long)page->dma_addr" somewhere? Rasmus