Revision da9846ae15186d491d6e21ebbb5051e1d3c7f652 authored by Tejun Heo on 29 January 2014, 17:04:03 UTC, committed by Greg Kroah-Hartman on 05 February 2014, 19:44:04 UTC
kernfs_deactivate() forgot to check whether KERNFS_LOCKDEP is set before performing lockdep annotations and ends up feeding uninitialized lockdep_map to lockdep triggering warning like the following on USB stick hotunplug. usb 1-2: USB disconnect, device number 2 INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 1 PID: 62 Comm: khubd Not tainted 3.13.0-work+ #82 Hardware name: empty empty/S3992, BIOS 080011 10/26/2007 ffff880065ca7f60 ffff88013a4ffa08 ffffffff81cfb6bd 0000000000000002 ffff88013a4ffac8 ffffffff810f8530 ffff88013a4fc710 0000000000000002 ffff880100000000 ffffffff82a3db50 0000000000000001 ffff88013a4fc710 Call Trace: [<ffffffff81cfb6bd>] dump_stack+0x4e/0x7a [<ffffffff810f8530>] __lock_acquire+0x1910/0x1e70 [<ffffffff810f931a>] lock_acquire+0x9a/0x1d0 [<ffffffff8127c75e>] kernfs_deactivate+0xee/0x130 [<ffffffff8127d4c8>] kernfs_addrm_finish+0x38/0x60 [<ffffffff8127d701>] kernfs_remove_by_name_ns+0x51/0xa0 [<ffffffff8127b4f1>] remove_files.isra.1+0x41/0x80 [<ffffffff8127b7e7>] sysfs_remove_group+0x47/0xa0 [<ffffffff8127b873>] sysfs_remove_groups+0x33/0x50 [<ffffffff8177d66d>] device_remove_attrs+0x4d/0x80 [<ffffffff8177e25e>] device_del+0x12e/0x1d0 [<ffffffff819722c2>] usb_disconnect+0x122/0x1a0 [<ffffffff819749b5>] hub_thread+0x3c5/0x1290 [<ffffffff810c6a6d>] kthread+0xed/0x110 [<ffffffff81d0a56c>] ret_from_fork+0x7c/0xb0 Fix it by making kernfs_deactivate() perform lockdep annotations only if KERNFS_LOCKDEP is set. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Fabio Estevam <festevam@gmail.com> Reported-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Jiri Kosina <jkosina@suse.cz> Reported-by: Dave Jones <davej@redhat.com> Tested-by: Fabio Estevam <fabio.estevam@freescale.com> Tested-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 38dbfb5
vmci_transport_notify.h
/*
* VMware vSockets Driver
*
* Copyright (C) 2009-2013 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation version 2 and no later version.
*
* 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.
*/
#ifndef __VMCI_TRANSPORT_NOTIFY_H__
#define __VMCI_TRANSPORT_NOTIFY_H__
#include <linux/types.h>
#include <linux/vmw_vmci_defs.h>
#include <linux/vmw_vmci_api.h>
#include <linux/vm_sockets.h>
#include "vmci_transport.h"
/* Comment this out to compare with old protocol. */
#define VSOCK_OPTIMIZATION_WAITING_NOTIFY 1
#if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY)
/* Comment this out to remove flow control for "new" protocol */
#define VSOCK_OPTIMIZATION_FLOW_CONTROL 1
#endif
#define VMCI_TRANSPORT_MAX_DGRAM_RESENDS 10
struct vmci_transport_recv_notify_data {
u64 consume_head;
u64 produce_tail;
bool notify_on_block;
};
struct vmci_transport_send_notify_data {
u64 consume_head;
u64 produce_tail;
};
/* Socket notification callbacks. */
struct vmci_transport_notify_ops {
void (*socket_init) (struct sock *sk);
void (*socket_destruct) (struct vsock_sock *vsk);
int (*poll_in) (struct sock *sk, size_t target,
bool *data_ready_now);
int (*poll_out) (struct sock *sk, size_t target,
bool *space_avail_now);
void (*handle_notify_pkt) (struct sock *sk,
struct vmci_transport_packet *pkt,
bool bottom_half, struct sockaddr_vm *dst,
struct sockaddr_vm *src,
bool *pkt_processed);
int (*recv_init) (struct sock *sk, size_t target,
struct vmci_transport_recv_notify_data *data);
int (*recv_pre_block) (struct sock *sk, size_t target,
struct vmci_transport_recv_notify_data *data);
int (*recv_pre_dequeue) (struct sock *sk, size_t target,
struct vmci_transport_recv_notify_data *data);
int (*recv_post_dequeue) (struct sock *sk, size_t target,
ssize_t copied, bool data_read,
struct vmci_transport_recv_notify_data *data);
int (*send_init) (struct sock *sk,
struct vmci_transport_send_notify_data *data);
int (*send_pre_block) (struct sock *sk,
struct vmci_transport_send_notify_data *data);
int (*send_pre_enqueue) (struct sock *sk,
struct vmci_transport_send_notify_data *data);
int (*send_post_enqueue) (struct sock *sk, ssize_t written,
struct vmci_transport_send_notify_data *data);
void (*process_request) (struct sock *sk);
void (*process_negotiate) (struct sock *sk);
};
extern struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops;
extern struct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops;
#endif /* __VMCI_TRANSPORT_NOTIFY_H__ */
Computing file changes ...