Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1324567rwb; Thu, 1 Dec 2022 15:58:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf6h4vNPhKy32s9ZibyWC5UO6ZVLYIJAOKV1yPor9Q86jJ/hakVygICjxewxgNXfW/TmIPSO X-Received: by 2002:a17:906:6dd7:b0:7a1:1c24:e564 with SMTP id j23-20020a1709066dd700b007a11c24e564mr46108776ejt.629.1669939111148; Thu, 01 Dec 2022 15:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669939111; cv=none; d=google.com; s=arc-20160816; b=IdLkTdkW7hvv+vs0KnpTOpQ5TmAbGRDL4hRFM8UgJsc1BaBgDi9aKuoBDPGxKBgmvP ubHAC4PEn495+jmX8kZr7p0raHSRIUEGo7nRNde8xKsKYjLpBAAcRWMbrSgmDUavGYjn F5oAY92xBabKrF/2t7O7ITwyEtdctylACksS5uNUJ0a4en9VHF43G4ciSzHtaYfvtIW0 XSgaDiZNUoOpy6fa6aKHFuEHVN5zadSxqRbOe/E9Qttn20aPMswyWSwyroXRFpd3tcMF F6EU7D3XEd0tVRqTy4LhAb0cuoUns0h4ycViK3RYi0+be3OyOTbOm84sp7gq+3kpfxn6 BWpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5KIBskCSFshVVQzdxQTuDjjiIrT7M1OJs78g3mXgnVs=; b=uhxQb2HCVD851mJxyzm6keIxgJMAl9+Jty80CTNhVIk3zti2uSQOZYbTjS+NCqffPi uJ+Y+U5v/t3KH2utieS4iKDxuoiukOVBAJxw0EzEYc2s9eIc42QfqQSpGzwtigFjSwaK lSZEbVNFzN1HXUYF+EyiMU4bsC/VL09zTfPchK8fYuo5N9AYW/28tOTNIOZO5TAsteop NqRCt+xRXcUAYBr99UqFmvIPi99amXhfNZODZmWmHnbr2Bx5WBhPAbLlx31L5uopbXRh 2vyg8dmINuocntVccf5TYiBIxC9SnRylF1wJjZJpKKjnhn0jPNOsdeAQktD7nu3u8Cb0 j4iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CTL+GCU0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hh20-20020a170906a95400b007add8160fd4si1423712ejb.766.2022.12.01.15.58.11; Thu, 01 Dec 2022 15:58:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CTL+GCU0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231400AbiLAXWB (ORCPT + 82 others); Thu, 1 Dec 2022 18:22:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231436AbiLAXVz (ORCPT ); Thu, 1 Dec 2022 18:21:55 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 317A0C9365 for ; Thu, 1 Dec 2022 15:21:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669936915; x=1701472915; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=uZ7J5U8J85lANK+HEQrux7shSC2sB/ALt6HujdjDQmY=; b=CTL+GCU0DZtmxArXCCFVe31KskcQxUlmV8j67pBtUpfFzJ42Ej+TtR6W 9OCFVJFhwr7V8To8WEeO2Sa7o3HAb2QIlB0CXOamN3kjoOOkwgbxaAxIE X3oE/UMHez6FYo2egAvmGE1OEDEtTgwX5NaVLGSpAfF30DTkR/j/8GL0X sv0GzCNzUS7OMA60Jtlzd7onIm0v1TFTBgeevvogF0vsJQ7WfC9j3RgUh KgBVjwzAb832hgjRizmXwsmxhISUZseNxq/8COSqsRYhHfyLtAvT84+zb EjnbPTGUisrEcEterM4jUjuXfExIGP/B0DaeKoA7pHRQrDjeLT6qM6ZKO Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="342755519" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="342755519" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2022 15:21:54 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="733597678" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="733597678" Received: from punajuuri.fi.intel.com (HELO paasikivi.fi.intel.com) ([10.237.72.43]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2022 15:21:52 -0800 Received: from paasikivi.fi.intel.com (localhost [127.0.0.1]) by paasikivi.fi.intel.com (Postfix) with SMTP id 3C70320363; Fri, 2 Dec 2022 01:21:50 +0200 (EET) Date: Thu, 1 Dec 2022 23:21:50 +0000 From: Sakari Ailus To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Jason Gunthorpe , Matthew Wilcox , Andy Shevchenko , "Rafael J. Wysocki" Subject: Re: [PATCH 1/4] container_of: add container_of_const() that preserves const-ness of the pointer Message-ID: References: <20221201193057.1195255-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221201193057.1195255-1-gregkh@linuxfoundation.org> X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, On Thu, Dec 01, 2022 at 08:30:54PM +0100, Greg Kroah-Hartman wrote: > container_of does not preserve the const-ness of a pointer that is > passed into it, which can cause C code that passes in a const pointer to > get a pointer back that is not const and then scribble all over the data > in it. To prevent this, container_of_const() will preserve the const > status of the pointer passed into it using the newly available _Generic() > method. "_const" in the name suggests that the macro would always take a const argument. Could this be called e.g. container_of_safe() (for type-safe, but full type_safe would be a bit long)? -- Kind regards, Sakari Ailus