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 2FF01C4332F for ; Mon, 6 Nov 2023 13:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbjKFN2W (ORCPT ); Mon, 6 Nov 2023 08:28:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232638AbjKFN2V (ORCPT ); Mon, 6 Nov 2023 08:28:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBD00D8 for ; Mon, 6 Nov 2023 05:28:18 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3923EC433C8; Mon, 6 Nov 2023 13:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1699277298; bh=2o00mggr6XSzYFuYU5lN46XZTkV+4LrrbkTGhxs3jD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CulUN+qyPt0JBStz+/Q5ns1Z9LaWrGxAr+ySl317bKFmFy6zCzIJgycbPUZ3Gguv9 1QOPqUb9O8wbgloUeRQyNJWdHkdT0vvCfPeFJAv5uWIp5BAxEMHeaNYCp8VSYwMtxg EWdqhl9yq+ogszcL0pdrGXU9HhZpqFo0ExJZf2KM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+5aed6c3aaba661f5b917@syzkaller.appspotmail.com, Oliver Hartkopp , Marc Kleine-Budde Subject: [PATCH 5.15 106/128] can: isotp: check CAN address family in isotp_bind() Date: Mon, 6 Nov 2023 14:04:26 +0100 Message-ID: <20231106130313.982678739@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 c6adf659a8ba85913e16a571d5a9bcd17d3d1234 upstream Add missing check to block non-AF_CAN binds. Syzbot created some code which matched the right sockaddr struct size but used AF_XDP (0x2C) instead of AF_CAN (0x1D) in the address family field: bind$xdp(r2, &(0x7f0000000540)={0x2c, 0x0, r4, 0x0, r2}, 0x10) ^^^^ This has no funtional impact but the userspace should be notified about the wrong address family field content. Link: https://syzkaller.appspot.com/text?tag=CrashLog&x=11ff9d8c480000 Reported-by: syzbot+5aed6c3aaba661f5b917@syzkaller.appspotmail.com Signed-off-by: Oliver Hartkopp Link: https://lore.kernel.org/all/20230104201844.13168-1-socketcan@hartkopp.net 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 @@ -1129,6 +1129,9 @@ static int isotp_bind(struct socket *soc if (len < ISOTP_MIN_NAMELEN) return -EINVAL; + if (addr->can_family != AF_CAN) + return -EINVAL; + /* sanitize tx/rx CAN identifiers */ tx_id = addr->can_addr.tp.tx_id; if (tx_id & CAN_EFF_FLAG)