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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A765C48BF6 for ; Thu, 29 Feb 2024 19:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j85siCiYyrvwyhJTyYYPQZo9wX1NwFbckulX5lBtJ+Q=; b=mDIq1toxMqovZB uciXqe6PAKmOpu25ambc+r7JiOtE/DDlWzpbmpOhO1QyOcldJZIyB8N24pHdrjOjRDvsg0Xlcsr8Z Ng7QTQ6L4rf1ICILSAnNdj9U2SV4Ae5n0eLJFd3kGEggccx+sGWtORzhaO/fBnsVrjMxwLE1vC3H8 Fy7HUTzaNeJORKjFIZ+PuETbpLkpLXTZCxienj6hsC8wxmshrmFsRbCN5/z9NNTNNY5D8ywxZKx0q tEdcUz3KJvoULNesykHUg3n2791l7dVr00NEvpvxrg+5U7uNSTgyjQD8/7gbKeNM7b6VFPcTCwLkH FZplgYOUCLSdb3tfQhiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rflmE-0000000Ep6P-2B0d; Thu, 29 Feb 2024 19:09:06 +0000 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rflmB-0000000Ep53-2Uqv for linux-arm-kernel@lists.infradead.org; Thu, 29 Feb 2024 19:09:04 +0000 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6e48153c13aso667853a34.3 for ; Thu, 29 Feb 2024 11:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709233739; x=1709838539; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=UPNx03vL5gJBUsLY5izQNSc5f5aQFQJTo3mFc1Gcb0A=; b=W2rl9DhX2BfirRZQbbq6NVl1Ra0BSkmu6Y+6jCK7t/3g3/Fij0qzR7sDQ3vZHYtszl E1EPF7xdDGxq7u5ujVj+aC/u2nLk4oDh20Vf+qlOBnvJIl9tUrX+Xs+NHz3qC8GXDe4/ XVs2xLnPeUGv36PYyxCoBliLEsy7boLBLhwhE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709233739; x=1709838539; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UPNx03vL5gJBUsLY5izQNSc5f5aQFQJTo3mFc1Gcb0A=; b=fD6u6DSGNgtQmIheqJoCH7UdTgvZzgTWBWWpkO9hTxiEeJBJwtNt4cD7/wYUw60Or1 +9KNytalXziuhMumug0xZsdyntc5pHc2vEDZSOl1c1GVcpTdQr/dZ7DqLDrVsTVZzE5z bv0m4yMmOyrh56HocRmyWycDZOERTNnP1rc1AM857uX/ErcOt6roaYwBgzdzFGIzo5OY +VIg2QIeq6qdN+7jgOKmW708hvnd2VJYYoitXBJiSZ1ZHfaJu6RGi4/Fudc1NJhRHiEv UmYbsAPxMe9h/VdIMU73jk58rIaYGeBa3Mcia+If+8rAYyv6F1x/fz/vA0R/W2diqYxW RxVQ== X-Forwarded-Encrypted: i=1; AJvYcCXGECpFdIOmOtVB6DrjgW9igncWynufWLjyvsU1A9S7295UpGRWkZvKfn9myB/LTs/E93cHxx0dscXNGIh3GJEwUtwJMMFpSGrEacqYN6+0uQjkys4= X-Gm-Message-State: AOJu0YxmEImxcSclYpDiq6zSWk9w3ejz+FSJKViAd1yQCXsVDprfB58e 0du0yqtU3LSU9gd/Z7b9KGx719FMeRiTW6XEQ9YjtTXTW5YJthq4zRDWVgjYjg== X-Google-Smtp-Source: AGHT+IHgyC7clemZIshyNx4SoJ7Udvxw9GwegtcRM1FBJfrzoLTLgcJeKmWLE72ksvmhiwetvndvRw== X-Received: by 2002:a9d:618c:0:b0:6e4:9e38:37a7 with SMTP id g12-20020a9d618c000000b006e49e3837a7mr2725366otk.23.1709233739242; Thu, 29 Feb 2024 11:08:59 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id c4-20020aa78804000000b006e05c801748sm1613455pfo.199.2024.02.29.11.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 11:08:58 -0800 (PST) Date: Thu, 29 Feb 2024 11:08:58 -0800 From: Kees Cook To: Jakub Kicinski Cc: Andy Shevchenko , Vinod Koul , Linus Walleij , Jonathan Cameron , Mark Brown , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-spi@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen , "David S. Miller" , Eric Dumazet , Paolo Abeni , "Gustavo A. R. Silva" Subject: Re: [PATCH v4 7/8] net-device: Use new helpers from overflow.h in netdevice APIs Message-ID: <202402291059.491B5E03@keescook> References: <20240228204919.3680786-1-andriy.shevchenko@linux.intel.com> <20240228204919.3680786-8-andriy.shevchenko@linux.intel.com> <202402281341.AC67EB6E35@keescook> <20240228144148.5c227487@kernel.org> <202402281554.C1CEEF744@keescook> <20240228165609.06f5254a@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240228165609.06f5254a@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240229_110903_675113_CFF4456A X-CRM114-Status: GOOD ( 20.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Feb 28, 2024 at 04:56:09PM -0800, Jakub Kicinski wrote: > On Wed, 28 Feb 2024 16:01:49 -0800 Kees Cook wrote: > > So, I found several cases where struct net_device is included in the > > middle of another structure, which makes my proposal more awkward. But I > > also don't understand why it's in the _middle_. Shouldn't it always be > > at the beginning (with priv stuff following it?) > > Quick search and examined manually: git grep 'struct net_device [a-z0-9_]*;' > > > > struct rtw89_dev > > struct ath10k > > etc. > > Ugh, yes, the (ab)use of NAPI. > > > Some even have two included (?) > > And some seem to be cargo-culted from out-of-tree code and are unused :S Ah, which can I remove? > That's... less pretty. I'd rather push the ugly into the questionable > users. Make them either allocate the netdev dynamically and store > a pointer, or move the netdev to the end of the struct. > > But yeah, that's a bit of a cleanup :( So far, it's not too bad. I'm doing some test builds now. As a further aside, this code: struct net_device *dev; ... struct net_device *p; ... /* ensure 32-byte alignment of whole construct */ alloc_size += NETDEV_ALIGN - 1; p = kvzalloc(alloc_size, GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL); ... dev = PTR_ALIGN(p, NETDEV_ALIGN); Really screams for a dynamic-sized (bucketed) kmem_cache_alloc API. Alignment constraints can be described in a regular kmem_cache allocator (rather than this open-coded version). I've been intending to build that for struct msg_msg for a while now, and here's another user. :) -Kees -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel