Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp836330imu; Thu, 22 Nov 2018 06:08:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/UCG17czeoerqAfqX5ijWiFARZcuaJjkqVEUzgdUuXY/tTyRaKz8elFxMDoyTjdmQDr5IKZ X-Received: by 2002:a17:902:66e5:: with SMTP id e92-v6mr11241700plk.92.1542895726608; Thu, 22 Nov 2018 06:08:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542895726; cv=none; d=google.com; s=arc-20160816; b=x5dkm+59ibomNDs+YQUR+qLTNT0/5qgCmxsAAo8ZWiVnlBfxk5zkxT8sjtDPOQ4ZdF 6DJ63BInDA0+y32bl7fkiulY0s6PGWMkDBBM/lllcIp2hnhQFJTAuQkzD5eogC2EyBj/ X1cI+kM9S6AhYSvB7A9pFKw5/ZOnTjdhXOHqTkdUiIGtELpZ+FP02hKRohMzfExkBiJg InFUS0BBffB68DDDThIbE2P3z11bpEW6onx8MctSZ+7FmKwI9gtMhdxkqtfjiBqpZNLK Uhl7nngO7e9klgOCFqSHlywjacHhe7O1mUMgjmKoMWtX1FofZIM2HO1b/iyHKtJbwEQv LdJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=eeoqGjIUKPL6c0nuTsvR7dZ47ePvLHk77Xps7C5kum0=; b=qnVJ/qCyVoGDnDdbQtvufbwFxT1gUjLMCZLrR9T1dKRqNl+L62Qq0eAWs2StnWtjfJ VoiZG3qZArtK1mro6NqNp9LVOjJGfdxhZHGbRU0rYlzB/Z5toeAk3oFDXFqTLeyCV7U4 gPCq0HSXk+NYlkgYlWg5ZYaf3meJGSQfZhluxUppEe9TOAAiSI4gHBz0Gyrv+lxJzI/H aD5aYstZNHWBJVNb7d+tOVDgFgGDnzADAJgmCqygVwDBKQgYe1dItCLwc3JIB6dQCQzL ILDW0fB2sCZSXxim5N7b2GpyhW0C36aRRqpptiICv17ZVfoiqetlNka3zKT7ICmSJkhA 034w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x191si5792104pfd.220.2018.11.22.06.08.32; Thu, 22 Nov 2018 06:08:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389261AbeKVOCb (ORCPT + 99 others); Thu, 22 Nov 2018 09:02:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:55062 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732521AbeKVOCb (ORCPT ); Thu, 22 Nov 2018 09:02:31 -0500 Received: from localhost.localdomain (c-24-6-170-16.hsd1.ca.comcast.net [24.6.170.16]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 08802516; Thu, 22 Nov 2018 03:25:07 +0000 (UTC) Date: Wed, 21 Nov 2018 19:25:07 -0800 From: Andrew Morton To: Masahiro Yamada Cc: Luc Van Oostenryck , Nick Desaulniers , Kees Cook , Josh Triplett , Alexei Starovoitov , linux-kernel@vger.kernel.org, NeilBrown , Greg Kroah-Hartman , Ingo Molnar , Crt Mori , Dan Carpenter Subject: Re: [PATCH v4 1/3] kernel.h: disable type-checks in container_of() for Sparse Message-Id: <20181121192507.5199cf95fd2da9573a18ca80@linux-foundation.org> In-Reply-To: <1542856462-18836-1-git-send-email-yamada.masahiro@socionext.com> References: <1542856462-18836-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 22 Nov 2018 12:14:20 +0900 Masahiro Yamada wrote: > When I tried to enable BUILD_BUG_ON for Sparse, the kbuild test robot > reported lots of "unknown expression" warnings from container_of(), > which seemed false positive. > > I addressed this in [1], but fixing Sparse is the right thing to do. > > The issue was fixed by Sparse commit 0eb8175d3e9c ("fix expansion of > function designator"), but it will take time until the fixed version > of Sparse is widely available. > > Disable the container_of() type checks for Sparse for now. > > [1] https://lore.kernel.org/lkml/1542623503-3755-1-git-send-email-yamada.masahiro@socionext.com/ > > ... > > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -985,6 +985,21 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } > #define __CONCAT(a, b) a ## b > #define CONCATENATE(a, b) __CONCAT(a, b) > > +/* > + * TODO: > + * Sparse emits "unknown expression" warnings. > + * It was fixed by commit 0eb8175d3e9c0d20354763d07ce3d4c0e543d988 in Sparse. > + * Remove the following workaround when the fixed Sparse is widely available. > + */ > +#ifdef __CHECKER__ > +#define TYPE_CHECK_CONTAINER_OF(ptr, type, member) do {} while (0) > +#else > +#define TYPE_CHECK_CONTAINER_OF(ptr, type, member) \ > + BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ > + !__same_type(*(ptr), void), \ > + "pointer type mismatch in container_of()") > +#endif I think that's OK. A few years hence, someone will happen upon this comment and will perform the obvious cleanup.