Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2165176rwb; Sat, 29 Jul 2023 00:54:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHV8+SQDKfVZ9ztzbYyurhAUzQncADQ9edAQJkfb3mdHXshd/J87A2FFfxtG9ISHeW8O3NK X-Received: by 2002:a17:903:41c4:b0:1b8:9b74:636b with SMTP id u4-20020a17090341c400b001b89b74636bmr4330298ple.68.1690617264316; Sat, 29 Jul 2023 00:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690617264; cv=none; d=google.com; s=arc-20160816; b=wuwpeyd7ibWD+1TrvAIbmguqqzUIc/4ZYBheTqq0dMDfYroOL+agJUcjjZjReqSb5p GdxUcQcfbPS1aBpGRdi0xQcWTH96RyW2chBkuavkl5u/cKB9nPxIX4XS6HXogJgiVoKZ eYIxMIbgJx/YTPi7aYMxC0ZBk0wyE3QRF57EwESdn8QGmQdfwXq/S7FKDM6nRn+AhZTG CzP+rdnMw/5meip5AyRY1PTjLGXFpcqfa24GVLf2wBiDoEoARwVXl9CkBqAjpVYoC2lb pRy7XZ49OfJUqqVjOpCIBLVLu2+Eh2Lcq2/XoYTnZyAHex7U8DAHw8TBxguLaX5EYS19 DlLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kMUwEAUayr3MQf/dfvByT6zVhORAHq8/IduiDVP6zG8=; fh=6+g7FBg/nYlRwy/mi6a/+eD3T2jhTD2qFD8VpSppqlw=; b=ikVNtVDfCDnOdOkcmdYvsDCoHVC5ZTwhzJmO/QC3gAKmeDWxjdAwVPDkTBduTyK+DM qSStBaYBFEkRkowiEQ5+B4boq7Q7X4rqkM+ChQ+HqNlwXUu+SHalYh/ZiJj8fkLEIZce dKxcU28C2HFCfAhcmS1uvreKgnBUAXBk5dmtNCzqxB6G2NlbjDYkGTsas8RUCN0WCz27 bqBDvdtOHyTzTlQsF++durgFs3If7tQjtYa3e/LjfM9BXGZM/rWgdile3WJEltPbyCQN LCClBrxcChBYkbp3kcFhnpwX04CG3AJZXrjwYA1zo2DFwZlumSsQ4Gnz5FkP+Q4rteED 8f6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=az+FzhTy; 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 u11-20020a6540cb000000b00563f8e3fca8si4080165pgp.49.2023.07.29.00.54.12; Sat, 29 Jul 2023 00:54:24 -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=@kernel.org header.s=k20201202 header.b=az+FzhTy; 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 S236506AbjG2G7U (ORCPT + 99 others); Sat, 29 Jul 2023 02:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjG2G7S (ORCPT ); Sat, 29 Jul 2023 02:59:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD18649EB; Fri, 28 Jul 2023 23:59:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1CA1660766; Sat, 29 Jul 2023 06:59:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 829E0C433C7; Sat, 29 Jul 2023 06:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690613954; bh=pH61JHyCnyY9RStw/F9+va8ZXuOwbbiiebLPqill1n0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=az+FzhTyIRfsDg6cCIJSp5wA/lSM6MNsVviNmMELnJGq4g+euILuU+o86NPIcamuy GOR2GFFlvzrKdj5Mv/aDJMCJ3eAz2oNEnDcYyNiM37j/SoSSSAy0nRZTBCJ4EGUQWu H0CURCOOE3VGyn2RYQip0d3Aip0Tik53a7SAB/nbxS8EiicwGFs1ctbOAM28pqCYTJ xVPpRzJ4Nr7kA/+4Blu+nF8k6W+2WZkHfK19fdlgn7liQ5oeCAQa45YOhagx9Ou1dW +BYz/RC3nbbW/wJRrNTS47epuws2A+b6rxYeNWUa5SYiSlEaqPLUctkPI9lWD5ilYg 81tvVHsrIURiQ== Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-56368c40e8eso1962291eaf.0; Fri, 28 Jul 2023 23:59:14 -0700 (PDT) X-Gm-Message-State: ABy/qLYiShmAZU+PBo/wBeprX3I6jX7aDRQrbdrI8ZVoyiPbtxwYZq+f 0PcjYau5qXWbMNl87P7eLX8Ef5oMWRRopygk1SU= X-Received: by 2002:a4a:3457:0:b0:566:f9ff:57f with SMTP id n23-20020a4a3457000000b00566f9ff057fmr4447885oof.8.1690613953808; Fri, 28 Jul 2023 23:59:13 -0700 (PDT) MIME-Version: 1.0 References: <20230725105827.1119167-1-james.clark@arm.com> In-Reply-To: <20230725105827.1119167-1-james.clark@arm.com> From: Masahiro Yamada Date: Sat, 29 Jul 2023 15:58:37 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] scripts/kallsyms: Fix build failure by setting errno before calling getline() To: James Clark Cc: linux-kbuild@vger.kernel.org, miguel.ojeda.sandonis@gmail.com, linux-kernel@vger.kernel.org, Miguel Ojeda , Kees Cook , Zhen Lei , Greg Kroah-Hartman , Arnd Bergmann , Boqun Feng , Nicolas Schier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Tue, Jul 25, 2023 at 7:58=E2=80=AFPM James Clark w= rote: > > getline() returns -1 at EOF as well as on error. It also doesn't set > errno to 0 on success, so initialize it to 0 before using errno to check > for an error condition. See the paragraph here [1]: > > For some system calls and library functions (e.g., getpriority(2)), > -1 is a valid return on success. In such cases, a successful return > can be distinguished from an error return by setting errno to zero > before the call, and then, if the call returns a status that indicates > that an error may have occurred, checking to see if errno has a > nonzero value. > > Bear has a bug [2] that launches processes with errno set and causes the > following build failure: > > $ bear -- make LLVM=3D1 > ... > LD .tmp_vmlinux.kallsyms1 > NM .tmp_vmlinux.kallsyms1.syms > KSYMS .tmp_vmlinux.kallsyms1.S > read_symbol: Invalid argument > > [1]: https://linux.die.net/man/3/errno > [2]: https://github.com/rizsotto/Bear/issues/469 > > Fixes: 1c975da56a6f ("scripts/kallsyms: remove KSYM_NAME_LEN_BUFFER") > Reviewed-by: Miguel Ojeda > Signed-off-by: James Clark Applied to linux-kbuild/fixes. Thanks. > --- > scripts/kallsyms.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c > index 16c87938b316..653b92f6d4c8 100644 > --- a/scripts/kallsyms.c > +++ b/scripts/kallsyms.c > @@ -129,6 +129,7 @@ static struct sym_entry *read_symbol(FILE *in, char *= *buf, size_t *buf_len) > ssize_t readlen; > struct sym_entry *sym; > > + errno =3D 0; > readlen =3D getline(buf, buf_len, in); > if (readlen < 0) { > if (errno) { > -- > 2.34.1 > --=20 Best Regards Masahiro Yamada