Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4049719ybd; Tue, 25 Jun 2019 13:08:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0Ws5yanl0nU+1XSgZY/E3P/8PxKB7n14nmSkjb4ox3Na7HHjHsOCGOZXTVVRUgq469UjD X-Received: by 2002:a17:90a:cd04:: with SMTP id d4mr730146pju.128.1561493330372; Tue, 25 Jun 2019 13:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561493330; cv=none; d=google.com; s=arc-20160816; b=SJrPkV40XMWNY3jP6vQEHTHkiXSMQiJ4z2fPFo0erLANo/mJLL/95n2y38in2TeDkL aNDlZujOXqUQF8/q3q7IA0RzilLTAWnFWZePVkgec2lP72P9qlBxYIz1SMpGYhjkBgSE j3WZZntJrGvsC1NoLqKz9yXgQ7FdfXLQfRsdmt5E+opPmnXlGlJQrtyFmn+zCqG928/m 3HpbivYX4J7AzuoDLTiAJPRDCdwSzUSe3F9f5x+DXpXR6MxDlIZripA+RPW+6s4csYUW Rnn1ayQdGw7N62SM3W0Pm9ROtpaQN07JyuiIgjReHxlZxA6rHnTGMd0Lj7SZ06IX9erG S32Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZmfgUvSKsxGJWxDPJZxJdLCc4A053/l+NMKJ98odJj0=; b=kHTjzp937epgKBeN2Ru7k4n52eXonyCOlQ3AzLwCmzkpyjnFmR51G5fb+frWuzX3r9 NK1eJCYLlE3y4No+L46jam6pekvnIozGeu8LknNJkuiHiBrCBKi/GgrzJ9jxUZIX1bLN Jy2zzSRJzcz7tF46lZwWgxkYZ0ecWehZGCBVdNy3UEdZFbPv5lm+bbYPqUarh5En6q/P Ail33Yquimve5Ws6em1mPZR3Eqoxya8N2jzFWR56y0DUCRHA6DjJ+LDriNtJq2ebCzcg j/w6Uw2YWdQ3T3HBguGofvz/X1DVkCYDPy79QMBnaLGw5Mm90EUQzP5DsshNSDehqNwY UmeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fomichev-me.20150623.gappssmtp.com header.s=20150623 header.b=FKNudjZn; 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 t19si73753pjr.68.2019.06.25.13.08.34; Tue, 25 Jun 2019 13:08:50 -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=@fomichev-me.20150623.gappssmtp.com header.s=20150623 header.b=FKNudjZn; 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 S1727034AbfFYUI0 (ORCPT + 99 others); Tue, 25 Jun 2019 16:08:26 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38468 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfFYUIZ (ORCPT ); Tue, 25 Jun 2019 16:08:25 -0400 Received: by mail-pl1-f196.google.com with SMTP id g4so41205plb.5 for ; Tue, 25 Jun 2019 13:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZmfgUvSKsxGJWxDPJZxJdLCc4A053/l+NMKJ98odJj0=; b=FKNudjZnwyh6DfF+62stYSAzQF+mywGHpH8+TPPM4J2Cm7My+57LlQIULAK+LJMmh+ hzA7KJVqKeUNy+hggsgi+CzqXp1rtLNT2IMfKa1MCz/KBU0hlMSBGlqXdIPVg2Rghe4V Nfc08Uh1YLQzxXTeGCTq69cbNy8BpNZy04XgpssT7EWkoK50h8jHBT2n5cly9cMFYnaq WB0P0OsNarW/rVixB5+oVE/LK4JKmjpQwAzHyMMH/YYefwPQwUmvoaxqtzJpezjYlXG3 cPkXQccDCDOIcE3K5qBdOU9LKydjmxrwBirEpIJaKFfsy8P7qbVHLavbcMDK2JEM3elB VY0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZmfgUvSKsxGJWxDPJZxJdLCc4A053/l+NMKJ98odJj0=; b=iiMeCz2qN9wamuG9eWBS/ZmmSz914hCb5nchbqLAZl9L33ZwzHK+uzpXyUIe0amQam kMd5G+xcxM2lRdpaOIQ58R1D6FPi7zuJqUQ/05QQoMqX8MLlCOy1ZScBYneoqL/NsDp1 JQXVehPQeVcY+4szp5shHrSHVIzgnOgxk68othtiBPeD3vuMToB/nk0DGPN2o20vOahx VY2MfKUlaMHtOpOR2aikKbDr7mLk5bjiybXQd7FJjaILFzlW+QWAhqvtIuKD89P0Awm3 vRf9npiJHqXdj7jlrn5Fg9rfX6pWKs4JvxlDA1SCDbFbjx/XaBMXHN+O8t/BfrmcasFc Crtg== X-Gm-Message-State: APjAAAWZaAXWVY3IygSnXL2sjOfdsUbaoyXJb69I+mAiMdWsTCfMdc9Q 2MMINB6mYrIhLpSQmy/yetcWxg== X-Received: by 2002:a17:902:7894:: with SMTP id q20mr471120pll.339.1561493305108; Tue, 25 Jun 2019 13:08:25 -0700 (PDT) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id f88sm81478pjg.5.2019.06.25.13.08.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 13:08:24 -0700 (PDT) Date: Tue, 25 Jun 2019 13:08:23 -0700 From: Stanislav Fomichev To: Krzesimir Nowak Cc: netdev@vger.kernel.org, Alban Crequy , Iago =?iso-8859-1?Q?L=F3pez?= Galeiras , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Stanislav Fomichev Subject: Re: [bpf-next v2 03/10] selftests/bpf: Avoid another case of errno clobbering Message-ID: <20190625200823.GB10487@mini-arch> References: <20190625194215.14927-1-krzesimir@kinvolk.io> <20190625194215.14927-4-krzesimir@kinvolk.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190625194215.14927-4-krzesimir@kinvolk.io> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/25, Krzesimir Nowak wrote: > 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. > > Fixes: 8184d44c9a57 ("selftests/bpf: skip verifier tests for unsupported program types") > Cc: Stanislav Fomichev > Signed-off-by: Krzesimir Nowak > --- > 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/testing/selftests/bpf/test_verifier.c > index 12589da13487..779e30b96ded 100644 > --- a/tools/testing/selftests/bpf/test_verifier.c > +++ b/tools/testing/selftests/bpf/test_verifier.c > @@ -867,6 +867,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, > int fixup_skips; > __u32 pflags; > int i, err; > + int saved_errno; Reverse Christmas tree. Otherwise LGTM. > > for (i = 0; i < MAX_NR_MAPS; i++) > map_fds[i] = -1; > @@ -894,6 +895,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, > pflags |= BPF_F_ANY_ALIGNMENT; > fd_prog = bpf_verify_program(prog_type, prog, prog_len, pflags, > "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 4); > + saved_errno = errno; > if (fd_prog < 0 && !bpf_probe_prog_type(prog_type, 0)) { > printf("SKIP (unsupported program type %d)\n", prog_type); > skips++; > @@ -910,7 +912,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, > if (expected_ret == 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 >