Message ID | 20221108141108.62974-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2730837wru; Tue, 8 Nov 2022 06:11:43 -0800 (PST) X-Google-Smtp-Source: AMsMyM4exndcDkql+Fbzjon4QNSlNZsJkQ9ftY7W4c1flbkdI9n9mgJMY4FUwQGCArt7L2xEOzT5 X-Received: by 2002:a05:6402:5202:b0:461:b7e3:e6b7 with SMTP id s2-20020a056402520200b00461b7e3e6b7mr55714134edd.282.1667916703438; Tue, 08 Nov 2022 06:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667916703; cv=none; d=google.com; s=arc-20160816; b=Zr0LaQuI6H/YSIwAaSVjPOP3hIeIDL9sCtUqkaOWvfMLqHf2QOC8y+5iAX3nzNuD4B Dd4+krzRX6I0CG9qkoNVI4wanAKWxF/JXr06uMtTsBnKzF+jUbAmOY0XKrzGmQahmguD X7GhFX0tV0L9ETjRtwyJwMPzxaF9Q79Epp7B11K/y3CTIUazYjHfj8pZUTfB+7Q9NB8r D8qZL5GJR6SuNd7gVCoqQerhvqTJ0ZyxtgwtLb6RShXN+sLwMrO/43Bp+Oy670zd3vPF RIGjR77jBRm0BEughjqRbJEwnGEnVl/Hy6sTAYbhag80/ZQt6PryFzoY/EwbJZaNBt8E SBug== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YpbL02LDOw11JCmqngldtrIFuA91md8pnq53vEEYrPA=; b=qPGeGQBcc+u5soCXnnV1Wxq2SJpwbN034NewqqcjZ0r/lu+ll5Jd0+rwHMaNYA+cSV T3ktXDJIgQKL3M2UKSAhU6M1bXIgqCI5gU2Szopfk4VyeDDg/ZHtq8A4/pr1orj9cymd c9oF4lSFAW4lgKn1mf6YXhxk3jYqBeR5Bhxzpg0DrPDsgpM/zVVPceesCapA44aX6hb/ 7psdb+UW0kI+LW2G0ac0Et8AULJujMGgMB6bk9Jf/Y0Jw3YVCEwD//ncxa4N8eyhZMR9 iQxIsx9SIBreC36YgvvfDKmGj4wYPB/fC/tuCl8AexMqP/yf5AQecEEuwRuS7eCTaIrO GhSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DFlRThY+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd17-20020a1709069b9100b007ae814af66bsi1538632ejc.389.2022.11.08.06.11.18; Tue, 08 Nov 2022 06:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DFlRThY+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235221AbiKHOKw (ORCPT <rfc822;david.rheinsberg@gmail.com> + 99 others); Tue, 8 Nov 2022 09:10:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235193AbiKHOKv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 8 Nov 2022 09:10:51 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5D3E5D; Tue, 8 Nov 2022 06:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667916650; x=1699452650; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=78UClQ5hZwRvjI4tqAdHLzPjsIcZ5QgMjnTJ3lC01cU=; b=DFlRThY+8a5/yj9kbajLA6c/57kVWz7ugdV8I1SeXsZQBocMZiz7D+h2 r1JJWSkizXZY9+YoVI6a0seGtgGkkxcpefQJA3P5GwP0usSfSQPxz0uAB XgLdBb2V/JzkO2QOmy+FM4Hnnbfhbnas+EQuJJPoowyQP3LW+xgwQlGe+ FyYJLIKVdP0U1w0oY6qQnEWDNjEI48s0maddu7AmeqqAgajCAFEl7F3gz 9IxVDRMGv0bNEaPjaM4eDL+0+KTaBXFOIOujuGzVdZ9LzkJfYkS7JBj+D JRyWI/vqBSGTgAfcwfQuWZWp9Bp0XfQqeH9H0DRpr2IKLEtCOnaycosZz A==; X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="396995452" X-IronPort-AV: E=Sophos;i="5.96,147,1665471600"; d="scan'208";a="396995452" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2022 06:10:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="699934682" X-IronPort-AV: E=Sophos;i="5.96,147,1665471600"; d="scan'208";a="699934682" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 08 Nov 2022 06:10:48 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id CA42615C; Tue, 8 Nov 2022 16:11:12 +0200 (EET) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Subject: [resend, PATCH net-next v1 1/1] mac_pton: Don't access memory over expected length Date: Tue, 8 Nov 2022 16:11:08 +0200 Message-Id: <20221108141108.62974-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748936234671517266?= X-GMAIL-MSGID: =?utf-8?q?1748937425116154220?= |
Series |
[resend,net-next,v1,1/1] mac_pton: Don't access memory over expected length
|
|
Commit Message
Andy Shevchenko
Nov. 8, 2022, 2:11 p.m. UTC
The strlen() may go too far when estimating the length of
the given string. In some cases it may go over the boundary
and crash the system which is the case according to the commit
13a55372b64e ("ARM: orion5x: Revert commit 4904dbda41c8.").
Rectify this by switching to strnlen() for the expected
maximum length of the string.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v1[resend]: used net-next (Jakub)
lib/net_utils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
Hello: This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <kuba@kernel.org>: On Tue, 8 Nov 2022 16:11:08 +0200 you wrote: > The strlen() may go too far when estimating the length of > the given string. In some cases it may go over the boundary > and crash the system which is the case according to the commit > 13a55372b64e ("ARM: orion5x: Revert commit 4904dbda41c8."). > > Rectify this by switching to strnlen() for the expected > maximum length of the string. > > [...] Here is the summary with links: - [resend,net-next,v1,1/1] mac_pton: Don't access memory over expected length https://git.kernel.org/netdev/net-next/c/21780f89d658 You are awesome, thank you!
diff --git a/lib/net_utils.c b/lib/net_utils.c index af525353395d..c17201df3d08 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -6,10 +6,11 @@ bool mac_pton(const char *s, u8 *mac) { + size_t maxlen = 3 * ETH_ALEN - 1; int i; /* XX:XX:XX:XX:XX:XX */ - if (strlen(s) < 3 * ETH_ALEN - 1) + if (strnlen(s, maxlen) < maxlen) return false; /* Don't dirty result unless string is valid MAC. */