Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp906004rwi; Wed, 19 Oct 2022 04:35:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Wa99qaG9gMOPE+bPJ85FyVBYgWgBCR0GM8xT3wH1TDHR4NtdrmOM6gLtJKuCRrX0lnrLN X-Received: by 2002:a63:4c5f:0:b0:439:49b4:809f with SMTP id m31-20020a634c5f000000b0043949b4809fmr6632015pgl.382.1666179300281; Wed, 19 Oct 2022 04:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179300; cv=none; d=google.com; s=arc-20160816; b=UiOvA/7uIEXxX/DuYH2M2SCMeEOnWcUiykt7c2mDTiJxE/8YapHvDGRS/K2jqlUYWW KYxLpb9y7puYV+jTmjsq+YV7AebMXnA64gAepub9PZnxJleKs0NttbKrTlqtHW+21MKA tmJfhBJG99RsUZ1E2RNsQAWqN2Pl50aaovOpMZ7buhrWemhyunpsPVmfbUMi5ECtXUkd jpoWejK1NLQOeRX2VdTdmJuNr1m528G1qPNctQuWt5Chzn1n/lBX0udWwj4USxktZlPP iMWayW4EB/YvUFgD8XQydJRewQvK6c9lnfxTPdvtyRDyZVDAfMU3A+4SkVmUkUABOvqA Dtbw== 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=gbCdJqhC/p7TIdq+qgmHmqp0p5N1FFC0pL42yEckEyA=; b=olNltwTQ02hCyz2lb8f1eqdL7nAp9NqM6+HjqxkAu5aqjUhAaHuNrqyc5iFejzMFop yfChXQLgS/kzdU3hRqpVLP1WMQOYUUTkQC9oDLSwSjxFxUAq9B5ZvM1PZC05mYvPP1t9 eEOhGkqNyH42I3yt79+jV4B3GAIXTiO/dgdw6zTFmBKv+h5dxLENVx3765q+q14GrrrX wHmLjFby7ex1SiDa+euqjL+qgjUDfWaeg6uH9IHWmxZz2izqx8ItS7xcLXpf5eyOMpyV dexCxCRAHPF9OzE6lvm67gUfzv3WHzcuWiML6s5GpEWRBOwDHcw+m+zc7EidaZxPmEKT crYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sZjpmTs7; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l69-20020a638848000000b00463cdd82176si16417679pgd.184.2022.10.19.04.34.46; Wed, 19 Oct 2022 04:35:00 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=sZjpmTs7; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231299AbiJSL0M (ORCPT + 99 others); Wed, 19 Oct 2022 07:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbiJSLZx (ORCPT ); Wed, 19 Oct 2022 07:25:53 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 760EF262B; Wed, 19 Oct 2022 03:57:21 -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 sin.source.kernel.org (Postfix) with ESMTPS id 03842CE21FD; Wed, 19 Oct 2022 09:16:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02FCFC433C1; Wed, 19 Oct 2022 09:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666171008; bh=OjZ0L2KyAgkZPt75DZB7YHk9PytepHMPjogVsy2mw0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sZjpmTs77JEA7QV8CRa2QbEeGkD6gsKwBp/StyeTEHuKVDpp6KBjHMrZkzcjti9YH 0EOIligLrBV+uw2U/rgP8iMGtYqzeX75EkpRP3bIfA4YUTEmrzQa1AVuBvHwXfE3qM mi6jVgs3hq0HWinBrXaoOQhrZ9BH1jkWMaWFCN+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , "David S. Miller" Subject: [PATCH 6.0 849/862] net: ieee802154: return -EINVAL for unknown addr type Date: Wed, 19 Oct 2022 10:35:36 +0200 Message-Id: <20221019083327.373078021@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Aring commit 30393181fdbc1608cc683b4ee99dcce05ffcc8c7 upstream. This patch adds handling to return -EINVAL for an unknown addr type. The current behaviour is to return 0 as successful but the size of an unknown addr type is not defined and should return an error like -EINVAL. Fixes: 94160108a70c ("net/ieee802154: fix uninit value bug in dgram_sendmsg") Signed-off-by: Alexander Aring Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/ieee802154_netdev.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/include/net/ieee802154_netdev.h +++ b/include/net/ieee802154_netdev.h @@ -185,21 +185,27 @@ static inline int ieee802154_sockaddr_check_size(struct sockaddr_ieee802154 *daddr, int len) { struct ieee802154_addr_sa *sa; + int ret = 0; sa = &daddr->addr; if (len < IEEE802154_MIN_NAMELEN) return -EINVAL; switch (sa->addr_type) { + case IEEE802154_ADDR_NONE: + break; case IEEE802154_ADDR_SHORT: if (len < IEEE802154_NAMELEN_SHORT) - return -EINVAL; + ret = -EINVAL; break; case IEEE802154_ADDR_LONG: if (len < IEEE802154_NAMELEN_LONG) - return -EINVAL; + ret = -EINVAL; + break; + default: + ret = -EINVAL; break; } - return 0; + return ret; } static inline void ieee802154_addr_from_sa(struct ieee802154_addr *a,