Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp694101pxb; Mon, 25 Oct 2021 16:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzInbXa3HvPpMtlcRW6/r5HhDGB2Xj3rsasy8faLQyYs/7egfciLtBtVRbHEWaDSXfx0TsT X-Received: by 2002:aa7:d9d7:: with SMTP id v23mr28159368eds.286.1635205688763; Mon, 25 Oct 2021 16:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635205688; cv=none; d=google.com; s=arc-20160816; b=dTxyE9hzePrXybU31i9MsbVzrFcF9wYZ3oJnLOX0zKbgBpOJoU2Sbdq6QREeUYV2jz 6ezu3SDRjlB1zMLiNiIhIztLK5rxkW25IEdj8h1a9S57GwdWIEv7BRohnQShD/dCdPC9 RjaFE11paC5yTHUyeyWgKck7E6ixA90wU76NWiPMacOFOOtPSxkqflm5rn9YzufHfwt7 tDu6c1e3FwkBXdhXHkvAkIfju13cqOvZOsPXU9ttkP9E3V/bObyN5aPjYMri6Jejrpxp BpBL05dNW34djneDgmG2m27v1p9RDH6ct754XPPhC8jH56suJLdEMs9H5N5SVB77rv4W 9PgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Okt8mCHB9VRWjpuaX5d2KTUCnG2yDyvrbZ4E06DdQ60=; b=RmNdr0HfgCsBIcziNMLJjGIi1lbMNc3FhGlkt+DRKNrSU09nBhGfyzIJhtVpaLU/F0 0C/uqYoutK297fROzVOD942egp83A9BL/nsQ7vwYhnGmo1bKMaNa08IeTBaGWAtsLfMy gL73domnMO9+oa/y0EGfdTQUA39A4MsLqFLivXmc0zjDH710qOQPoHwfCLpjaxXl79/6 qT2IrbFJSh5+0mXIQ9s28DNnf4KEsAeyh7jCgPFafKAiEDGJ90OOcCInXqGvcoSmmSUp j8fEKgeEDwCLD9CgLYDLd13uAcdvdrR7wgGCD0qsBRJvD+yl9nRQo9U6fDbU/XKPX/9j j5cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h12wF4Sz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o8si23164006ejy.317.2021.10.25.16.47.41; Mon, 25 Oct 2021 16:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h12wF4Sz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236174AbhJYTl6 (ORCPT + 99 others); Mon, 25 Oct 2021 15:41:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:53414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236538AbhJYTey (ORCPT ); Mon, 25 Oct 2021 15:34:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6CEFE6103C; Mon, 25 Oct 2021 19:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635190284; bh=YtplX7ENlKSo0YXZkDaEXzwPNtKcowSANbe0onNv4PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h12wF4SztfzKFmyKj9+KdHxfSWB21mpDDOg2PfZrXa+7cOXdbm+/0rJOn4csGB18q xsoL9vXukfCiyADi2Yq9IiwRYfJbn/5y7+1o5tVlze5dEimfjD0NgqBO3dQIsWqzx0 16ahoL+737qQEMAFKXDqNTX8RNWx7O1bm4i+9KHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Sottas Guillaume (LMB)" , Oliver Hartkopp , Marc Kleine-Budde Subject: [PATCH 5.10 37/95] can: isotp: isotp_sendmsg(): fix return error on FC timeout on TX path Date: Mon, 25 Oct 2021 21:14:34 +0200 Message-Id: <20211025191002.183693059@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025190956.374447057@linuxfoundation.org> References: <20211025190956.374447057@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Kleine-Budde commit d674a8f123b4096d85955c7eaabec688f29724c9 upstream. When the a large chunk of data send and the receiver does not send a Flow Control frame back in time, the sendmsg() does not return a error code, but the number of bytes sent corresponding to the size of the packet. If a timeout occurs the isotp_tx_timer_handler() is fired, sets sk->sk_err and calls the sk->sk_error_report() function. It was wrongly expected that the error would be propagated to user space in every case. For isotp_sendmsg() blocking on wait_event_interruptible() this is not the case. This patch fixes the problem by checking if sk->sk_err is set and returning the error to user space. Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol") Link: https://github.com/hartkopp/can-isotp/issues/42 Link: https://github.com/hartkopp/can-isotp/pull/43 Link: https://lore.kernel.org/all/20210507091839.1366379-1-mkl@pengutronix.de Cc: stable@vger.kernel.org Reported-by: Sottas Guillaume (LMB) Tested-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- net/can/isotp.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -953,6 +953,9 @@ static int isotp_sendmsg(struct socket * if (wait_tx_done) { /* wait for complete transmission of current pdu */ wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE); + + if (sk->sk_err) + return -sk->sk_err; } return size;