Skip to content
Closed
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 }}
1 change: 1 addition & 0 deletions include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/* L2CAP defaults */
#define L2CAP_DEFAULT_MTU 672
#define L2CAP_DEFAULT_MIN_MTU 48
#define L2CAP_SIG_MTU 48 /* BR/EDR signaling MTU */
#define L2CAP_DEFAULT_FLUSH_TO 0xFFFF
#define L2CAP_EFS_DEFAULT_FLUSH_TO 0xFFFFFFFF
#define L2CAP_DEFAULT_TX_WINDOW 63
Expand Down
47 changes: 47 additions & 0 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5618,6 +5618,15 @@ static inline void l2cap_sig_send_rej(struct l2cap_conn *conn, u16 ident)
l2cap_send_cmd(conn, ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
}

static inline void l2cap_sig_send_mtu_rej(struct l2cap_conn *conn, u8 ident)
{
struct l2cap_cmd_rej_mtu rej;

rej.reason = cpu_to_le16(L2CAP_REJ_MTU_EXCEEDED);
rej.max_mtu = cpu_to_le16(L2CAP_SIG_MTU);
l2cap_send_cmd(conn, ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
}

static inline void l2cap_sig_channel(struct l2cap_conn *conn,
struct sk_buff *skb)
{
Expand All @@ -5630,6 +5639,44 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
if (hcon->type != ACL_LINK)
goto drop;

/*
* Bluetooth Core v5.4, Vol 3, Part A, Section 4: the BR/EDR
* signaling channel has a fixed signaling MTU (MTUsig) whose
* minimum and default is 48 octets. Section 4.1 says that on
* an MTUExceeded command reject the identifier "shall match
* the first request command in the L2CAP packet" and that
* packets containing only response commands "shall be
* silently discarded".
*
* Linux intentionally deviates from that prescription:
*
* 1. Silently discarding desynchronizes the peer. The
* remote stack never learns its responses were dropped,
* so any state machine waiting on a paired response
* stalls until its own timer fires.
*
* 2. Locating "the first request command" requires walking
* command headers past MTUsig, i.e. processing bytes
* from a packet we have already decided is too large to
* process.
*
* Reject every over-MTUsig signaling packet with one
* L2CAP_REJ_MTU_EXCEEDED command reject. The reject's
* reason field is what tells the peer that the whole packet
* was discarded; the identifier value is informational, so
* we use the identifier from the first command header (a
* single fixed-offset byte read) or zero when the packet is
* too short to carry even one header.
*/
if (skb->len > L2CAP_SIG_MTU) {
u8 ident = (skb->len >= L2CAP_CMD_HDR_SIZE) ?
skb->data[1] : 0;

BT_DBG("signaling packet exceeds MTU");
l2cap_sig_send_mtu_rej(conn, ident);
goto drop;
}

while (skb->len >= L2CAP_CMD_HDR_SIZE) {
u16 len;

Expand Down
Loading