From patchwork Sat Oct 22 07:29:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1110079wrr; Sat, 22 Oct 2022 01:51:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5HNWGiQ/Ef1VNt3rCHuV61kwHwnAicEADyUjHEMZFQ373mLKgmU+dXTnnhfqCy2GYWFoxg X-Received: by 2002:a17:906:ee89:b0:73d:70c5:1a4e with SMTP id wt9-20020a170906ee8900b0073d70c51a4emr18381918ejb.683.1666428674057; Sat, 22 Oct 2022 01:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428674; cv=none; d=google.com; s=arc-20160816; b=yrQ9SFwPcW+WZ1SJpfSgqCcflO27ZxHYeAuM5iL/O4Yz9qHw21OPberFLzXggVKEVu aftJLcxH3X1JpqtjTkDA6kz1m0TLds74YEqBk9oHnTaJfJab2V8BcRVJJo82Mwsgpgvi jby/6fsFaQL2EtBcmJ46WepeHDDoHqORKG7jgyi1E5ZLY7uc4lCqTAOcZLIcNb6jG5HZ ZxrlxxUqZ4MXCDJQcodG382fxz/spmACWQxpoPiik/XU8Dl4HxzoHwqZo7Ap4ZOH2fqh /3GtDWcYcFWKN/Q2hYJHuiswk014PwUFLBrmZSYQ3UiHFZKbXpH4tDCCnQGqpU+cwWUU KbQg== 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=MZ+dM7VAHsL3jsHU07go608N8LWJkogxxTvwv0Kb59mr6Qz5I5cpfeuiEywkSnDzhj Lsk1OXnFUW7wEIgRpC+KRl4hG2TyuERDFwZ3L7uiTnTxjDMlrhX/7Pk6lfhFfRdqe4fh k1ahJKCnriFkW/09gmPQhNvWdpoQ2iWtFrXA0D3nWM0dpyaWk6mMW2lA9fi+zwQeA4ub bIRa1yzprQfwxNqoNMl11vhFyB09YqLL1ZOrZSf0tTOAAjL+vdAy0n5BhruBnN9Ayy5H 8WMKap/Y3XeJ+GRvb5+RHhzDIz+dtyxhAeRPwoM0nL1NA6UWL/sOEnrlq/QHzCUidnjc JcrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bzk2p3yU; 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 c26-20020a056402159a00b0046189831142si302235edv.7.2022.10.22.01.50.49; Sat, 22 Oct 2022 01:51:14 -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=Bzk2p3yU; 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 S234550AbiJVIuK (ORCPT + 99 others); Sat, 22 Oct 2022 04:50:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234820AbiJVIsK (ORCPT ); Sat, 22 Oct 2022 04:48:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69121BC8A; Sat, 22 Oct 2022 01:10:20 -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 D698BB82E11; Sat, 22 Oct 2022 08:07:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CD10C433D6; Sat, 22 Oct 2022 08:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666426041; bh=OjZ0L2KyAgkZPt75DZB7YHk9PytepHMPjogVsy2mw0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bzk2p3yU5CoeSukwuetD4Fw4iK9VYqkYwP4Y4dT4hKfh/PC9+gJmXFf9mHUuNQ1bH rDnpTqWAI4U3ITJlCOt7XLefUcV3VEKOlJXrTAsWdBPBQIl1uKHLiQXmIQP2rhKKmp 1RvhT2IWeRwHNTE5AKwGuenok/qjGLa881dArqbw= 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.19 700/717] net: ieee802154: return -EINVAL for unknown addr type Date: Sat, 22 Oct 2022 09:29:39 +0200 Message-Id: <20221022072529.411578843@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747377113508475515?= X-GMAIL-MSGID: =?utf-8?q?1747377113508475515?= 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,