Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp961728pxb; Wed, 6 Apr 2022 05:24:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/qgj3wHRy30Uv+3W3nzr/I1QPZGXdeveHKq57lrgk1u5zVB+6/t4d7d/O33+OZMDSNysJ X-Received: by 2002:a17:902:ccd1:b0:154:359:7e17 with SMTP id z17-20020a170902ccd100b0015403597e17mr8268803ple.42.1649247880763; Wed, 06 Apr 2022 05:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247880; cv=none; d=google.com; s=arc-20160816; b=ANYdfD9qyJB5xvyAlTD95iM0gBBCUZa5LlS4VndU1fSQthxMjuHzW/WVDkfsw23L9v /go26URaU84tGTJPbGk3fH7hgo6wh7un6wkIXmUH+avh5qUrHPUAeV2MkMAY3LCe72/K JO96YR6KSTHi5xdD3gPj4AQZ+VIm8RhfHURzQVpwrhk/6ZXuPwIkSdRiu3VqY48o1L4L DZBpj4a6anybTy590eGGQAP/PXrV5FbOEmUQgemQfj0mMyFpOcAw39ZmoM21CcAIDs85 loR2xfG/dJtXzu+I/5Ro8xzcJRB3Q4mcAomlJTKSmDeSkZWLllL7lDkTYGGpI1F23m5u PBuw== 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=dZxMhYZAg70X9oh+ivoI3oBvXwsYmgPJlGZ78gA/ILU=; b=cAi1vSt4XpvtQFdxn2ZrA/zDvLgWfxR+QhHzOtktJPVehjUDRbf/Tj9luwOXjbTwXI vlAEygMTyjBbmat1nmGBm7xCOfWYuE3I7MxRRsGqVJ9KzS7PStDDpCh+v40Fq3JoeiCf 5cuuJ7DVBG9nBTiWZ9cyXd/p3X2BPBQYVqcDkKa96UoeJjvO8i8mvw01mrLND+1suA9a QZEbbdsIamBVZHXvbFvMrU4spT69eX/2l5EUZ/Bh/cKNTuu3XP9ui5O4ZHRp1BfFTOI9 lVYpZip19DDVJt5g4osA9Y6wYfBknuxoixEyGhbKfcX9VdRVvG757tzLzYDX7B58CMxa 1Hhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GFJr/6ZS"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y35-20020a056a00182300b004fa3a8e0099si18051873pfa.336.2022.04.06.05.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:24:40 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GFJr/6ZS"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 007BB57421D; Wed, 6 Apr 2022 04:34:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1587377AbiDFAIx (ORCPT + 99 others); Tue, 5 Apr 2022 20:08:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349267AbiDEJtb (ORCPT ); Tue, 5 Apr 2022 05:49:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E19E1902E; Tue, 5 Apr 2022 02:43:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EDD3C615E5; Tue, 5 Apr 2022 09:43:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01FD9C385A1; Tue, 5 Apr 2022 09:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151809; bh=CYBBhqqXnWioOKsqKoupoL8mV+Bt0Z2q89SwnPZ8n6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GFJr/6ZSi7uqZ3Q9CwQZ4YChHWHImqL3CGVE7ta9H7XcRw4JIOVimnMEZ2MxqfRZK XyV4/x7Lo7xqcKgLGebM/eDxR5SmJy9Kkv0rEKni7XHh4Ogq1iUhWdDkXW6HIa9/Bi wy4irPnSDS7I7J7xq4C+3b4QZPVMchNYDx2OdgGI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Derek Will , Oliver Hartkopp , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.15 550/913] can: isotp: return -EADDRNOTAVAIL when reading from unbound socket Date: Tue, 5 Apr 2022 09:26:52 +0200 Message-Id: <20220405070356.334244799@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver Hartkopp [ Upstream commit 30ffd5332e06316bd69a654c06aa033872979b7c ] When reading from an unbound can-isotp socket the syscall blocked indefinitely. As unbound sockets (without given CAN address information) do not make sense anyway we directly return -EADDRNOTAVAIL on read() analogue to the known behavior from sendmsg(). Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol") Link: https://github.com/linux-can/can-utils/issues/349 Link: https://lore.kernel.org/all/20220316164258.54155-2-socketcan@hartkopp.net Suggested-by: Derek Will Signed-off-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- net/can/isotp.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -1005,12 +1005,16 @@ static int isotp_recvmsg(struct socket * { struct sock *sk = sock->sk; struct sk_buff *skb; + struct isotp_sock *so = isotp_sk(sk); int err = 0; int noblock; noblock = flags & MSG_DONTWAIT; flags &= ~MSG_DONTWAIT; + if (!so->bound) + return -EADDRNOTAVAIL; + skb = skb_recv_datagram(sk, flags, noblock, &err); if (!skb) return err;