Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp201476iob; Mon, 2 May 2022 17:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsnhmUTeGr2z8bpch/3jZImvYsYDS2chhx1UsgZx+NtTI+Q6s0NS0Hauzhrjvpovt4pe2k X-Received: by 2002:a17:90a:e7ca:b0:1dc:4aeb:be5d with SMTP id kb10-20020a17090ae7ca00b001dc4aebbe5dmr1783776pjb.185.1651536258199; Mon, 02 May 2022 17:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651536258; cv=none; d=google.com; s=arc-20160816; b=zWmSZtjYIdaUxzu1JIJT2iTlID4CqvLtTvYMb72lgqIdBquYgAT4hpC6kId3vy2vFv 0MWwN/yPVUGeAZKExoQoW8PEsPGGckVQvDbVm2ca3qCZdZu9fQu+lA/iauQ3/a6OQNyS SPWpbcuclhoL4jWEm9GvL1SuTXqHN4hoFw+ppd+W8K4+WQdzLjzVlwdUPbm9pU9l3cfn dKOkCQjF6HU0ZNnIoarwM21CO6L/um2Ceac8wZQvotmyLf8rMv+KmBBZkk5Vr98K8+X9 YLFpJospga26t8oVLBwqUBZP5r2WcdrWJMGebNMllpXLlKTpPbKX8uYNIHH7XRxeVp+f 0ZLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Cq/bV6RK8FDU8B3/J6PiOX4oHk2MVdSUsZvuBXDrwOw=; b=TP6GH3Bja3t9V0AFSJrDB0mqZjE2OpeTum4FnzERGS13uVRJt2w1pnoAAIQi/u8MkU xJSLu1xySkhKO9DKbSfCgf3MGMJ/lkClwaodBERDUWfluBg5MsyPxXrbsln5KG2EvB/7 VMLL6WTDxTKbEwiRjAOQpcrfinm/AQ2vAUMSTAxc15ZXZZuySLYwUEWN8LUDeHebC9Bt d12D1C9VgZGY4JUJXsUpRAGzJz4W0SMvjqVhxvXxEiYa/hu4gmZlBVSvLkwG/eD9pIUy VFnobMdhInJYqSENNzNx9EE7X2cJMovH4xvFNv5zTQD/5GpwEMYDtv7mHobZihwF6Ocu 9HAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q8XpaOT9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w186-20020a6382c3000000b003c1735355e6si12489398pgd.214.2022.05.02.17.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:04:18 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q8XpaOT9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 62FA0344ED; Mon, 2 May 2022 17:04:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382267AbiD3H2I (ORCPT + 99 others); Sat, 30 Apr 2022 03:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382259AbiD3H2H (ORCPT ); Sat, 30 Apr 2022 03:28:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B44D784EE9 for ; Sat, 30 Apr 2022 00:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651303485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Cq/bV6RK8FDU8B3/J6PiOX4oHk2MVdSUsZvuBXDrwOw=; b=Q8XpaOT9QsBC/R6rWy5qZsA/cX2B03/PCeW0zIkafROVXujic56jDWgfZoZQPWCgRzetfJ zSfMa1Yn6lJwtrtQ6fL3NmhgEwFO/U/Ms1udY3GFrwk6QGvjrRLSr/0oQLTzGsy8s1nvOF SgH5dKzHU9zFILKeSLJS6nVoazKHc8w= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-VGvSndeuMoKY1yc9MoL7TQ-1; Sat, 30 Apr 2022 03:24:44 -0400 X-MC-Unique: VGvSndeuMoKY1yc9MoL7TQ-1 Received: by mail-pf1-f198.google.com with SMTP id g5-20020a62e305000000b0050d2dba0c5dso5226418pfh.8 for ; Sat, 30 Apr 2022 00:24:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Cq/bV6RK8FDU8B3/J6PiOX4oHk2MVdSUsZvuBXDrwOw=; b=UNrmdMN3OAWcakNdNrcrqzqr8/giVAOKvd/sNa+TH48P21SwSWSW+nFWv4VE5q9bpF ZOKdFuRxqvlfByyiAVEAsPt36DYrqaHnduxI698Ofu87tyPdoPZiP6qcnwv8ILm7sbp5 Y3bAKGxZGq0b3rC4nTZonFPuiClI6i24nyFbo5pKsnH3y0aTIDAZQqdDkPUp5ptweUqs GdckY1Ia5TMtzRTF5VX2tmykObGg3j5si6TrHc9wGl99j79Cs+d43gAVMuSWaZ7mQxlU HvKGgE7Wg9icRCuOzJKxek9sp6hKoIsIToiRsVmLA1xbqStUHs2mGyFQufZ+jjTok53u 3nOg== X-Gm-Message-State: AOAM532uiIzDEEYn23gkYW1AvRQveabk4ffZ416ZgOWeMIQXyjFekG3q 1Na/hldi4Ve21TdlT9ce+B3y8vDrRbK0HfEAy4ta6bn37bwGDLYpo09F8tL5yIMANCfpsxxPn1L A17RksD2haW12SEPFolXwAT8zatapQJqxfJqJkUwc X-Received: by 2002:a17:902:e012:b0:15d:53:61ff with SMTP id o18-20020a170902e01200b0015d005361ffmr2857432plo.73.1651303483089; Sat, 30 Apr 2022 00:24:43 -0700 (PDT) X-Received: by 2002:a17:902:e012:b0:15d:53:61ff with SMTP id o18-20020a170902e01200b0015d005361ffmr2857422plo.73.1651303482851; Sat, 30 Apr 2022 00:24:42 -0700 (PDT) MIME-Version: 1.0 References: <20220421140740.459558-1-benjamin.tissoires@redhat.com> <20220421140740.459558-4-benjamin.tissoires@redhat.com> <20220426041147.gwnxhcjftl2kaz6g@MBP-98dd607d3435.dhcp.thefacebook.com> In-Reply-To: From: Benjamin Tissoires Date: Sat, 30 Apr 2022 09:24:31 +0200 Message-ID: Subject: Re: [RFC bpf-next v4 3/7] error-inject: add new type that carries if the function is non sleepable To: Alexei Starovoitov Cc: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Tero Kristo , lkml , "open list:HID CORE LAYER" , bpf Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Sat, Apr 30, 2022 at 5:30 AM Alexei Starovoitov wrote: > > On Tue, Apr 26, 2022 at 12:52 AM Benjamin Tissoires > wrote: > > > > On Tue, Apr 26, 2022 at 6:11 AM Alexei Starovoitov > > wrote: > > > > > > On Thu, Apr 21, 2022 at 04:07:36PM +0200, Benjamin Tissoires wrote: > > > > When using error-injection function through bpf to change the return > > > > code, we need to know if the function is sleepable or not. > > > > > > > > Currently the code assumes that all error-inject functions are sleepable, > > > > except for a few selected of them, hardcoded in kernel/bpf/verifier.c > > > > > > > > Add a new flag to error-inject so we can code that information where the > > > > function is declared. > > > > > > > > Signed-off-by: Benjamin Tissoires > > > > > > > > --- > > > > > > > > new in v4: > > > > - another approach would be to define a new kfunc_set, and register > > > > it with btf. But in that case, what program type would we use? > > > > BPF_PROG_TYPE_UNSPEC? > > > > - also note that maybe we should consider all of the functions > > > > non-sleepable and only mark some as sleepable. IMO it makes more > > > > sense to be more restrictive by default. > > > > > > I think the approach in this patch is fine. > > > We didn't have issues with check_non_sleepable_error_inject() so far, > > > so I wouldn't start refactoring it. > > > > OK... though I can't help but thinking that adding a new > > error-inject.h enum value is going to be bad, because it's an API > > change, and users might not expect NS_ERRNO. > > Not sure about api concern. This is the kernel internal tag. > bpf progs are not aware of them. The functions can change > from sleepable to non-sleepable too. > allow_error_inject can be removed. And so on. > > > OTOH, if we had a new kfunc_set, we keep the existing error-inject API > > in place with all the variants and we just teach the verifier that the > > function is non sleepable. > ... > > IIUC, the kfunc_set approach would solve that, no? > > Makes sense. Let's figure out an extensible kfunc_set approach > that is not centralized in verifier.c > OK, I'll work on this in v5. But I need to rethink the whole sleepable/non-sleepable definitions for my use case, because I have now a clear separation between not sleepable context (in fentry/fexit/fmod_ret) and sleepable context (in SEC("syscall")), so maybe the whole thing is not really required. Cheers, Benjamin