From patchwork Sat Oct 29 08:03:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16781 X-Patchwork-Delegate: sven@narfation.org Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 1D44383168; Sat, 29 Oct 2016 10:03:59 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=xp2a9EZA; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Temperror (SPF Temporary Error: DNS Error: exceeded max query lookup time) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id EDBA583163 for ; Sat, 29 Oct 2016 10:03:36 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593CDC8FD0000000000002E17.dip0.t-ipconnect.de [IPv6:2003:c5:93cd:c8fd::2e17]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 7D8E31C8001 for ; Sat, 29 Oct 2016 10:03:36 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1477728216; bh=ynJEWEG/E+nJUvlFYhSckoj4nOzKOYfOe9X2YA/WD34=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xp2a9EZAQJh+JiYVgqDnBh44kHc2s+sS1CvJDSjdvIx/087y9FhzUGNeaBfv3q0tx 85AGgwyPOXTTDXCmUkFKPJ3U3mjNnAbLoZ51xJRvQQleuvRYXlOBoeuxh+ut1kY3zH NutSbht5pkrbJncc4FO1r8rQjAOyKls24cXiPCZc= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 29 Oct 2016 10:03:28 +0200 Message-Id: <20161029080328.26584-3-sven@narfation.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161029080328.26584-1-sven@narfation.org> References: <20161029080328.26584-1-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: genetlink: mark families as __ro_after_init X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Johannes Berg Now genl_register_family() is the only thing (other than the users themselves, perhaps, but I didn't find any doing that) writing to the family struct. In all families that I found, genl_register_family() is only called from __init functions (some indirectly, in which case I've add __init annotations to clarifly things), so all can actually be marked __ro_after_init. This protects the data structure from accidental corruption. Signed-off-by: Johannes Berg Signed-off-by: David S. Miller [sven@narfation.org: Add compat code] Signed-off-by: Sven Eckelmann --- Patch already in net-next compat-include/linux/cache.h | 35 +++++++++++++++++++++++++++++++++++ net/batman-adv/netlink.c | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 compat-include/linux/cache.h diff --git a/compat-include/linux/cache.h b/compat-include/linux/cache.h new file mode 100644 index 0000000..93dff58 --- /dev/null +++ b/compat-include/linux/cache.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_CACHE_H +#define _NET_BATMAN_ADV_COMPAT_LINUX_CACHE_H + +#include +#include_next + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) + +#ifndef __ro_after_init +#define __ro_after_init +#endif + +#endif /* < KERNEL_VERSION(4, 6, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_CACHE_H */ diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 5dfc5c4..5d38c77 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -603,7 +603,7 @@ static const struct genl_ops batadv_netlink_ops[] = { }; -struct genl_family batadv_netlink_family = { +struct genl_family batadv_netlink_family __ro_after_init = { .hdrsize = 0, .name = BATADV_NL_NAME, .version = 1,