From patchwork Mon Oct 24 11:32:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp615278wru; Mon, 24 Oct 2022 12:25:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51D+jkYTIpYLeZ1emuEcteWFgVtg4jpsmU6HmyZyKTRl0Xn355NsTdfdlRI1M/+kvannSD X-Received: by 2002:a17:907:2e0b:b0:7a7:d37e:4650 with SMTP id ig11-20020a1709072e0b00b007a7d37e4650mr6257786ejc.261.1666639559712; Mon, 24 Oct 2022 12:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639559; cv=none; d=google.com; s=arc-20160816; b=QEhaskO72NduOaGoOeWEjDqzmN8SQh+4l1PpL2pCeBZ16lBC9vq79BwOaFCCQpKyWO m+L2fKXBSahU8bTev+9t8QVGkdLCaIO2+42Dx09osXnPQTTQwHROfDskNclk2GnSN4bn hJvxT5GbXWT7QOTVURKnbTUIKmGn8K+yjCU1yKn7BsRX6l6eRzWcmUKmNqLnD29OT2B6 p7HijOzQGxwt5+m18QaxNdzMwhk/X6qg+R0199J8z7KlIfjMFMlpCyPvuZYAzUKPj4gF SUk0DgdkmR9qoTuL3Z7vwuj+gMFUeOEEW8eQw1LIifq9tpJYaPKi1zxAGWtT9mM97Em1 YWjw== 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=joj6Pws13CTw/b/6CzdcXp8QNlZFPu1/ybe5FFGraea++bjq51vH6OQfd+3aOFnSGP s35jwyMTh0s+mxWzBn0H+ABvQShZzBlIOz5I5lG+Kkk/iimEDvI6mmOc5ZIJopRWS4jz IbGnGVDbbuTKTIuWwnlPQVDIGyyZat2i9de28SywXrT++zNHKN8WvF6tkDQOJVWz2UBY foMp7O0VkFoVBenaTZk+WEu+Y4ntDCpf1DTqpmoyNfD5NssgWXCC3pNqQEPVtdoHHBYS CC+6m9ut8BrDtqC2wfIU0hqPNs3i16+V6WG5WHNHDRiPN7WkOrf+cF7g0IPdraDezmlX l9zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="k2C9/z8g"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt19-20020a170907729300b007a137bfaa8dsi549944ejc.148.2022.10.24.12.25.34; Mon, 24 Oct 2022 12:25:59 -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="k2C9/z8g"; 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 S232700AbiJXTOm (ORCPT + 99 others); Mon, 24 Oct 2022 15:14:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233433AbiJXTOO (ORCPT ); Mon, 24 Oct 2022 15:14:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2107514081; Mon, 24 Oct 2022 10:52:32 -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 ams.source.kernel.org (Postfix) with ESMTPS id 440F5B8162F; Mon, 24 Oct 2022 12:15:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AB21C433D7; Mon, 24 Oct 2022 12:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613732; bh=OjZ0L2KyAgkZPt75DZB7YHk9PytepHMPjogVsy2mw0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2C9/z8gDGFrhTWEtxk4yyF68pP+6m5E4j7/yg08hEpJ+ygUswyBFRsviFcADzVpC 7FUrX7hdrgXWDgKk/+71PqCqe5Rk7cHy/BbXyVFUhligqjuZnr1ksI7ofjDqYNC/d1 y0QSfuxkvF8DnG4jQiWbt2QoNFFDRcW3z+M3hJw0= 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 5.4 248/255] net: ieee802154: return -EINVAL for unknown addr type Date: Mon, 24 Oct 2022 13:32:38 +0200 Message-Id: <20221024113011.539405016@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598243037953314?= X-GMAIL-MSGID: =?utf-8?q?1747598243037953314?= 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,