From patchwork Mon Oct 24 11:32:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp431635wru; Mon, 24 Oct 2022 05:44:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6NsrAR5fVlnuNds1/aUhdgriXsp7dMeS7GYIjSFFyg42g51HWjufuyFZ+RQCW7oliKS5r2 X-Received: by 2002:aa7:c6c1:0:b0:460:f684:901a with SMTP id b1-20020aa7c6c1000000b00460f684901amr19867351eds.6.1666615460618; Mon, 24 Oct 2022 05:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615460; cv=none; d=google.com; s=arc-20160816; b=vunhmh9b8JnMT+XMDk+/QqGhBKuE+H8HADTX0Z83ZiRovBkyVvqszDQQqdr2399PBU yHi4+5Fl7arweXzpinpP1zEEEhoIhHKYCjdYlvsPSplmtHl08DDOuqxGGdbmS4hatolH DnqlMlZfgF0dHcgTH2fP8GVSCTXbeIWX2mq2IeIfOG0LOVYE87aDOOx2yTMbl1CbNLZM 65N5rHGJx3OU5zM6Y+y2TGu3wVbBMEbEwje9iuY/MQ4hggUS2qdeAvI80AeB9cE6CET9 FLW5cYFLMqVBRaJaTh5oFoHN/MCgP9rF12Hzttk9IxwlC80/kSjpWcxccem9Gk1Qz0ay 2nSg== 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=w+JeoqngnDIj22oFXTpwtF8uTj2pzFV8HLCcISlxjDE=; b=bzPfrcM3xL10dC3Q0y057tVn92zEGOeV7mGFEng2MBqkNeJvONC6LfCjFqqR0REjZV /cmfTqL6QMEgAbY7fdBfEkLKASo6R/GjKK/WOFc2gV50sbJcgF3JLrb+ipZsYINr3kgk EDV6xHQwHhmW7krU85OjnHXWBXDP6cJofbHEiy3LKBUZOSKj+lioy777VZueQnBhXfdO italTDLxto1neTOtWqzYphZvdsgr1jH3XCKZoDPt3EcE9bpmBGospLHL9S5xLsgcRtO2 PYND4NZCeefviFciNVJzx08DtZL9lQD08cKUrh7b76z8JJrZjBFRKMfBCXVAGPn4uioy B3sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hL3a5z6l; 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 n14-20020aa7c78e000000b00458ee128628si23638722eds.470.2022.10.24.05.43.53; Mon, 24 Oct 2022 05:44:20 -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=hL3a5z6l; 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 S231218AbiJXMiJ (ORCPT + 99 others); Mon, 24 Oct 2022 08:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234278AbiJXMem (ORCPT ); Mon, 24 Oct 2022 08:34:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E11574A807; Mon, 24 Oct 2022 05:05:04 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 5D53E612BF; Mon, 24 Oct 2022 12:04:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DE76C433C1; Mon, 24 Oct 2022 12:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613087; bh=nU5shlmlTDL+WA15wXTBEMZOu70bg3gompzMDfGsWu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hL3a5z6l2Qr4q2CC+F7xlvybcngWdUmP0CH8b3G3ITelh5Eejbfb14fMgIk9iWj/t zTvzTlD1ph2n/77BFkecYMbeRceu0rJcglBDqmPiBTi7iH5U3BgrY/zyP1+3NR0F35 M4WcJg7dCGhjcFs5oiEY1kwYP4efYORP92GwrZG8= 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 4.19 222/229] net: ieee802154: return -EINVAL for unknown addr type Date: Mon, 24 Oct 2022 13:32:21 +0200 Message-Id: <20221024113006.446380153@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747572973490626382?= X-GMAIL-MSGID: =?utf-8?q?1747572973490626382?= 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 @@ -193,21 +193,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,