Isotp driver causes timeout because of race condition during nonblocking writes

Bug #2038852 reported by Pankaj
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

This are my system details
Description: Ubuntu 20.04.6 LTS
Release: 20.04

When using 5.15.133 kernel on Ubuntu 20.04. I am seeing that non blocking writes cause race condition and locks the socket. This issue is resolved by a patch from here https://<email address hidden>/T/#u. This patch is supposed to make in the 6.7 kernel commit id 61caf48cf7 and I would like it to be fixed for 5.15 stream as well. I have tested that this patch when applied to 5.15.133 works. The patch cannot be directly applied but a more comprehensive look at the current code at net/can/isotp.c. This is a diff of my changes to isotp.c
119c119,120
< ISOTP_SENDING
---
> ISOTP_SENDING,
> ISOTP_SHUTDOWN,
873c874
< if (!so->bound)
---
> if (!so->bound|| so->tx.state == ISOTP_SHUTDOWN)
876,893c877,887
< /* we do not support multiple buffers - for now */
< if (cmpxchg(&so->tx.state, ISOTP_IDLE, ISOTP_SENDING) != ISOTP_IDLE ||
< wq_has_sleeper(&so->wait)) {
< if (msg->msg_flags & MSG_DONTWAIT) {
< err = -EAGAIN;
< goto err_out;
< }
<
< /* wait for complete transmission of current pdu */
< err = wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE);
< if (err)
< goto err_out;
< }
<
< if (!size || size > MAX_MSG_LENGTH) {
< err = -EINVAL;
< goto err_out_drop;
< }
---
> while (cmpxchg(&so->tx.state, ISOTP_IDLE, ISOTP_SENDING) != ISOTP_IDLE) {
> /* we do not support multiple buffers - for now */
> if (msg->msg_flags & MSG_DONTWAIT)
> return -EAGAIN;
> if (so->tx.state == ISOTP_SHUTDOWN)
> return -EADDRNOTAVAIL;
> /* wait for complete transmission of current pdu */
> err = wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE);
> if (err)
> goto err_out;
> }

Tags: jammy
Pankaj (pajain)
description: updated
Paul White (paulw2u)
affects: ubuntu → linux (Ubuntu)
tags: added: jammy
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 2038852

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
Pankaj (pajain) wrote :

I cannot provide logs using apport. Please let me know if you need to know how I am using this driver.

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.