Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10424109ybi; Thu, 11 Jul 2019 05:08:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcauctaJIR/KGrokbYWpuTRb0cczEJS8ocMnRngjFyNWkMomA5jKAbfde4GwWhDlFTcokS X-Received: by 2002:a17:90a:bf03:: with SMTP id c3mr4276106pjs.112.1562846904256; Thu, 11 Jul 2019 05:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562846904; cv=none; d=google.com; s=arc-20160816; b=WQgXvgl19hOyj3FGo2U3GCa6DuDB1aFMpfC2TQ8uf/NLSOX+YMhKc+9uWUovDGX+o9 0vnyGae8MXEo/MdKCZWr2Z+gubKu8UNhBxKjFuNYZNBa1ZLXZvkpH3znlyn6mr0xBaGE V7WsuuHSHb46mpVdPZnhBjwGcLgyrbbYZ4w5w04d4ji6VT38pWPC76pXPEY0tA8dOFxA G7nNg5qVzHznR+xPTdijWtEaCDodtawzfgPErFJ9Rn7Bze7/SZkmBYh3vROEQX+vyXhu 9Sh7sms4x6cdk2TW+bcC4n97XwUTmoI2kO+7m1mTJ9kKDpa6wtWYsttDFf4LbLykhjR9 loEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YFCxGO6KV5W4HnGiTTvC8J1Y11PoOncGzlRaAH+YitY=; b=U5TiBSjTUfrZBZJLhXI5V7dTHQOr9P8OlIvkdwskzvwQ4v3C7Drprg3+AHejFbdpIg 58HEROvYUC02TTrC3fFiUJOxr+s26DGCPzZZg3nue7CWE5tyY/P4aisWoJSbuiyNfAV9 ReGV3K/TNwSRJS0cGqQPtb2M0ZzS4dC4YppFEB7tHewD1FUrlbQioGIW3p+Ccgjhkx27 gT7JBNfU1G3eMWitpDybZTud+pvBS+hJ1+s6Z3kiUy0OWNSUSzfFbZoZ+d2COt2J0udZ e9WMR1+oI+s8ne0irWEpAXjtntT4LwnCgBFZw53hxx16dyR9SxwLLpYLvX7so7x30H1C cwFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b=gqHdZrhy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si4735813pll.279.2019.07.11.05.08.08; Thu, 11 Jul 2019 05:08:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b=gqHdZrhy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728578AbfGKMF1 (ORCPT + 99 others); Thu, 11 Jul 2019 08:05:27 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34096 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728531AbfGKMF0 (ORCPT ); Thu, 11 Jul 2019 08:05:26 -0400 Received: by mail-lj1-f196.google.com with SMTP id p17so5524885ljg.1 for ; Thu, 11 Jul 2019 05:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kinvolk.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YFCxGO6KV5W4HnGiTTvC8J1Y11PoOncGzlRaAH+YitY=; b=gqHdZrhydiZVnlVQy4pXamlOAmehSSQyqPVvYp1XIWDNaJIflXL/y4ej78BNjvmDaT wjE4YsuM3hdrMdUB0VaTKvxtXl2poyXQwc/m8RN1z/8tvvHBETHl3ZTSZM6RniSAVqwV pZOz19hsGlInW+f5P9Q5Ejvr2x52m5Xtb4Ick= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YFCxGO6KV5W4HnGiTTvC8J1Y11PoOncGzlRaAH+YitY=; b=VNE8sdxNuTb/z2pBe3eg4ytIhm3iwonB70siYw4fFArY4TWekOuM6K+oi0gTbHqCz+ PP//OQn2U36RbvOIfv0jJsapER7yLOpFRsVyufp89UqckcCYmkNsr9mFOPm1pkPjsBro 7u1ZxylEDPVBm6BrSVmhx3JNMtvkgpEBcWewwnpooohkt1MsBiCqRr82GiC/i5tkH5U4 Hm1koCvzvwWXT/mHSpW000xrf2Csoh30I+ZYr2+RtGiiSwQRwsKDuVM6VcQHD3Geulou wDQXR+yk05EvFxyPCCtSWWbv492gxZBGnOZPru4Vx5+Mk+WBVX9TgtXNCP2EBYcRcvw1 z8UA== X-Gm-Message-State: APjAAAUf6bA58dasP2yM5fPExN9Cp7Th+LuB6XzRT5e+RqOMKGMmBauz nzvPgZYhtQ8yv/xaah3Fe1CbEN5FTbUJUMqmNvMBcw== X-Received: by 2002:a2e:9754:: with SMTP id f20mr2286572ljj.151.1562846722686; Thu, 11 Jul 2019 05:05:22 -0700 (PDT) MIME-Version: 1.0 References: <20190708163121.18477-1-krzesimir@kinvolk.io> <20190708163121.18477-4-krzesimir@kinvolk.io> In-Reply-To: From: Krzesimir Nowak Date: Thu, 11 Jul 2019 14:05:11 +0200 Message-ID: Subject: Re: [bpf-next v3 03/12] selftests/bpf: Avoid another case of errno clobbering To: Andrii Nakryiko Cc: open list , Alban Crequy , =?UTF-8?Q?Iago_L=C3=B3pez_Galeiras?= , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Networking , bpf , xdp-newbies@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 11, 2019 at 1:57 AM Andrii Nakryiko wrote: > > On Mon, Jul 8, 2019 at 3:43 PM Krzesimir Nowak wro= te: > > > > Commit 8184d44c9a57 ("selftests/bpf: skip verifier tests for > > unsupported program types") added a check for an unsupported program > > type. The function doing it changes errno, so test_verifier should > > save it before calling it if test_verifier wants to print a reason why > > verifying a BPF program of a supported type failed. > > > > Changes since v2: > > - Move the declaration to fit the reverse christmas tree style. > > > > Fixes: 8184d44c9a57 ("selftests/bpf: skip verifier tests for unsupporte= d program types") > > Cc: Stanislav Fomichev > > Signed-off-by: Krzesimir Nowak > > --- > > Acked-by: Andrii Nakryiko > > > tools/testing/selftests/bpf/test_verifier.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testin= g/selftests/bpf/test_verifier.c > > index 3fe126e0083b..c7541f572932 100644 > > --- a/tools/testing/selftests/bpf/test_verifier.c > > +++ b/tools/testing/selftests/bpf/test_verifier.c > > @@ -864,6 +864,7 @@ static void do_test_single(struct bpf_test *test, b= ool unpriv, > > int run_errs, run_successes; > > int map_fds[MAX_NR_MAPS]; > > const char *expected_err; > > + int saved_errno; > > int fixup_skips; > > nit: combine those ints? or even with i and err below as well? Will do. > > > __u32 pflags; > > int i, err; > > @@ -894,6 +895,7 @@ static void do_test_single(struct bpf_test *test, b= ool unpriv, > > pflags |=3D BPF_F_ANY_ALIGNMENT; > > fd_prog =3D bpf_verify_program(prog_type, prog, prog_len, pflag= s, > > "GPL", 0, bpf_vlog, sizeof(bpf_vlo= g), 4); > > + saved_errno =3D errno; > > if (fd_prog < 0 && !bpf_probe_prog_type(prog_type, 0)) { > > printf("SKIP (unsupported program type %d)\n", prog_typ= e); > > skips++; > > @@ -910,7 +912,7 @@ static void do_test_single(struct bpf_test *test, b= ool unpriv, > > if (expected_ret =3D=3D ACCEPT) { > > if (fd_prog < 0) { > > printf("FAIL\nFailed to load prog '%s'!\n", > > - strerror(errno)); > > + strerror(saved_errno)); > > goto fail_log; > > } > > #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS > > -- > > 2.20.1 > > --=20 Kinvolk GmbH | Adalbertstr.6a, 10999 Berlin | tel: +491755589364 Gesch=C3=A4ftsf=C3=BChrer/Directors: Alban Crequy, Chris K=C3=BChl, Iago L= =C3=B3pez Galeiras Registergericht/Court of registration: Amtsgericht Charlottenburg Registernummer/Registration number: HRB 171414 B Ust-ID-Nummer/VAT ID number: DE302207000