Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2920212rwe; Mon, 29 Aug 2022 02:41:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6m4FNd0PeokGVLsu6U6amddepw/nDYAQ3PlgVVKP7lXOOPXdsJTXnc8O3TBRyjf+n+9msJ X-Received: by 2002:a17:902:70c6:b0:173:c64:c03b with SMTP id l6-20020a17090270c600b001730c64c03bmr15288044plt.34.1661766062198; Mon, 29 Aug 2022 02:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661766062; cv=none; d=google.com; s=arc-20160816; b=iGUGcVSVG6e9J9eX8Xnxjdsl311KQjwk9b5nVTnEFcxlw/w+aLOyqA+bKTZS+m41wE i+PCwUPuGv10Lx4z/L2A2tNZ3A3kfURU64vbdrZyP+Ij2jVXv2AkqfMaOzG2BmE3Nmbg nVawRj/lopFNwL+Gys5fUCMCqkF/jIsHh+idDZ1K8SXdysUH2lQIlriVbrdUSGW1ftIg Pv3HD7CGtqnMWj503vo27Vv22yZp4+j90lSqvuAEC5sDLEijQIsXjI0XOilafF3Y77IH Pthzxu+5vUVkCKWmkz7mlBa+zKyW0v9hEnJO3RZIVueOJJZ+upKFCDCC6HblrvdPnBIQ 0a2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=kmK1xA3ChRDfbs0TeBtj2omjGednU5QOYRX/hf9CLvY=; b=UXA19hJaS4U0q41g21zH3F9Yj9xJDJEh+lBk2T5tqIPOho45Ci/y1PBj0YqMMAPVX3 tRPA2V2watj1UZADIS1rcKG0PLBZFalPeTo1Cfkq4EmLUBlYonbgBHsUoOY5irJi9QE8 pQI066XrZI6jcdbNBcQHAIr91R3IMheYl1m/vo3/TLA7olGAw5qYBtzsJevoAyy/AmEW umfBWg2cZey/Sfyb0SZVckhCz0s9zC4/hgd5Y8I+MXaidmdybS8llUF+pzLHkRjeeE82 ApeFVxdXBy3pVRqXSvxD/ZxxNAMPUuG82MPhyPM+vuaAtIRCdhlM9o0R7MHNMNjY4w03 OXWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@datenfreihafen.org header.s=2021 header.b=J+LMzCfI; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a17090332c700b00161739962ffsi3562176plr.163.2022.08.29.02.40.51; Mon, 29 Aug 2022 02:41:02 -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=@datenfreihafen.org header.s=2021 header.b=J+LMzCfI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbiH2JIr (ORCPT + 99 others); Mon, 29 Aug 2022 05:08:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbiH2JIp (ORCPT ); Mon, 29 Aug 2022 05:08:45 -0400 Received: from proxima.lasnet.de (proxima.lasnet.de [IPv6:2a01:4f8:121:31eb:3::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A58F15924C; Mon, 29 Aug 2022 02:08:44 -0700 (PDT) Received: from [IPV6:2003:e9:d701:1d41:444a:bdf5:adf8:9c98] (p200300e9d7011d41444abdf5adf89c98.dip0.t-ipconnect.de [IPv6:2003:e9:d701:1d41:444a:bdf5:adf8:9c98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: stefan@datenfreihafen.org) by proxima.lasnet.de (Postfix) with ESMTPSA id DC52CC025B; Mon, 29 Aug 2022 11:08:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datenfreihafen.org; s=2021; t=1661764123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmK1xA3ChRDfbs0TeBtj2omjGednU5QOYRX/hf9CLvY=; b=J+LMzCfIJh5USARdHZll17yWkpMM1GhQgg1nTknvtwECow/iAbAECbttAsIAccrGZEybGM 08W/WHkggZ3BtxYj//RWM4fb/HJ7zRB6Y786DRIVJdCcIhGmwBF9hOqB3EHiYEQtx4nJf1 L/kDChq0CZNHqnZFVvqJlUW3UDjwvwp9Xwk6Kj7wrHhoQmOouGtMbKsc11KOXl1vd/EkD5 57lfPrUI0d5A3Kjwtxv1JmNd/0MshTo44MWx4gNe10j4oUPvWttWBCmSkTQkpykLd9vK7o ZhrrnBc7rnU9hF/WJFM1N7OaxgGCrlZ8n7U36me0IzjP8OQEopcpeu/qk9YV4g== Message-ID: <85f66a3a-95fa-5aaa-def0-998bf3f5139f@datenfreihafen.org> Date: Mon, 29 Aug 2022 11:08:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] net/ieee802154: fix uninit value bug in dgram_sendmsg Content-Language: en-US To: Alexander Aring Cc: Haimin Zhang , Alexander Aring , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wpan - ML , Network Development , Linux Kernel Mailing List , Haimin Zhang References: <20220822071902.3419042-1-tcs_kernel@tencent.com> From: Stefan Schmidt In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hello Alex. On 23.08.22 14:22, Alexander Aring wrote: > Hi, > > On Tue, Aug 23, 2022 at 5:42 AM Stefan Schmidt > wrote: >> >> Hello. >> >> On 22.08.22 09:19, Haimin Zhang wrote: >>> There is uninit value bug in dgram_sendmsg function in >>> net/ieee802154/socket.c when the length of valid data pointed by the >>> msg->msg_name isn't verified. >>> >>> This length is specified by msg->msg_namelen. Function >>> ieee802154_addr_from_sa is called by dgram_sendmsg, which use >>> msg->msg_name as struct sockaddr_ieee802154* and read it, that will >>> eventually lead to uninit value read. So we should check the length of >>> msg->msg_name is not less than sizeof(struct sockaddr_ieee802154) >>> before entering the ieee802154_addr_from_sa. >>> >>> Signed-off-by: Haimin Zhang >> >> >> This patch has been applied to the wpan tree and will be >> part of the next pull request to net. Thanks! > > For me this patch is buggy or at least it is questionable how to deal > with the size of ieee802154_addr_sa here. You are right. I completely missed this. Thanks for spotting! > There should be a helper to calculate the size which depends on the > addr_type field. It is not required to send the last 6 bytes if > addr_type is IEEE802154_ADDR_SHORT. > Nitpick is that we should check in the beginning of that function. Haimin, in ieee802154 we could have two different sizes for ieee802154_addr_sa depending on the addr_type. We have short and extended addresses. Could you please rework this patch to take this into account as Alex suggested? I reverted your original patch from my tree. regards Stefan Schmidt