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
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on: [pull_request]

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: tedd-an/bzcafe@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 }}

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

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

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

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

- name: Cleanup PR
uses: tedd-an/bzcafe@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: tedd-an/bzcafe@main
with:
task: patchwork
space: kernel
github_token: ${{ secrets.ACTION_TOKEN }}
email_token: ${{ secrets.EMAIL_TOKEN }}
patchwork_token: ${{ secrets.PATCHWORK_TOKEN }}
patchwork_user: ${{ secrets.PATCHWORK_USER }}

28 changes: 12 additions & 16 deletions include/linux/sockptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,10 @@ static inline int copy_safe_from_sockptr(void *dst, size_t ksize,
static inline int copy_struct_from_sockptr(void *dst, size_t ksize,
sockptr_t src, size_t usize)
{
size_t size = min(ksize, usize);
size_t rest = max(ksize, usize) - size;

if (!sockptr_is_kernel(src))
return copy_struct_from_user(dst, ksize, src.user, size);

if (usize < ksize) {
memset(dst + size, 0, rest);
} else if (usize > ksize) {
char *p = src.kernel;
return copy_struct_from_user(dst, ksize, src.user, usize);

while (rest--) {
if (*p++)
return -E2BIG;
}
}
memcpy(dst, src.kernel, size);
return 0;
return copy_struct_from_bounce_buffer(dst, ksize, src.kernel, usize);
}

static inline int copy_to_sockptr_offset(sockptr_t dst, size_t offset,
Expand All @@ -121,6 +107,16 @@ static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size)
return copy_to_sockptr_offset(dst, 0, src, size);
}

static inline int
copy_struct_to_sockptr(sockptr_t dst, size_t usize, const void *src,
size_t ksize, bool *ignored_trailing)
{
if (!sockptr_is_kernel(dst))
return copy_struct_to_user(dst.user, usize, src, ksize, ignored_trailing);

return copy_struct_to_bounce_buffer(dst.kernel, usize, src, ksize, ignored_trailing);
}

static inline void *memdup_sockptr_noprof(sockptr_t src, size_t len)
{
void *p = kmalloc_track_caller_noprof(len, GFP_USER | __GFP_NOWARN);
Expand Down
65 changes: 64 additions & 1 deletion include/linux/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,77 @@ copy_struct_to_user(void __user *dst, size_t usize, const void *src,
return -EFAULT;
}
if (ignored_trailing)
*ignored_trailing = ksize < usize &&
*ignored_trailing = usize < ksize &&
memchr_inv(src + size, 0, rest) != NULL;
/* Copy the interoperable parts of the struct. */
if (copy_to_user(dst, src, size))
return -EFAULT;
return 0;
}

static __always_inline void
__copy_struct_generic_bounce_buffer(void *dst, size_t dstsize,
const void *src, size_t srcsize,
bool *ignored_trailing)
{
size_t size = min(dstsize, srcsize);
size_t rest = max(dstsize, srcsize) - size;

/* Deal with trailing bytes. */
if (dstsize > srcsize)
memset(dst + size, 0, rest);
if (ignored_trailing)
*ignored_trailing = dstsize < srcsize &&
memchr_inv(src + size, 0, rest) != NULL;
/* Copy the interoperable parts of the struct. */
memcpy(dst, src, size);
}

/**
* This is like copy_struct_from_user(), but the
* src buffer was already copied into a kernel
* bounce buffer, so it will never return -EFAULT.
*/
static __always_inline __must_check int
copy_struct_from_bounce_buffer(void *dst, size_t dstsize,
const void *src, size_t srcsize)
{
bool ignored_trailing;

/* Double check if ksize is larger than a known object size. */
if (WARN_ON_ONCE(dstsize > __builtin_object_size(dst, 1)))
return -E2BIG;

__copy_struct_generic_bounce_buffer(dst, dstsize,
src, srcsize,
&ignored_trailing);
if (unlikely(ignored_trailing))
return -E2BIG;

return 0;
}

/**
* This is like copy_struct_to_user(), but the
* dst buffer is a kernel bounce buffer instead
* of a direct userspace buffer, so it will never return -EFAULT.
*/
static __always_inline __must_check int
copy_struct_to_bounce_buffer(void *dst, size_t dstsize,
const void *src,
size_t srcsize,
bool *ignored_trailing)
{
/* Double check if srcsize is larger than a known object size. */
if (WARN_ON_ONCE(srcsize > __builtin_object_size(src, 1)))
return -E2BIG;

__copy_struct_generic_bounce_buffer(dst, dstsize,
src, srcsize,
ignored_trailing);
return 0;
}

bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size);

long copy_from_kernel_nofault(void *dst, const void *src, size_t size);
Expand Down
6 changes: 6 additions & 0 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5473,7 +5473,13 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
if (chan->ident != cmd->ident)
continue;

l2cap_chan_hold(chan);
l2cap_chan_lock(chan);

l2cap_chan_del(chan, ECONNRESET);

l2cap_chan_unlock(chan);
l2cap_chan_put(chan);
}

return 0;
Expand Down
Loading