From patchwork Fri Jun 28 14:40:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 168096 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3785649ilk; Fri, 28 Jun 2019 07:40:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqymhsG7vaQjZMKl7HI+De8KkRFH4+91oH44x8GU1QYx81jiSR/iDQl288VXMjjOthWghvnv X-Received: by 2002:a17:902:a409:: with SMTP id p9mr12178997plq.218.1561732837269; Fri, 28 Jun 2019 07:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561732837; cv=none; d=google.com; s=arc-20160816; b=qUDwijSEY9r8fl9pfRvZqb44ZbEYKAXug3iZi2nEshKldUHkRGNH6iCAhy6s1l/rMQ Mb7W7ehFgYILoaoi533rccgefeBHzD9nj40NHWeDtJILhsC4BVyshJBRItWCaNOjwikD pyJdwN/oYE9OHs98qmJUFIs9nxcacB5NE5e0GDcYPTBsxyGB5UMb/TG28jrYxjS4Ve5x 3Bfhcb717HkldMacjra0x35zAx0i7tkpBuRHdAF41eUHDEkrXhgeWuk1dxMZaN+K9QCj tzI9xu7qXWu00s3DFlww1hUpeZr0V09lAhqjEsbE484NjWF606W8Kzh+H+oyY2jo9Lad tOXw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=43pfzP2x4vNwZbt+GQwJI43/4L1/J5JLLMGuVKAsq/0=; b=tsVBzEgvyJlzFp/pW+yIo0uWxWsDIfL5wuC+xh1OFb6Cych70I+FuodSFgwEfG7LVo 3Eeu9gM3gVTpulp5p32jrXzRySFO3Qe1LkqMBHpfG10f0ToDcgccz786rR6QXB3j7erp cXHUt6/walnz3gw1vusHr/S0PmURU7IiQkJPT3l36MmM8GgkR+LTgMOiPiOZbvPRWih2 hBuEDmQV7EwarEi5E6szK5p+YvNfaO2Eko3zyjV6TNy0S0LVziLhBpl9lgKX81vrazvp 0Q7sTnMGglz/xUoThaf3WLA3hm/nkitfnIyuSoufvPTitxcmAOAaS8PChykR4wsywlDN MbTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=xVSv7MOs; 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=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d39si2375428pla.371.2019.06.28.07.40.36; Fri, 28 Jun 2019 07:40:37 -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=@zx2c4.com header.s=mail header.b=xVSv7MOs; 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=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbfF1Okf (ORCPT + 30 others); Fri, 28 Jun 2019 10:40:35 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:46577 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726655AbfF1Okf (ORCPT ); Fri, 28 Jun 2019 10:40:35 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 6715ffe1; Fri, 28 Jun 2019 14:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=mail; bh=AGNG8P6ktfKqFiGbK8g05DgQu8E=; b=xVSv7MOsA+Gxaj2iyrpq P6KS+RHc76Q881QkSESn2yuhFNXqW6NBMLdM2d1h8D6BPC/EoPK8zgXijJLFz4TM +gADwDq0F7QFUvvNe7zudnAjCJl3D5po9+rvLR2Tk2Eb4LEYRKQfNWJNOwSLVAOy VGCGu+lPOrVyxafC3H7kIWiXHAKDplGV3A/+5ebKzI/fqny9ZzbSTFrL7zNl165C C8ozmUbydk0mjta4AM4j32jGNVQxHr2eKEsMc9A75i5jAMqJY10LAOIrcOYxpydq lydCsKN4JtPFnjsLAhUcundobHVXkjH6LYGdwgvcgSNF3klXZU/G7jn5lot/tKW8 UA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 83477081 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Fri, 28 Jun 2019 14:06:14 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Johannes Berg Subject: [PATCH] netlink: use 48 byte ctx instead of 6 signed longs for callback Date: Fri, 28 Jun 2019 16:40:21 +0200 Message-Id: <20190628144022.31376-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org People are inclined to stuff random things into cb->args[n] because it looks like an array of integers. Sometimes people even put u64s in there with comments noting that a certain member takes up two slots. The horror! Really this should mirror the usage of skb->cb, which are just 48 opaque bytes suitable for casting a struct. Then people can create their usual casting macros for accessing strongly typed members of a struct. As a plus, this also gives us the same amount of space on 32bit and 64bit. Signed-off-by: Jason A. Donenfeld Cc: Johannes Berg --- include/linux/netlink.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.21.0 Reviewed-by: Johannes Berg diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 593d1b9c33a8..205fa7b1f07a 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -192,7 +192,14 @@ struct netlink_callback { bool strict_check; u16 answer_flags; unsigned int prev_seq, seq; - long args[6]; + union { + u8 ctx[48]; + + /* args is deprecated. Cast a struct over ctx instead + * for proper type safety. + */ + long args[6]; + }; }; struct netlink_notify {