Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5304391rdb; Wed, 13 Dec 2023 05:14:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyaX/1elK7D38hOsiTX/C6N/YDT1BGieiFqurUyIMd42BuhT5c699nIjm8jVBiHkOobNzF X-Received: by 2002:a17:903:1206:b0:1cc:70dd:62c3 with SMTP id l6-20020a170903120600b001cc70dd62c3mr4176205plh.30.1702473244697; Wed, 13 Dec 2023 05:14:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702473244; cv=none; d=google.com; s=arc-20160816; b=r+tatjzcXYWWoKLm7qY8ETsnJvoJDXZGF2p9eeySmYR+l3X+1Dmsg/9oTzIaeJZ/ch gadScuwvjR9/JiunsvfFUuw9jiYSS0iKSx/rNok4HtRyIGEtg63LNh6V6uGiJ0OemQx4 PfBjVLtjO0o2hkSRWjqdCQtxDVUgf1uZ3TksEOHvX1BMtgwqaHHYu+SBOzeZQq/86Ccb BS5RgrcbCw1j4c82f8++LynGeiwyOGPJ83fE6R8pbJ7sbeXRSuO9zphWSle8+Enu5U78 eZ8YJdhGSctOW/oEqeFEZixcieXY9ZwlfXpDMuS+FfxeJVCSU3Q9n5HTNVQ08ECbhLHE 9QWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1Qo5R6yTzwaWH5LM+yEuRkuuzL/LOwLG4Rnp9GlOsN0=; fh=OupyLn+cVLj8l0f7t5FnMD8nQObPgwsnUNwIXas1IUE=; b=p/MypIUezrzuE7cJoCKmjQyIn46gL7V2YiEmkUxgMESLYun2Jg0EHBA0UYga14Zhos rdqtTXtzKLAQT6oNKFX5zWTU9kdOt4iwzwoBGxr2a5ky/pWBIJ5Tc+FLfcLsBceteopk m1Z6gEDT7/VitufmhWQ5Htnz9pF3bD5fA1QBfGGvEtGVfupCkg23tj3z1xql9Xg5PNRo gzMBpliMQtAL8F0t3bjtuX/i85LM63M6QYwE6OTIeeMj2iiyXqhn/yhzhMaAjon+upJN b0uP3qCc9FMa73aIYbvBDAt/DNRHO9zWf7fbVaT4onzrZGRMKveUMwdbFLiatSngc9mR eBlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nbXR0iWY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id y2-20020a170902ed4200b001cf9e86314dsi9456766plb.637.2023.12.13.05.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:14:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nbXR0iWY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E6CE4804784B; Wed, 13 Dec 2023 05:13:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379149AbjLMNNh (ORCPT + 99 others); Wed, 13 Dec 2023 08:13:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbjLMNNh (ORCPT ); Wed, 13 Dec 2023 08:13:37 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30F7FB2 for ; Wed, 13 Dec 2023 05:13:40 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-425c54f5842so24985101cf.2 for ; Wed, 13 Dec 2023 05:13:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702473219; x=1703078019; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1Qo5R6yTzwaWH5LM+yEuRkuuzL/LOwLG4Rnp9GlOsN0=; b=nbXR0iWY60rcWdeTGupQ2mX4EmoMVHTu5yLrjncNaQD7vK9KHDqRulVzI9Yn/JZdRZ dtCsyK+AIxfNDkFU7YvHv0x7FJ+EqpbPJZVvVDRV2L3vVgnOMdMcd1FEdelDx8pRhWv7 cQFuGAAH1AWMk02blZVThXX5CeMbZ9FqJaBhX4SV38Nla1a2qt040u/xIN06kwVfmeXG GAp9gXMkW/Q6qq4fbuCGz5quKub/9WTnYp1VkGQdxj7tvdOgrGgC7XxGcYkpcr91zIVz gHAXYdd7Rv47MWBSVkB2HnS6/h4SkdkzPGLfNTGRcTskWus+Xp4ERrdOYxBAnsFFXFKM VA+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702473219; x=1703078019; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1Qo5R6yTzwaWH5LM+yEuRkuuzL/LOwLG4Rnp9GlOsN0=; b=vzWO3tJDwC4ZHfNL1Svl2HYItH5s49IGB1ig03qkn6+va+/ZyyUV4VxtPw6po5UAXo CPlOUgiUTJKT1dAJ5SLD984w6IOBk37iO82AcjlvVOvPgBaxQ0MjBmuCVG9P9eKr6pGE x1p5C0WAHlzim3u2htak2Qj/ItR1DOeIga4DHzqkR2rBWTuWKn+ncrV4JYKgAbyVYP3T xZP+gn/fqc+veMGuK9xznAs+5mr8xBtv3evvsjhSlAjiWNnKGPHqSek5gvmrcUj60rOH 1yzKoCxUyvXhMnnaXElW6ZCYa7UvvzFTvOfuexr9E6NPAxKAGw7rKRXd7JzkzkUvlCqs EckQ== X-Gm-Message-State: AOJu0YwFshz0AiP+rG/RU9biPH2Xuzt0KTb9Kc2wWx4qxXxGe3SkL+Qv GSr3DXbBoXc5Wj9QvFVgUs+dLg== X-Received: by 2002:ac8:5909:0:b0:423:7d92:ddba with SMTP id 9-20020ac85909000000b004237d92ddbamr10443139qty.5.1702473219241; Wed, 13 Dec 2023 05:13:39 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id p18-20020ac84612000000b00423e77c96adsm4871616qtn.94.2023.12.13.05.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:13:38 -0800 (PST) Date: Wed, 13 Dec 2023 16:13:22 +0300 From: Dan Carpenter To: xueqin Luo Cc: gregkh@linuxfoundation.org, hdegoede@redhat.com, Larry.Finger@lwfinger.net, xiongxin@kylinos.cn, wangqi@kylinos.cn, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [RESEND PATCH-next] staging: rtl8723bs: replace deprecated strncpy with strscpy_pad Message-ID: References: <20231213011840.10005-1-luoxueqin@kylinos.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231213011840.10005-1-luoxueqin@kylinos.cn> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:14:00 -0800 (PST) On Wed, Dec 13, 2023 at 09:18:40AM +0800, xueqin Luo wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > We should NUL-pad as there are full struct copies happening in places: > | case NL80211_IFTYPE_MONITOR: > | ret = rtw_cfg80211_add_monitor_if(padapter, > | (char *)name, &ndev); > | break; > I don't see where the full copy is... What you're looking for is some place that copies "mon_ndev->name" to the user. > A suitable replacement is `strscpy_pad` due to the fact that it > guarantees both NUL-termination and NUL-padding on the destination > buffer. > > Additionally, replace size macro `IFNAMSIZ` with sizeof(): > | struct net_device { > | char name[IFNAMSIZ]; > | ... This would normally be the right move but IFNAMSIZ is a really standard macro that everyone knows. When I'm reviewing this code, I later on see a line: memcpy(pwdev_priv->ifname_mon, name, IFNAMSIZ + 1); That means name must be "IFNAMSIZ + 1" characters long or it is a bug. Please find out where name is set. We need to know how long it is before we can go any further. regards, dan carpenter