linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Evgeniy Polyakov <zbr@ioremap.net>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	"David S. Miller" <davem@davemloft.net>
Subject: [61/74] connector: Delete buggy notification code.
Date: Thu, 04 Feb 2010 09:12:32 -0800	[thread overview]
Message-ID: <20100204171522.587621313@linux.site> (raw)
In-Reply-To: <20100204171850.GA16539@kroah.com>

2.6.32-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Evgeniy Polyakov <zbr@ioremap.net>

commit f98bfbd78c37c5946cc53089da32a5f741efdeb7 upstream.

On Tue, Feb 02, 2010 at 02:57:14PM -0800, Greg KH (gregkh@suse.de) wrote:
> > There are at least two ways to fix it: using a big cannon and a small
> > one. The former way is to disable notification registration, since it is
> > not used by anyone at all. Second way is to check whether calling
> > process is root and its destination group is -1 (kind of priveledged
> > one) before command is dispatched to workqueue.
>
> Well if no one is using it, removing it makes the most sense, right?
>
> No objection from me, care to make up a patch either way for this?

Getting it is not used, let's drop support for notifications about
(un)registered events from connector.
Another option was to check credentials on receiving, but we can always
restore it without bugs if needed, but genetlink has a wider code base
and none complained, that userspace can not get notification when some
other clients were (un)registered.

Kudos for Sebastian Krahmer <krahmer@suse.de>, who found a bug in the
code.

Signed-off-by: Evgeniy Polyakov <zbr@ioremap.net>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/connector/connector.c |  175 ------------------------------------------
 include/linux/connector.h     |   32 -------
 2 files changed, 207 deletions(-)

--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -36,17 +36,6 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
 MODULE_DESCRIPTION("Generic userspace <-> kernelspace connector.");
 
-static u32 cn_idx = CN_IDX_CONNECTOR;
-static u32 cn_val = CN_VAL_CONNECTOR;
-
-module_param(cn_idx, uint, 0);
-module_param(cn_val, uint, 0);
-MODULE_PARM_DESC(cn_idx, "Connector's main device idx.");
-MODULE_PARM_DESC(cn_val, "Connector's main device val.");
-
-static DEFINE_MUTEX(notify_lock);
-static LIST_HEAD(notify_list);
-
 static struct cn_dev cdev;
 
 static int cn_already_initialized;
@@ -210,54 +199,6 @@ static void cn_rx_skb(struct sk_buff *__
 }
 
 /*
- * Notification routing.
- *
- * Gets id and checks if there are notification request for it's idx
- * and val.  If there are such requests notify the listeners with the
- * given notify event.
- *
- */
-static void cn_notify(struct cb_id *id, u32 notify_event)
-{
-	struct cn_ctl_entry *ent;
-
-	mutex_lock(&notify_lock);
-	list_for_each_entry(ent, &notify_list, notify_entry) {
-		int i;
-		struct cn_notify_req *req;
-		struct cn_ctl_msg *ctl = ent->msg;
-		int idx_found, val_found;
-
-		idx_found = val_found = 0;
-
-		req = (struct cn_notify_req *)ctl->data;
-		for (i = 0; i < ctl->idx_notify_num; ++i, ++req) {
-			if (id->idx >= req->first &&
-					id->idx < req->first + req->range) {
-				idx_found = 1;
-				break;
-			}
-		}
-
-		for (i = 0; i < ctl->val_notify_num; ++i, ++req) {
-			if (id->val >= req->first &&
-					id->val < req->first + req->range) {
-				val_found = 1;
-				break;
-			}
-		}
-
-		if (idx_found && val_found) {
-			struct cn_msg m = { .ack = notify_event, };
-
-			memcpy(&m.id, id, sizeof(m.id));
-			cn_netlink_send(&m, ctl->group, GFP_KERNEL);
-		}
-	}
-	mutex_unlock(&notify_lock);
-}
-
-/*
  * Callback add routing - adds callback with given ID and name.
  * If there is registered callback with the same ID it will not be added.
  *
@@ -276,8 +217,6 @@ int cn_add_callback(struct cb_id *id, ch
 	if (err)
 		return err;
 
-	cn_notify(id, 0);
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cn_add_callback);
@@ -295,111 +234,9 @@ void cn_del_callback(struct cb_id *id)
 	struct cn_dev *dev = &cdev;
 
 	cn_queue_del_callback(dev->cbdev, id);
-	cn_notify(id, 1);
 }
 EXPORT_SYMBOL_GPL(cn_del_callback);
 
-/*
- * Checks two connector's control messages to be the same.
- * Returns 1 if they are the same or if the first one is corrupted.
- */
-static int cn_ctl_msg_equals(struct cn_ctl_msg *m1, struct cn_ctl_msg *m2)
-{
-	int i;
-	struct cn_notify_req *req1, *req2;
-
-	if (m1->idx_notify_num != m2->idx_notify_num)
-		return 0;
-
-	if (m1->val_notify_num != m2->val_notify_num)
-		return 0;
-
-	if (m1->len != m2->len)
-		return 0;
-
-	if ((m1->idx_notify_num + m1->val_notify_num) * sizeof(*req1) !=
-	    m1->len)
-		return 1;
-
-	req1 = (struct cn_notify_req *)m1->data;
-	req2 = (struct cn_notify_req *)m2->data;
-
-	for (i = 0; i < m1->idx_notify_num; ++i) {
-		if (req1->first != req2->first || req1->range != req2->range)
-			return 0;
-		req1++;
-		req2++;
-	}
-
-	for (i = 0; i < m1->val_notify_num; ++i) {
-		if (req1->first != req2->first || req1->range != req2->range)
-			return 0;
-		req1++;
-		req2++;
-	}
-
-	return 1;
-}
-
-/*
- * Main connector device's callback.
- *
- * Used for notification of a request's processing.
- */
-static void cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
-{
-	struct cn_ctl_msg *ctl;
-	struct cn_ctl_entry *ent;
-	u32 size;
-
-	if (msg->len < sizeof(*ctl))
-		return;
-
-	ctl = (struct cn_ctl_msg *)msg->data;
-
-	size = (sizeof(*ctl) + ((ctl->idx_notify_num +
-				 ctl->val_notify_num) *
-				sizeof(struct cn_notify_req)));
-
-	if (msg->len != size)
-		return;
-
-	if (ctl->len + sizeof(*ctl) != msg->len)
-		return;
-
-	/*
-	 * Remove notification.
-	 */
-	if (ctl->group == 0) {
-		struct cn_ctl_entry *n;
-
-		mutex_lock(&notify_lock);
-		list_for_each_entry_safe(ent, n, &notify_list, notify_entry) {
-			if (cn_ctl_msg_equals(ent->msg, ctl)) {
-				list_del(&ent->notify_entry);
-				kfree(ent);
-			}
-		}
-		mutex_unlock(&notify_lock);
-
-		return;
-	}
-
-	size += sizeof(*ent);
-
-	ent = kzalloc(size, GFP_KERNEL);
-	if (!ent)
-		return;
-
-	ent->msg = (struct cn_ctl_msg *)(ent + 1);
-
-	memcpy(ent->msg, ctl, size - sizeof(*ent));
-
-	mutex_lock(&notify_lock);
-	list_add(&ent->notify_entry, &notify_list);
-	mutex_unlock(&notify_lock);
-}
-
 static int cn_proc_show(struct seq_file *m, void *v)
 {
 	struct cn_queue_dev *dev = cdev.cbdev;
@@ -437,11 +274,8 @@ static const struct file_operations cn_f
 static int __devinit cn_init(void)
 {
 	struct cn_dev *dev = &cdev;
-	int err;
 
 	dev->input = cn_rx_skb;
-	dev->id.idx = cn_idx;
-	dev->id.val = cn_val;
 
 	dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR,
 					 CN_NETLINK_USERS + 0xf,
@@ -457,14 +291,6 @@ static int __devinit cn_init(void)
 
 	cn_already_initialized = 1;
 
-	err = cn_add_callback(&dev->id, "connector", &cn_callback);
-	if (err) {
-		cn_already_initialized = 0;
-		cn_queue_free_dev(dev->cbdev);
-		netlink_kernel_release(dev->nls);
-		return -EINVAL;
-	}
-
 	proc_net_fops_create(&init_net, "connector", S_IRUGO, &cn_file_ops);
 
 	return 0;
@@ -478,7 +304,6 @@ static void __devexit cn_fini(void)
 
 	proc_net_remove(&init_net, "connector");
 
-	cn_del_callback(&dev->id);
 	cn_queue_free_dev(dev->cbdev);
 	netlink_kernel_release(dev->nls);
 }
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -24,9 +24,6 @@
 
 #include <linux/types.h>
 
-#define CN_IDX_CONNECTOR		0xffffffff
-#define CN_VAL_CONNECTOR		0xffffffff
-
 /*
  * Process Events connector unique ids -- used for message routing
  */
@@ -73,30 +70,6 @@ struct cn_msg {
 	__u8 data[0];
 };
 
-/*
- * Notify structure - requests notification about
- * registering/unregistering idx/val in range [first, first+range].
- */
-struct cn_notify_req {
-	__u32 first;
-	__u32 range;
-};
-
-/*
- * Main notification control message
- * *_notify_num 	- number of appropriate cn_notify_req structures after 
- *				this struct.
- * group 		- notification receiver's idx.
- * len 			- total length of the attached data.
- */
-struct cn_ctl_msg {
-	__u32 idx_notify_num;
-	__u32 val_notify_num;
-	__u32 group;
-	__u32 len;
-	__u8 data[0];
-};
-
 #ifdef __KERNEL__
 
 #include <asm/atomic.h>
@@ -149,11 +122,6 @@ struct cn_callback_entry {
 	u32 seq, group;
 };
 
-struct cn_ctl_entry {
-	struct list_head notify_entry;
-	struct cn_ctl_msg *msg;
-};
-
 struct cn_dev {
 	struct cb_id id;
 



  parent reply	other threads:[~2010-02-04 17:23 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-04 17:18 [00/74] 2.6.32.8-stable review Greg KH
2010-02-04 17:11 ` [01/74] [SCSI] scsi_lib: Fix bug in completion of bidi commands Greg KH
2010-02-04 17:11 ` [02/74] [SCSI] mptsas: Fix issue with chain pools allocation on katmai Greg KH
2010-02-04 17:11 ` [03/74] mm: add new read_cache_page_gfp() helper function Greg KH
2010-02-04 17:11 ` [04/74] drm/i915: Selectively enable self-reclaim Greg KH
2010-02-04 17:11 ` [05/74] firewire: ohci: fix crashes with TSB43AB23 on 64bit systems Greg KH
2010-02-04 17:11 ` [06/74] S390: fix single stepped svcs with TRACE_IRQFLAGS=y Greg KH
2010-02-04 17:11 ` [07/74] x86: Set hotpluggable nodes in nodes_possible_map Greg KH
2010-02-04 17:11 ` [08/74] x86: Remove "x86 CPU features in debugfs" (CONFIG_X86_CPU_DEBUG) Greg KH
2010-02-04 17:11 ` [09/74] libata: retry FS IOs even if it has failed with AC_ERR_INVALID Greg KH
2010-02-04 17:11 ` [10/74] [S390] zcrypt: Do not remove coprocessor for error 8/72 Greg KH
2010-02-04 17:11 ` [11/74] [S390] dasd: fix possible NULL pointer errors Greg KH
2010-02-11 23:15   ` Bastian Blank
2010-02-11 23:38     ` Greg KH
2010-02-04 17:11 ` [12/74] ACPI: Add a generic API for _OSC -v2 Greg KH
2010-02-04 17:11 ` [13/74] ACPI: Add platform-wide _OSC support Greg KH
2010-02-04 17:11 ` [14/74] ACPI: fix OSC regression that caused aer and pciehp not to load Greg KH
2010-02-04 17:11 ` [15/74] ACPI: Advertise to BIOS in _OSC: _OST on _PPC changes Greg KH
2010-02-04 17:11 ` [16/74] UBI: fix volume creation input checking Greg KH
2010-02-04 17:11 ` [17/74] e1000: enhance frame fragment detection Greg KH
2010-02-04 17:11 ` [18/74] e1000e: " Greg KH
2010-02-04 17:11 ` [19/74] e1000/e1000e: dont use small hardware rx buffers Greg KH
2010-02-04 17:11 ` [20/74] drm/i915: Reload hangcheck timer too for Ironlake Greg KH
2010-02-04 17:11 ` [21/74] Fix a leak in affs_fill_super() Greg KH
2010-02-04 17:11 ` [22/74] Fix failure exits in bfs_fill_super() Greg KH
2010-02-04 17:11 ` [23/74] fix oops in fs/9p late mount failure Greg KH
2010-02-04 17:11 ` [24/74] fix leak in romfs_fill_super() Greg KH
2010-02-04 17:11 ` [25/74] Fix remount races with symlink handling in affs Greg KH
2010-02-04 17:11 ` [26/74] fix affs parse_options() Greg KH
2010-02-04 17:11 ` [27/74] Fix failure exit in ipathfs Greg KH
2010-02-04 17:11 ` [28/74] mm: fix migratetype bug which slowed swapping Greg KH
2010-02-04 17:12 ` [29/74] FDPIC: Respect PT_GNU_STACK exec protection markings when creating NOMMU stack Greg KH
2010-02-04 17:12 ` [30/74] Split flush_old_exec into two functions Greg KH
2010-02-04 17:12 ` [31/74] sparc: TIF_ABI_PENDING bit removal Greg KH
2010-02-04 17:12 ` [32/74] x86: get rid of the insane TIF_ABI_PENDING bit Greg KH
2010-02-04 17:12 ` [33/74] Input: winbond-cir - remove dmesg spam Greg KH
2010-02-04 17:12 ` [34/74] x86: Disable HPET MSI on ATI SB700/SB800 Greg KH
2010-02-04 17:12 ` [35/74] iwlwifi: set default aggregation frame count limit to 31 Greg KH
2010-02-04 17:12 ` [36/74] drm/i915: only enable hotplug for detected outputs Greg KH
2010-02-04 17:12 ` [37/74] firewire: core: add_descriptor size check Greg KH
2010-02-04 17:12 ` [38/74] SECURITY: selinux, fix update_rlimit_cpu parameter Greg KH
2010-02-04 17:12 ` [39/74] regulator: Specify REGULATOR_CHANGE_STATUS for WM835x LED constraints Greg KH
2010-02-04 17:12 ` [40/74] x86: Add Dell OptiPlex 760 reboot quirk Greg KH
2010-02-04 17:12 ` [41/74] x86: Add quirk for Intel DG45FC board to avoid low memory corruption Greg KH
2010-02-04 17:12 ` [42/74] x86/amd-iommu: Fix possible integer overflow Greg KH
2010-02-04 17:12 ` [43/74] clocksource: fix compilation if no GENERIC_TIME Greg KH
2010-02-04 17:12 ` [44/74] tcp: update the netstamp_needed counter when cloning sockets Greg KH
2010-02-04 17:12 ` [45/74] sky2: Fix oops in sky2_xmit_frame() after TX timeout Greg KH
2010-02-04 17:12 ` [46/74] net: restore ip source validation Greg KH
2010-02-05 10:16   ` Sven Joachim
2010-02-04 17:12 ` [47/74] af_packet: Dont use skb after dev_queue_xmit() Greg KH
2010-02-04 17:12 ` [48/74] ax25: netrom: rose: Fix timer oopses Greg KH
2010-02-04 17:12 ` [49/74] KVM: allow userspace to adjust kvmclock offset Greg KH
2010-02-04 17:12 ` [50/74] oprofile/x86: add Xeon 7500 series support Greg KH
2010-02-04 17:12 ` [51/74] oprofile/x86: fix crash when profiling more than 28 events Greg KH
2010-02-04 17:12 ` [52/74] libata: retry link resume if necessary Greg KH
2010-02-04 17:12 ` [53/74] mm: percpu-vmap fix RCU list walking Greg KH
2010-02-04 17:12 ` [54/74] mm: purge fragmented percpu vmap blocks Greg KH
2010-02-04 17:12 ` [55/74] block: fix bio_add_page for non trivial merge_bvec_fn case Greg KH
2010-02-04 17:12 ` [56/74] Fix flush_old_exec()/setup_new_exec() split Greg KH
2010-02-04 17:12 ` [57/74] random: drop weird m_time/a_time manipulation Greg KH
2010-02-04 17:12 ` [58/74] random: Remove unused inode variable Greg KH
2010-02-04 17:12 ` [59/74] block: fix bugs in bio-integrity mempool usage Greg KH
2010-02-04 17:12 ` [60/74] usb: r8a66597-hdc disable interrupts fix Greg KH
2010-02-04 17:12 ` Greg KH [this message]
2010-02-04 17:12 ` [62/74] be2net: Bug fix to support newer generation of BE ASIC Greg KH
2010-02-04 17:12 ` [63/74] be2net: Fix memset() arg ordering Greg KH
2010-02-04 17:12 ` [64/74] mm: flush dcache before writing into page to avoid alias Greg KH
2010-02-04 17:12 ` [65/74] mac80211: fix NULL pointer dereference when ftrace is enabled Greg KH
2010-02-04 17:12 ` [66/74] imxfb: correct location of callbacks in suspend and resume Greg KH
2010-02-04 17:12 ` [67/74] mx3fb: some debug and initialisation fixes Greg KH
2010-02-04 17:12 ` [68/74] starfire: clean up properly if firmware loading fails Greg KH
2010-02-04 17:12 ` [69/74] kernel/cred.c: use kmem_cache_free Greg KH
2010-02-04 17:12 ` [70/74] uartlite: fix crash when using as console Greg KH
2010-02-04 17:12 ` [71/74] pktcdvd: removing device does not remove its sysfs dir Greg KH
2010-02-04 17:12 ` [72/74] ath9k: fix eeprom INI values override for 2GHz-only cards Greg KH
2010-02-04 17:12 ` [73/74] ath9k: fix beacon slot/buffer leak Greg KH
2010-02-04 17:12 ` [74/74] powerpc: TIF_ABI_PENDING bit removal Greg KH
2010-02-05  7:36 ` [Stable-review] [00/74] 2.6.32.8-stable review Nikola Ciprich
2010-02-05 17:12   ` Greg KH
2010-02-07 10:26     ` Nikola Ciprich
2010-02-05 16:53 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100204171522.587621313@linux.site \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=zbr@ioremap.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).