From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36D59C4332F for ; Mon, 6 Nov 2023 13:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232469AbjKFN2T (ORCPT ); Mon, 6 Nov 2023 08:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232643AbjKFN2S (ORCPT ); Mon, 6 Nov 2023 08:28:18 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0970CD8 for ; Mon, 6 Nov 2023 05:28:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47A14C433C7; Mon, 6 Nov 2023 13:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1699277295; bh=ckGTuqYbmiTGvBVM4u2n0Q/dtLH3QLLA9FzVev7tIMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f8n/uZ9ZzRtdQmCkIyIYyOMCGOiEUyecJ46Oao4Ozf0ZnKUO3HFw3MRTNrgfQ7Bp2 70HrRn6QgGdu0yEj951BD9mFlXVmcYSSVm1C6lTBYedP74AzwXoxEwZ/xASJkm/CuU MgMwV+1FScVOnsiCUNiyuUqlm7AawrzcchLzl0kE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Derek Will , Oliver Hartkopp , Marc Kleine-Budde Subject: [PATCH 5.15 105/128] can: isotp: isotp_bind(): return -EINVAL on incorrect CAN ID formatting Date: Mon, 6 Nov 2023 14:04:25 +0100 Message-ID: <20231106130313.936755563@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231106130309.112650042@linuxfoundation.org> References: <20231106130309.112650042@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oliver Hartkopp commit 2aa39889c463195a0dfe2aff9fad413139c32a4f upstream Commit 3ea566422cbd ("can: isotp: sanitize CAN ID checks in isotp_bind()") checks the given CAN ID address information by sanitizing the input values. This check (silently) removes obsolete bits by masking the given CAN IDs. Derek Will suggested to give a feedback to the application programmer when the 'sanitizing' was actually needed which means the programmer provided CAN ID content in a wrong format (e.g. SFF CAN IDs with a CAN ID > 0x7FF). Link: https://lore.kernel.org/all/20220515181633.76671-1-socketcan@hartkopp.net Suggested-by: Derek Will Signed-off-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- net/can/isotp.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -1142,6 +1142,11 @@ static int isotp_bind(struct socket *soc else rx_id &= CAN_SFF_MASK; + /* give feedback on wrong CAN-ID values */ + if (tx_id != addr->can_addr.tp.tx_id || + rx_id != addr->can_addr.tp.rx_id) + return -EINVAL; + if (!addr->can_ifindex) return -ENODEV;