Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
checks: write
pull-requests: write

jobs:
ci:
runs-on: ubuntu-latest
name: CI for Pull Request
steps:
- name: Checkout the source code
uses: actions/checkout@v3
with:
path: src/src

- name: CI
uses: bluez/action-ci@main
with:
task: ci
base_folder: src
space: kernel
github_token: ${{ secrets.GITHUB_TOKEN }}
email_token: ${{ secrets.EMAIL_TOKEN }}
patchwork_token: ${{ secrets.PATCHWORK_TOKEN }}
patchwork_user: ${{ secrets.PATCHWORK_USER }}

44 changes: 44 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Sync

on:
schedule:
- cron: "*/5 * * * *"

jobs:
sync_repo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master

- name: Sync Repo
uses: bluez/action-ci@main
with:
task: sync
workflow: workflow
upstream_repo: 'https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git'
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Cleanup PR
uses: bluez/action-ci@main
with:
task: cleanup
github_token: ${{ secrets.ACTION_TOKEN }}

sync_patchwork:
needs: sync_repo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Sync Patchwork
uses: bluez/action-ci@main
with:
task: patchwork
workflow: workflow
space: kernel
github_token: ${{ secrets.ACTION_TOKEN }}
email_token: ${{ secrets.EMAIL_TOKEN }}
patchwork_token: ${{ secrets.PATCHWORK_TOKEN }}
patchwork_user: ${{ secrets.PATCHWORK_USER }}
51 changes: 31 additions & 20 deletions net/bluetooth/bnep/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,11 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
return 0;
}

static int bnep_rx_control(struct bnep_session *s, void *data, int len)
static int bnep_rx_control_cmd(struct bnep_session *s, u8 cmd, void *data,
int len)
{
u8 cmd = *(u8 *)data;
int err = 0;

data++;
len--;

switch (cmd) {
case BNEP_CMD_NOT_UNDERSTOOD:
case BNEP_SETUP_CONN_RSP:
Expand Down Expand Up @@ -254,6 +251,14 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len)
return err;
}

static int bnep_rx_control(struct bnep_session *s, void *data, int len)
{
if (len < 1)
return -EILSEQ;

return bnep_rx_control_cmd(s, *(u8 *)data, data + 1, len - 1);
}

static int bnep_rx_extension(struct bnep_session *s, struct sk_buff *skb)
{
struct bnep_ext_hdr *h;
Expand Down Expand Up @@ -299,19 +304,26 @@ static int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
{
struct net_device *dev = s->dev;
struct sk_buff *nskb;
u8 *data;
u8 type, ctrl_type;

dev->stats.rx_bytes += skb->len;

type = *(u8 *) skb->data;
skb_pull(skb, 1);
ctrl_type = *(u8 *)skb->data;
data = skb_pull_data(skb, sizeof(type));
if (!data)
goto badframe;
type = *data;

if ((type & BNEP_TYPE_MASK) >= sizeof(__bnep_rx_hlen))
goto badframe;

if ((type & BNEP_TYPE_MASK) == BNEP_CONTROL) {
if (bnep_rx_control(s, skb->data, skb->len) < 0) {
data = skb_pull_data(skb, sizeof(ctrl_type));
if (!data)
goto badframe;
ctrl_type = *data;

if (bnep_rx_control_cmd(s, ctrl_type, skb->data, skb->len) < 0) {
dev->stats.tx_errors++;
kfree_skb(skb);
return 0;
Expand All @@ -325,23 +337,22 @@ static int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
/* Verify and pull ctrl message since it's already processed */
switch (ctrl_type) {
case BNEP_SETUP_CONN_REQ:
/* Pull: ctrl type (1 b), len (1 b), data (len bytes) */
if (!skb_pull(skb, 2 + *(u8 *)(skb->data + 1) * 2))
/* Pull: len (1 b), data (len * 2 bytes) */
data = skb_pull_data(skb, 1);
if (!data)
goto badframe;
if (!skb_pull(skb, *data * 2))
goto badframe;
break;
case BNEP_FILTER_MULTI_ADDR_SET:
case BNEP_FILTER_NET_TYPE_SET: {
u8 *hdr;

/* Pull ctrl type (1 b) + len (2 b) */
hdr = skb_pull_data(skb, 3);
if (!hdr)
case BNEP_FILTER_NET_TYPE_SET:
/* Pull: len (2 b), data (len bytes) */
data = skb_pull_data(skb, sizeof(u16));
if (!data)
goto badframe;
/* Pull data (len bytes); length is big-endian */
if (!skb_pull(skb, get_unaligned_be16(&hdr[1])))
if (!skb_pull(skb, get_unaligned_be16(data)))
goto badframe;
break;
}
default:
kfree_skb(skb);
return 0;
Expand Down
Loading