From: Luiz Augusto von Dentz <[email protected]>
In order to properly handle shutdown syscall the code shall not assume
that the how argument is always SHUT_RDWR resulting in SHUTDOWN_MASK as
that would result in poll to immediatelly report EPOLLHUP instead of
properly waiting for disconnect_cfm (Disconnect Complete) which is
rather important for the likes of BAP as the CIG may need to be
reprogrammed.
Fixes: ccf74f2390d6 ("Bluetooth: Add BTPROTO_ISO socket type")
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
net/bluetooth/iso.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index ced8ad4fed4f..b50a69064fee 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -1317,17 +1317,32 @@ static int iso_sock_shutdown(struct socket *sock, int how)
sock_hold(sk);
lock_sock(sk);
- if (!sk->sk_shutdown) {
- sk->sk_shutdown = SHUTDOWN_MASK;
- iso_sock_clear_timer(sk);
- __iso_sock_close(sk);
-
- if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
- !(current->flags & PF_EXITING))
- err = bt_sock_wait_state(sk, BT_CLOSED,
- sk->sk_lingertime);
+ switch (how) {
+ case SHUT_RD:
+ if (sk->sk_shutdown & RCV_SHUTDOWN)
+ goto unlock;
+ sk->sk_shutdown |= RCV_SHUTDOWN;
+ break;
+ case SHUT_WR:
+ if (sk->sk_shutdown & SEND_SHUTDOWN)
+ goto unlock;
+ sk->sk_shutdown |= SEND_SHUTDOWN;
+ break;
+ case SHUT_RDWR:
+ if (sk->sk_shutdown & SHUTDOWN_MASK)
+ goto unlock;
+ sk->sk_shutdown |= SHUTDOWN_MASK;
+ break;
}
+ iso_sock_clear_timer(sk);
+ __iso_sock_close(sk);
+
+ if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
+ !(current->flags & PF_EXITING))
+ err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime);
+
+unlock:
release_sock(sk);
sock_put(sk);
--
2.37.2
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=669308
---Test result---
Test Summary:
CheckPatch FAIL 1.87 seconds
GitLint PASS 0.98 seconds
SubjectPrefix PASS 0.74 seconds
BuildKernel PASS 32.56 seconds
BuildKernel32 PASS 28.57 seconds
Incremental Build with patchesPASS 42.90 seconds
TestRunner: Setup PASS 478.43 seconds
TestRunner: l2cap-tester PASS 16.66 seconds
TestRunner: bnep-tester PASS 6.19 seconds
TestRunner: mgmt-tester PASS 98.28 seconds
TestRunner: rfcomm-tester PASS 9.50 seconds
TestRunner: sco-tester PASS 9.29 seconds
TestRunner: smp-tester PASS 9.25 seconds
TestRunner: userchan-tester PASS 6.44 seconds
Details
##############################
Test: CheckPatch - FAIL - 1.87 seconds
Run checkpatch.pl script with rule in .checkpatch.conf
Bluetooth: ISO: Fix not handling shutdown condition\WARNING:TYPO_SPELLING: 'immediatelly' may be misspelled - perhaps 'immediately'?
#82:
that would result in poll to immediatelly report EPOLLHUP instead of
^^^^^^^^^^^^
total: 0 errors, 1 warnings, 0 checks, 41 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/12949086.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
---
Regards,
Linux Bluetooth
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <[email protected]>:
On Fri, 19 Aug 2022 11:46:33 -0700 you wrote:
> From: Luiz Augusto von Dentz <[email protected]>
>
> In order to properly handle shutdown syscall the code shall not assume
> that the how argument is always SHUT_RDWR resulting in SHUTDOWN_MASK as
> that would result in poll to immediatelly report EPOLLHUP instead of
> properly waiting for disconnect_cfm (Disconnect Complete) which is
> rather important for the likes of BAP as the CIG may need to be
> reprogrammed.
>
> [...]
Here is the summary with links:
- Bluetooth: ISO: Fix not handling shutdown condition
https://git.kernel.org/bluetooth/bluetooth-next/c/a89e4b749aab
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html