From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFDB7EB64D7 for ; Tue, 13 Jun 2023 19:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5l7aNLr+J3svMQu5G7Ix4eZC99ogZJA4TcbEnpzpWNQ=; b=JUXTPOffxS6LfS ksO/GwHorImfm7UK5HJ1plr1NUqepORyywdH8fp6VYhPYOiXP2n0AfmxA7WrBAPOZLTNXW5BaNhH0 tFS52f+PVItAopE10yBrZXaQduhlcZTuPx1GaLVHmVqjrbxd5LCUjUHobYzI3zZyX9qDVGgu+dHmr gV6X2n56FAJcFt+bBz143ag1dR7dAycnj2QqnFzJg9FIigPIrF5Ytu/5fAilTj0Q0Lal0LbLG7nNv NoG+DNj1NlXesyvE+qBUsQZjsCNPYfdLLS0woJmIhMCILNkXiCgJ07tiT/eceQMZWV9M2YyHjkvZU Wk4QeUGb0PHN7i+nOMew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q99ch-008yM0-13; Tue, 13 Jun 2023 19:24:11 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q99cb-008yKY-2L for linux-arm-kernel@lists.infradead.org; Tue, 13 Jun 2023 19:24:08 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1b3ca7d007bso17941915ad.1 for ; Tue, 13 Jun 2023 12:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686684241; x=1689276241; 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=JTjIPDpkQa3VuoP57lMJ7BntaNSVpd5s/6n5Z5BophI=; b=BFk+KLo8AyFTwl75dvJrkMUiU5O0zBWVIuH3k1X/cMgHY+owCkN+GbwZQm98xJlt6d Eg6pHt468GyNfzv2T3adVh2PhUhofAjkRdB2N2I1Nz2lYJwZtNtROyN6Whx4xrMUTxaE bnPQigDrbnYNXENBT6muXhyfb6bwSDjoEZGWg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686684241; x=1689276241; 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=JTjIPDpkQa3VuoP57lMJ7BntaNSVpd5s/6n5Z5BophI=; b=YEozpuhS8GCYVaM2gC3CeUORhF8jTA4Dc/U+fx8u7z9xXgMuypjeWT+ZIJFOu6ekV7 /ZilsRsy0O6DS6i0J5kn7XQ+N3KwNVXqu9VaKemuKY8TeAZS2XSP03LO0e3LxrQgzB1O fkWxinZz8y/hS15mqjQHrsnqlSpfR0nlpks4f9/DkL5VedjeiExDdpkrucQLv7Wga01j 1VfT4oVrOMoCIqUZ1cMs6DD4iBHdZy6chiDx8F5E6myJptDifJi8rl5Ytfmz6W7lV744 57/fjRpF5XZ3BDfly0tRpdu4K4I3n7G4SfT5YTDM93mW4L1XRL0yX3kOLkUXP8UT9LmQ c+mA== X-Gm-Message-State: AC+VfDzPiv/UhUDcix/8qaf4bU//pCovUqKz1o70b5sk4C6uAZN/iGwD 7OoliOEmTJwrXzjLtJfhWKYwmA== X-Google-Smtp-Source: ACHHUZ5Xio21b+oMrhdUH1aEbO1e1KiOm+5dj7FNMCh/97l936Jqv0lrNd7Ra4B1IM3emNt/o72jiw== X-Received: by 2002:a17:902:e74c:b0:1b0:e0a:b7ab with SMTP id p12-20020a170902e74c00b001b00e0ab7abmr9998246plf.31.1686684241406; Tue, 13 Jun 2023 12:24:01 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id d15-20020a170902cecf00b001ab09f5ca61sm10631831plg.55.2023.06.13.12.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 12:24:00 -0700 (PDT) Date: Tue, 13 Jun 2023 12:23:59 -0700 From: Kees Cook To: Azeem Shaikh Cc: Jakub Kicinski , linux-hardening@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] net/mediatek: strlcpy withreturn Message-ID: <202306131223.F8F403D386@keescook> References: <20230613003458.3538812-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230613003458.3538812-1-azeemshaikh38@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230613_122405_779936_E1E5A80E X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 13, 2023 at 12:34:57AM +0000, Azeem Shaikh wrote: > strlcpy() reads the entire source buffer first. > This read may exceed the destination size limit. > This is both inefficient and can lead to linear read > overflows if a source string is not NUL-terminated [1]. > In an effort to remove strlcpy() completely [2], replace > strlcpy() here with strscpy(). > > Direct replacement is safe here since DEV_ASSIGN is only used by > TRACE macros and the return values are ignored. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > [2] https://github.com/KSPP/linux/issues/89 > > Signed-off-by: Azeem Shaikh Yup double-checked the users of the macros. Looks good to me. Reviewed-by: Kees Cook -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel