linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: johan.hedberg@gmail.com
Cc: linux-bluetooth@vger.kernel.org, Johan Hedberg <johan.hedberg@nokia.com>
Subject: Re: [PATCH] Bluetooth: Add blacklist support for incoming connections
Date: Mon, 17 May 2010 17:39:57 +0200	[thread overview]
Message-ID: <1274110797.26613.32.camel@localhost.localdomain> (raw)
In-Reply-To: <1274109587-26638-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> In some circumstances it could be desirable to reject incoming
> connections on the baseband level. This patch adds this feature through
> two new ioctl's: HCIBLOCKADDR and HCIUNBLOCKADDR. Both take a simple
> Bluetooth address as a parameter. BDADDR_ANY can be used with
> HCIUNBLOCKADDR to remove all devices from the blacklist.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
> ---
>  fs/compat_ioctl.c                |    2 +
>  include/net/bluetooth/hci.h      |    3 +
>  include/net/bluetooth/hci_core.h |    8 +++
>  net/bluetooth/hci_core.c         |    2 +
>  net/bluetooth/hci_event.c        |    2 +-
>  net/bluetooth/hci_sock.c         |   90 ++++++++++++++++++++++++++++++++++++++
>  6 files changed, 106 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
> index 641640d..1863896 100644
> --- a/fs/compat_ioctl.c
> +++ b/fs/compat_ioctl.c
> @@ -1328,6 +1328,8 @@ COMPATIBLE_IOCTL(HCISETLINKPOL)
>  COMPATIBLE_IOCTL(HCISETLINKMODE)
>  COMPATIBLE_IOCTL(HCISETACLMTU)
>  COMPATIBLE_IOCTL(HCISETSCOMTU)
> +COMPATIBLE_IOCTL(HCIBLOCKADDR)
> +COMPATIBLE_IOCTL(HCIUNBLOCKADDR)
>  COMPATIBLE_IOCTL(HCIINQUIRY)
>  COMPATIBLE_IOCTL(HCIUARTSETPROTO)
>  COMPATIBLE_IOCTL(HCIUARTGETPROTO)
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index fc0c502..ca2518e 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -100,6 +100,9 @@ enum {
>  #define HCISETACLMTU	_IOW('H', 227, int)
>  #define HCISETSCOMTU	_IOW('H', 228, int)
>  
> +#define HCIBLOCKADDR	_IOW('H', 230, int)
> +#define HCIUNBLOCKADDR	_IOW('H', 231, int)
> +
>  #define HCIINQUIRY	_IOR('H', 240, int)
>  
>  /* HCI timeouts */
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index ce3c99e..ffe7827 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -62,6 +62,11 @@ struct hci_conn_hash {
>  	unsigned int     sco_num;
>  };
>  
> +struct bdaddr_list {
> +	struct list_head list;
> +	bdaddr_t bdaddr;
> +};
> +
>  struct hci_dev {
>  	struct list_head list;
>  	spinlock_t	lock;
> @@ -125,6 +130,7 @@ struct hci_dev {
>  
>  	struct inquiry_cache	inq_cache;
>  	struct hci_conn_hash	conn_hash;
> +	struct bdaddr_list	blacklist;
>  
>  	struct hci_dev_stats	stat;
>  
> @@ -422,6 +428,8 @@ int hci_get_conn_info(struct hci_dev *hdev, void __user *arg);
>  int hci_get_auth_info(struct hci_dev *hdev, void __user *arg);
>  int hci_inquiry(void __user *arg);
>  
> +struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);
> +
>  void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
>  
>  int hci_recv_frame(struct sk_buff *skb);
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 4ad2319..669b0db 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -922,6 +922,8 @@ int hci_register_dev(struct hci_dev *hdev)
>  
>  	hci_conn_hash_init(hdev);
>  
> +	INIT_LIST_HEAD(&hdev->blacklist.list);
> +
>  	memset(&hdev->stat, 0, sizeof(struct hci_dev_stats));
>  
>  	atomic_set(&hdev->promisc, 0);
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 6c57fc7..4d651fc 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -952,7 +952,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
>  
>  	mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
>  
> -	if (mask & HCI_LM_ACCEPT) {
> +	if (mask & HCI_LM_ACCEPT && !hci_blacklist_lookup(hdev, &ev->bdaddr)) {

to make this a bit more readable and clear, this should be like this:

	if ((mask & HCI_LM_ACCEPT) && !hci_blacklist(....

Otherwise patch looks fine:

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



  reply	other threads:[~2010-05-17 15:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17 15:19 [PATCH] Bluetooth: Add blacklist support for incoming connections johan.hedberg
2010-05-17 15:39 ` Marcel Holtmann [this message]
     [not found] ` <AANLkTil3cZu0tfsemxC2DrXTW7gmXU8-MXYKeWyS9t0M@mail.gmail.com>
2010-05-17 20:42   ` Johan Hedberg

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=1274110797.26613.32.camel@localhost.localdomain \
    --to=marcel@holtmann.org \
    --cc=johan.hedberg@gmail.com \
    --cc=johan.hedberg@nokia.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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).