Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3551509rwo; Mon, 24 Jul 2023 12:49:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlEEX7nm3/JZSKh2p/5OkTtC0VdGWUBzaHtFsqOAB2pgNWCQ7eTkRiKLGRGLPKkIiIipTCtO X-Received: by 2002:a05:6402:2039:b0:522:1e24:afb6 with SMTP id ay25-20020a056402203900b005221e24afb6mr6300109edb.0.1690228171861; Mon, 24 Jul 2023 12:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690228171; cv=none; d=google.com; s=arc-20160816; b=o3LXTr+ehb3WZ+tefU4quOL2MDPDzAA34BeUAhJ+7+8gSkaY93dcBlnvtKELkPsFV1 GP43YaMIKrOD48w0y/XT03vbaQ4fkdymVZJbOZQjq/DE4gCHoU0NTef+KqA6ASOEyn5L WhDdkuaUh6XSn2288OjejaYujBnHoRHI9pfWJ6ez0bm51uv0y3Hj6TVavPLysiZlt31b ZuQrvGYGgCCyW/5/nj8nIysaUa7eI1SF+iFHXN0oKhkbPLV1/UY98FrNjp1lKIstt1Mu dC7EGQRZE3ioIL/KPAEGJ4mjeMVGxS0UQUP7DOFU/JYv2Uu39zAJhBrKGKDJ17Q8GsM5 miRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=0FujArfu7E/KTN1mlKzztQlR74xZ/uhX/VqwNimO1ag=; fh=5N1VjZjcRGZ4x2QGabxTeRF98NRcGc7v7sD9ti9/bJ0=; b=MYWehAPv6TVgl8p4k24W3Hs+L6N8CvbTjRUNGQGPFSBrAJdKm2BetMGBFQd7XsoQjS bzkW93YMXQdXV8IDCy/Corse4QOHvafCcB4GLgGPc4M2GSnQG2BwacFzVS3N1RSzZmpJ 2tqHDUWZX4ALvuK5a17w+18W6fa5iX7kQVupg+O66fv5S3LuPsFRlVe4xOpP9wgOWfsa T45vGuDN6gpk62PsGCtFX9e/zcLF2Zo6GI9QZpZnU0k/u5p2/UsnrRedXevRwVs1C4Nl 7HgIMtVBwA3hjwORX7z+k3OEPSFMEeQ7GMnmqOSANtZZO+MZ5zQkDxt9lX068csbEOoD Ik+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=dlXIyuHh; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u7-20020aa7d0c7000000b0051dd5a53314si6817466edo.68.2023.07.24.12.49.07; Mon, 24 Jul 2023 12:49:31 -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=@infradead.org header.s=bombadil.20210309 header.b=dlXIyuHh; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbjGXT3L (ORCPT + 99 others); Mon, 24 Jul 2023 15:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjGXT3K (ORCPT ); Mon, 24 Jul 2023 15:29:10 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C5310E4; Mon, 24 Jul 2023 12:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0FujArfu7E/KTN1mlKzztQlR74xZ/uhX/VqwNimO1ag=; b=dlXIyuHhxR9o3f2zUpEs3clL+2 yzn7QTM9lrwYRgpVfZVgAXPrgO1PTsytDOUcOQcMZctsNWdpdIdrqr/05MByXuFHVEy9jlPFzE1Kd TMW3mo7ALcEa3zxVeNNBQ8CT1U/LlD6+Olx9bTkiOzjhFPoyhkZgywCDq9m5dLiiikSRCp61kCCKY oSuPtOTT3Kc0njtJDicDgBtX6q1SyVvaXgbmYJzW7GjEXWz6lL0+9MrlUsH5KqKL0QgtlHLJGTIML kf8FaSWP2NczzlIQFbHHWGX5fHj1xaeZKpwkcaptXSlU2Nr4lOpTS+OndPupkif8/OL3680jPtDUB D8X3p1QQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qO1Eg-005Itu-1i; Mon, 24 Jul 2023 19:28:50 +0000 Date: Mon, 24 Jul 2023 12:28:50 -0700 From: Luis Chamberlain To: Arnd Bergmann Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Steven Rostedt , Masami Hiramatsu , Arnd Bergmann , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mark Rutland , Kees Cook , Peter Zijlstra , Miguel Ojeda , Palmer Dabbelt , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-modules@vger.kernel.org Subject: Re: [PATCH 2/2] [v2] kallsyms: rework symbol lookup return codes Message-ID: References: <20230724135327.1173309-1-arnd@kernel.org> <20230724135327.1173309-2-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230724135327.1173309-2-arnd@kernel.org> Sender: Luis Chamberlain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,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 On Mon, Jul 24, 2023 at 03:53:02PM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann > > Building with W=1 in some configurations produces a false positive > warning for kallsyms: > > kernel/kallsyms.c: In function '__sprint_symbol.isra': > kernel/kallsyms.c:503:17: error: 'strcpy' source argument is the same as destination [-Werror=restrict] > 503 | strcpy(buffer, name); > | ^~~~~~~~~~~~~~~~~~~~ > > This originally showed up while building with -O3, but later started > happening in other configurations as well, depending on inlining > decisions. The underlying issue is that the local 'name' variable is > always initialized to the be the same as 'buffer' in the called functions > that fill the buffer, which gcc notices while inlining, though it could > see that the address check always skips the copy. > > The calling conventions here are rather unusual, as all of the internal > lookup functions (bpf_address_lookup, ftrace_mod_address_lookup, > ftrace_func_address_lookup, module_address_lookup and > kallsyms_lookup_buildid) already use the provided buffer and either return > the address of that buffer to indicate success, or NULL for failure, > but the callers are written to also expect an arbitrary other buffer > to be returned. > > Rework the calling conventions to return the length of the filled buffer > instead of its address, which is simpler and easier to follow as well > as avoiding the warning. Leave only the kallsyms_lookup() calling conventions > unchanged, since that is called from 16 different functions and > adapting this would be a much bigger change. > > Link: https://lore.kernel.org/all/20200107214042.855757-1-arnd@arndb.de/ > Signed-off-by: Arnd Bergmann For modules side of things: Reviewed-by: Luis Chamberlain Luis