Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6941148yba; Thu, 2 May 2019 00:57:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ6u4TUVUAoAsXHKsp1yUjETw12gJVZZdqYaet0WmNaBUGqKkdmEo2ELB1Y3zvCfCeSw5g X-Received: by 2002:a63:e004:: with SMTP id e4mr2594631pgh.344.1556783879350; Thu, 02 May 2019 00:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556783879; cv=none; d=google.com; s=arc-20160816; b=JQPFP0x7zrNloymg93jd9rjbEBdKHppMv17qThnH/Qc5/L577kBAf6SLsq74K5+Ujh 7U1s3m6mOpxzsna9+rSls/h/lHOfPkRtI1UeugLaHJ0KpQStgkNzn94qUZm2aCl1Ihi8 twdowS6iojepJbs6mhuNhWHYu2U8SdcmppxMaAmfyokSWvs/H+Il9Ldfaxu4hQCYOIlp wQV6ocZ1EC3z8ZubU6f8w7JjtnsHsJpOkkiYePDbHpNyW0UTvWj67xrl6CSx+uyM/JJa CLQ8P/BFP2UX1fjrD6f3y5HZTCfPaDR1rG7Kyhvz08SxQuPitV4lOBLh7NpmpiI9b5CM pNOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oRQNrBl3LbUWqyjxjhcKLS8Zdkaq+AHCYKUjrU7AoLE=; b=Lr48l8eanDSoVWwRcCnd7ydnqGO5dIdM98psTUsRPEGO1QzhYU18L8DXpnrajxcWJi o2mRAqIs4CgE+65TTZwa2mZKNRVR9/rAE2OI+w2C8K2BqRvV2hcuHKipmuC0CgDMdttj OXfQmNZxdRJLNdwsB3HkIoTnnS90AQMSKLsbxjN9J+C1zsWK3rMlFL0iBb0ZLDQUlLuc yhKmV4MJANqzsYszABb3yl08Zmo8imza1/GaOntMRylvfeN42N31169wZ5T3pOFvOvPa 8eSE3NBGAKwJkQb5ex6A4zLctiakG9dJmEtiLJPGAE4SBkrrvjF5mBC35ANPCanLsj/Y 60bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K1azEk9F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cc13si15697868plb.412.2019.05.02.00.57.41; Thu, 02 May 2019 00:57:59 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b=K1azEk9F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726255AbfEBH4p (ORCPT + 99 others); Thu, 2 May 2019 03:56:45 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:42244 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbfEBH4p (ORCPT ); Thu, 2 May 2019 03:56:45 -0400 Received: by mail-qt1-f194.google.com with SMTP id p20so1416673qtc.9 for ; Thu, 02 May 2019 00:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oRQNrBl3LbUWqyjxjhcKLS8Zdkaq+AHCYKUjrU7AoLE=; b=K1azEk9FUZTF8l2OPl9v0vSzvaDSDakovrJzRcwbtRPQ1Ki/rEsvk6No2vUF4HY1+J GOXHNzqdPU489+RSuELiGvWh09jiS0XtJErSFv0tSB+JV30b3XP21kZbXLPo62tuy8z3 wXmBOqchvpNA6BfRQ/EbaK+Bmh9YPtfYK+Un0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oRQNrBl3LbUWqyjxjhcKLS8Zdkaq+AHCYKUjrU7AoLE=; b=UpUAPf/upSvWNRuXQ1aAPzmjhoc95l759p/NPkGXnhs6k7cY2N9wL6JkhVcSWtPLMJ y0Y1ID7A7Ji0GUWYmMBYri2nFsjookzAwtOUHjNHmfaT6/cwSpNmo8jBd9mNxniikHxs qLwkCLMcrj8S0ZT4QV9nr5R2RwbAzErN2UeX0SDHvd34BD5AiQ33gKvLzK4rbmj2/E4S bHpjp9hmgVxx2+zctpsqStfwTr0qROTmtpMzxD9uqVyLsNdHgiSP5uxoNN+y3muheQU+ L5vaYzS2ykt944Netz3cr6oJa4+MRKbeosOp/7l50OR5plbWH3wilNkKro5b2n6vIVZf p4mQ== X-Gm-Message-State: APjAAAX4CPfoU/3FjqbshfUQIGT4P7LuCPepiILx8cerG0X8mvl2BMIR IBXg/qZ1F0DNIkxha3FcdHhYtXLXafNv56jzOvgBNQ== X-Received: by 2002:ac8:362e:: with SMTP id m43mr1985816qtb.339.1556783804389; Thu, 02 May 2019 00:56:44 -0700 (PDT) MIME-Version: 1.0 References: <20190418075016.252988-1-pihsun@chromium.org> In-Reply-To: <20190418075016.252988-1-pihsun@chromium.org> From: Nicolas Boichat Date: Thu, 2 May 2019 15:56:33 +0800 Message-ID: Subject: Re: [PATCH] wireless: Use offsetof instead of custom macro. To: Pi-Hsun Shih Cc: open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 18, 2019 at 3:50 PM Pi-Hsun Shih wrote: > > Use offsetof to calculate offset of a field to take advantage of > compiler built-in version when possible, and avoid UBSAN warning when > compiling with Clang: > > ================================================================== > UBSAN: Undefined behaviour in net/wireless/wext-core.c:525:14 > member access within null pointer of type 'struct iw_point' > CPU: 3 PID: 165 Comm: kworker/u16:3 Tainted: G S W 4.19.23 #43 > Workqueue: cfg80211 __cfg80211_scan_done [cfg80211] > Call trace: > dump_backtrace+0x0/0x194 > show_stack+0x20/0x2c > __dump_stack+0x20/0x28 > dump_stack+0x70/0x94 > ubsan_epilogue+0x14/0x44 > ubsan_type_mismatch_common+0xf4/0xfc > __ubsan_handle_type_mismatch_v1+0x34/0x54 > wireless_send_event+0x3cc/0x470 > ___cfg80211_scan_done+0x13c/0x220 [cfg80211] > __cfg80211_scan_done+0x28/0x34 [cfg80211] > process_one_work+0x170/0x35c > worker_thread+0x254/0x380 > kthread+0x13c/0x158 > ret_from_fork+0x10/0x18 > =================================================================== > > Signed-off-by: Pi-Hsun Shih The warning from clang is spurious, but in another case, we felt that the cleanup was worth it, nevertheless (https://lore.kernel.org/patchwork/patch/1050040/). Reviewed-By: Nicolas Boichat > --- > include/uapi/linux/wireless.h | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/include/uapi/linux/wireless.h b/include/uapi/linux/wireless.h > index 86eca3208b6b..f259cca5cc2b 100644 > --- a/include/uapi/linux/wireless.h > +++ b/include/uapi/linux/wireless.h > @@ -1090,8 +1090,7 @@ struct iw_event { > /* iw_point events are special. First, the payload (extra data) come at > * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second, > * we omit the pointer, so start at an offset. */ > -#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ > - (char *) NULL) > +#define IW_EV_POINT_OFF offsetof(struct iw_point, length) > #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \ > IW_EV_POINT_OFF) > > -- > 2.21.0.392.gf8f6787159e-goog >