From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34C01C433EF for ; Tue, 10 May 2022 20:20:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D22D6B0072; Tue, 10 May 2022 16:20:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 580746B0073; Tue, 10 May 2022 16:20:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 404576B0074; Tue, 10 May 2022 16:20:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2C8876B0072 for ; Tue, 10 May 2022 16:20:51 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 053CF3166E for ; Tue, 10 May 2022 20:20:50 +0000 (UTC) X-FDA: 79450951902.02.A84D258 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf30.hostedemail.com (Postfix) with ESMTP id CED71800A8 for ; Tue, 10 May 2022 20:20:32 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id m12so4021143plb.4 for ; Tue, 10 May 2022 13:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VPY+BPFQANz3gDy7cqE3RCNN6lWRUXJ8ern2JoTstfU=; b=jXJ6JFzMblllvK795NI3FvQqpQcwPkVl0bVhyMK3o6LmyhiyVnc9pM+SKsWNtbwkrb vXm0gGlSLp7eTZ8a3YevY+oHmXKB8W/ilZrxw5RUlRCGLC2N3HG9SVP/c97aedgjRwhp wWaIxviwceQPsCLv0sWmrBE0Tj9PqDc3LgbWs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VPY+BPFQANz3gDy7cqE3RCNN6lWRUXJ8ern2JoTstfU=; b=eiFnkO96ocHl4r0RdBgTiujdW4RbG6KcHVp0KNWClBivfTk4iBnY/+eS3FuNGNreVi bZo31Qg/YeSqjnYiQheMhHztttfdlIad7mkA0uJVCxjZ2SXdsVs6udn0uA9jWEgxJKM6 PIHsPJZHDOtSBjzsZKZbwBbAAt0ukVf9cWP/gweuyLqPUh8Iqz8tZaUbxokkNevIJePz uDwEQt78TOlYAz3fUOBSM8MfCF+tt3sdWQJuGtM6zDPoS+8ieU83nSfs1FI+masycIeH Od3REUzI99UbFRbce9C7Rydvsrv2MiurYskni/DEbUXnqV2pwZ3Ll1Xb9Wu01PjblljF cSHw== X-Gm-Message-State: AOAM533akm+NWSUszoIm/cbQ+7I5rxDrQNidkcBd8qPjQuJ/5olAqSPq fGlSCw/GNT5pnuUbIwMVXHDffw== X-Google-Smtp-Source: ABdhPJxDdK9krQAGRnUj2ALxtk0356084bzaUSCApoi5YQd/8+Z41ynrHVmWGvv4Q3NHHnQBRhfzLA== X-Received: by 2002:a17:90b:4b01:b0:1dc:7405:dd62 with SMTP id lx1-20020a17090b4b0100b001dc7405dd62mr1604206pjb.160.1652214049398; Tue, 10 May 2022 13:20:49 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y11-20020a17090a644b00b001d95cdb62d4sm2256217pjm.33.2022.05.10.13.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:20:48 -0700 (PDT) Date: Tue, 10 May 2022 13:20:48 -0700 From: Kees Cook To: Matthew Wilcox Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Du Cheng , Christophe JAILLET , Vlastimil Babka , William Kucharski , Arnd Bergmann , Nathan Chancellor , netdev@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] niu: Add "overloaded" struct page union member Message-ID: <202205101318.4980180F9@keescook> References: <20220509222334.3544344-1-keescook@chromium.org> <202205100849.58D2C81@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: CED71800A8 X-Stat-Signature: ketpp4tjn3uycgyrsjs1bnrjrh6mujad Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=jXJ6JFzM; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf30.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.176 as permitted sender) smtp.mailfrom=keescook@chromium.org X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652214032-492752 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, May 10, 2022 at 06:27:41PM +0100, Matthew Wilcox wrote: > On Tue, May 10, 2022 at 08:50:47AM -0700, Kees Cook wrote: > > On Tue, May 10, 2022 at 12:27:53AM -0700, Christoph Hellwig wrote: > > > On Mon, May 09, 2022 at 03:23:33PM -0700, Kees Cook wrote: > > > > The randstruct GCC plugin gets upset when it sees struct addresspace > > > > (which is randomized) being assigned to a struct page (which is not > > > > randomized): > > > > > > Well, the right fix here is to remove this abuse from the driver, not > > > to legitimize it as part of a "driver" patch touching a core mm header > > > > Right, I didn't expect anyone to like the new "overloaded" member. > > Mainly I'd just like to understand how niu _should_ be fixed. Is using > > the "private" member the correct thing here? > > Well ... no. We're not entirely set up yet to go to the good answer > that means we don't have to touch this driver again, and yet we're also > in a situation where we'll need to touch this driver at some point in > order to get rid of the way it abuses struct page before we can get to > our good place. > > The eventual good answer is that we declare a driver-private memdesc > variant that has a ->link, ->base ->refcount and ->pfn (maybe it has more > than that; I'd have to really understand this driver to be completely > certain about what it needs). Or perhaps there's a better way to handle > driver-allocated memory for this kind of networking card that this driver > should be converted to use. > > I haven't looked into this case deeply enough to have strong thoughts > about how we should handle it, both now and in the glorious future. Okay, in the meantime, I'll just add a casting wrapper with a big comment to explain what I understand about it with some pointers back to this and prior threads. :) Thanks! -- Kees Cook