Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp391749yba; Thu, 16 May 2019 02:34:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXQizm1HMmQ8UVz/cFxuVjhNot4B/yASElgUrJE2ikXno9jYybP5H47FG1fkk8L0vozyw8 X-Received: by 2002:a63:fb02:: with SMTP id o2mr48087668pgh.357.1557999253298; Thu, 16 May 2019 02:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557999253; cv=none; d=google.com; s=arc-20160816; b=UKZdOp5xONMBWOCry9/UNE8SOQtOYCHchXS5QCHh3DMPczkWRlsT6yxTlV1aE1JTwJ 3/bBXsdgrdwIO1nQKo06c1eW9DanwiyZpbARwH0s1vpJ0drDv7d5bHHTzmwbMZOGOpiI eiG8BwEdHQB1fSfWTUlynVgziz8/q3SQnFVyeVDWNKYbcXCBH3d+zdo7qy9XUOi17kV0 31RYrDktkp3c1TOkquwGfs+7bSGe7Nt85XuC0ekTzX4tFVYc35sQHIU7pOR2AcL/pGlP Lqs5RHm9kRHEQebjGqe6DnnwfyzE57xkteeoMK2z1LGM7QOWMgl1Gaao/AEat2FwOtBT 61SA== 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=scP5pJngsU9KJ/PvOc7PkGn3ctf+6jypjet7NqrKqmA=; b=f5ZxjbGke+UeMzYQFkdCC1Qw5GFz5GIU2Bu+pd25xcY9urcJ258IHdqMhDt1Wnaq7g c62Zv/sZN8FU0h9sZDRPd+eTqqndKJtxD9acpSO14Xzvbb1FTKKnlrBMqwtze84+YEAO RmLK7Z6ffywjXGz0u1PqrNXppg2i5SQAoHe74qygc7OslKSQiFmrBMqDI+sPnew4EwsD eTANLy05eX9v6LEljPmfCXcV/2lpkgPXo9j2PmqC23yPx31zc+1YCU27te6YGnRjZjT8 GFcazRQiUmWztPLp/o9o0guk5w3h2BGF6N3Wf3CaUO10dmPQ2Ahmx9CeW4xI9INLTABw fbbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b=BQLpv+w5; 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 m8si4411223pgp.68.2019.05.16.02.33.58; Thu, 16 May 2019 02:34:13 -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=BQLpv+w5; 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 S1727109AbfEPJbR (ORCPT + 99 others); Thu, 16 May 2019 05:31:17 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38327 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbfEPJbR (ORCPT ); Thu, 16 May 2019 05:31:17 -0400 Received: by mail-lj1-f193.google.com with SMTP id 14so2453889ljj.5 for ; Thu, 16 May 2019 02:31:15 -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=scP5pJngsU9KJ/PvOc7PkGn3ctf+6jypjet7NqrKqmA=; b=BQLpv+w5ngjqKJjwCym2ZWvuhIyTXrQXe/cH0kkyhS3AsX/8P4b2Uup0CJ63BRhZw6 0f6scy9IOKguNgia+DARy/Pgsf9ihVfdo+x2VptKljZpgjcpQh2K6bqp5DpPLMTCR1Ms G/Ir19EM1+91HaPREMy7MEtETZbC78Ge1OCtU= 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=scP5pJngsU9KJ/PvOc7PkGn3ctf+6jypjet7NqrKqmA=; b=bPa+AqhTIfWtNidjxjz2G6x5crJnlKicPA66PdMXTc7FiCErXrUNI+4PhODdG9nccN 7fXMZydNiphM8nyTQqwRJFqcFiB0Mf9KXOuQ60X0B5Cc9PNeUWiottoupNfbO5bowIFz ZDpNRk2kVycaI77+hbnm9TaIZAJD70Yutc7JwRNYPYkLFBGnFkMHbqhzI2NLqT/1R5jG CzgdwsDeLuFD7U0nZw/0gHRdoRplJgOcaTmUb0n3f2OLZNm9EUEu09euzCjMyLCi7QAR VyRX6gntEQdrZkMPlsHXdNYa1Q8K2LMBlqL7Vr38mmJrZiTIzshjR90Jx/olJjLLBXJn a0oQ== X-Gm-Message-State: APjAAAUDewxE+nGdgiVnF9mLqHjdx9STD2YJe9y8SnXjOHdMTUQJjyOb Js5IbVGZzFZg2Aqvv2YujP7jhsdqEthZodNWhidkoQ== X-Received: by 2002:a2e:74f:: with SMTP id i15mr22844265ljd.156.1557999075116; Thu, 16 May 2019 02:31:15 -0700 (PDT) MIME-Version: 1.0 References: <20190515134731.12611-1-krzesimir@kinvolk.io> <20190515134731.12611-4-krzesimir@kinvolk.io> <20190515145037.6918f626@cakuba.netronome.com> In-Reply-To: <20190515145037.6918f626@cakuba.netronome.com> From: Krzesimir Nowak Date: Thu, 16 May 2019 11:31:04 +0200 Message-ID: Subject: Re: [PATCH bpf v1 3/3] selftests/bpf: Avoid a clobbering of errno To: Jakub Kicinski Cc: bpf@vger.kernel.org, =?UTF-8?Q?Iago_L=C3=B3pez_Galeiras?= , "Alban Crequy (Kinvolk)" , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrey Ignatov , Jiong Wang , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@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 Wed, May 15, 2019 at 11:51 PM Jakub Kicinski wrote: > > On Wed, 15 May 2019 15:47:28 +0200, Krzesimir Nowak wrote: > > Save errno right after bpf_prog_test_run returns, so we later check > > the error code actually set by bpf_prog_test_run, not by some libcap > > function. > > > > Cc: Jakub Kicinski > > Fixes: 5a8d5209ac022 ("selftests: bpf: add trivial JSET tests") > > This commit (of mine) just moved this code into a helper, the bug is > older: > > Fixes: 832c6f2c29ec ("bpf: test make sure to run unpriv test cases in tes= t_verifier") Oops, ok. Will fix it. Thanks. > > > 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/testin= g/selftests/bpf/test_verifier.c > > index bf0da03f593b..514e17246396 100644 > > --- a/tools/testing/selftests/bpf/test_verifier.c > > +++ b/tools/testing/selftests/bpf/test_verifier.c > > @@ -818,15 +818,17 @@ static int do_prog_test_run(int fd_prog, bool unp= riv, uint32_t expected_val, > > __u32 size_tmp =3D sizeof(tmp); > > uint32_t retval; > > int err; > > + int saved_errno; > > > > if (unpriv) > > set_admin(true); > > err =3D bpf_prog_test_run(fd_prog, 1, data, size_data, > > tmp, &size_tmp, &retval, NULL); > > + saved_errno =3D errno; > > if (unpriv) > > set_admin(false); > > if (err) { > > - switch (errno) { > > + switch (saved_errno) { > > case 524/*ENOTSUPP*/: > > printf("Did not run the program (not supported) "= ); > > return 0; > --=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