Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp932600rwd; Thu, 8 Jun 2023 09:34:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xEe6Bku9u8ll1TM1/1KDwW3uca93khksAk9Qp67gsV5wHdrpcOfKi9FRK/x9J3X972yvq X-Received: by 2002:a05:6a00:2e01:b0:653:a9ac:44c with SMTP id fc1-20020a056a002e0100b00653a9ac044cmr6468776pfb.11.1686242089875; Thu, 08 Jun 2023 09:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686242089; cv=none; d=google.com; s=arc-20160816; b=jf86q1QX3Gi/we1QIfiwfWXw79j42tZDDWOs/h5FASoAxA4IQiUwGp/wHm7KSbiI/A IXVAc5UHSkW+9D87DqxrXUAvrLllubS0G6cKbPUs/YF3tSRg9UeyOtGZPyr24DGD322G qQg0JVhjOSB6hg+s3lc8DwNJPQVjdYUmFH17kHgi5mFJD9wTa53m6Ox7iRiPxUrs2wGO DSNC2ZbWyOsNP6DlruTC8WMqdXlAa1M/I+f4XoHTL0+SXQRoC1TcVw7TIUju5pti8wiE 1LCUIE2IQa7DdO5ksNys5/lPp79j1cIYIh0D5YCIqp9lzdp8MTUh2bSYB5aTPUPZtEuS 8S9Q== 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=L3eYHbt3Lra1h4IhwyjExc7YWHHEJ0+HYZYvn3NDBAE=; b=nQpWPRXcyD/zA+ujORhEAfMIOYIBvThnmxoYM1Ryc0wHbdRQNDWUHIcS+mFzBOWUcZ VlRv8jkqPrZb+kzJDQ9lqWuyCMjhN2MjorwN9PgiS4Ovv2bb4x6h3+nkB2hSEDfKvsnG q2gORJA1Du+6h4Q9zNr6bukEkwYG3lVzXPc7S++ZMi1Vto9HXGHIKeAIpbhXgIR9GxTy sL+2n0cZCdwdtkSTRvdWjiaw6cNWOWbxzgX/y9UZo/ziVBxd4/mafoKLh9cP/KM1TVJk 76UHd76dGwah9fGKK+BCc4ekCFgB701e1xf8yNVUBizyCrw3rvTiBbrMmRUYmbdCPfgH TAdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZEJf3h16; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e28-20020aa798dc000000b0064d4d472935si1075044pfm.18.2023.06.08.09.34.37; Thu, 08 Jun 2023 09:34:49 -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=@google.com header.s=20221208 header.b=ZEJf3h16; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234532AbjFHQ1b (ORCPT + 99 others); Thu, 8 Jun 2023 12:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbjFHQ1a (ORCPT ); Thu, 8 Jun 2023 12:27:30 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB231FDC for ; Thu, 8 Jun 2023 09:27:28 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2567b589d3bso462852a91.0 for ; Thu, 08 Jun 2023 09:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686241648; x=1688833648; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=L3eYHbt3Lra1h4IhwyjExc7YWHHEJ0+HYZYvn3NDBAE=; b=ZEJf3h16GMcrTLSlduQ0E82dKUprjaM9roz0jT7T7pEe7G3uVc1dE05sNT+LkTDrEC /qM3OyDEQ+QOYC47l4Xdub3HV/0619WfaOevCghUyImF9dg+U824Zbsj/noxGajNsdyq JQxCGez9axSQNYR16Ilj6r4Jn5HGh83iRTX1H6tIPI59k29BTqDao4EkJ18lavFNzg9F pmKx17nnmxG2R67NCCmpuP6IJLy4D2Ij+7AE+qxn6f3VXR1NjOZF0LCBPqXM5+9YvSDf YHXrw5kzs7XlSsrW1YXQGvFdr79UIZKyEv86TPjupcMONY0prUBil6Qdth2yzYBsPKRK jtkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686241648; x=1688833648; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L3eYHbt3Lra1h4IhwyjExc7YWHHEJ0+HYZYvn3NDBAE=; b=JK/4fA07nzf4MXeXofXZDTJx0qxP7rpNe6UlZIPmVwzbD6cTxKIGz66P8r691IalBK hJiNnkxXU+P4E1q8qcSt9IxVx/KxJR4dhsodX+HfDjpPuVmla3hDRjxu6itd5xh4yGIr eS/FUiOHH2u2JfA7as8wITPNkXJ9LB6X30ktnWk/ysYrC6n0TllUYlPTcMs+V/XlfApR qxJkdcNqK6YVBlLGxE50QTJIy9EF/nwntT5SnH6rKDMeMkVqUl/mKkVe0v48tQjNvBAG vO2ZFX4YjGRM6bYy3yayijoybwwg7zJuLDL2NqGEglxDXPvnHNGG9fnvfRQpA6PNFd6I owbg== X-Gm-Message-State: AC+VfDwsYHp2zVrSMCRgnEFiWiq+H8eqdtMlO+GYuesWYotsFfeFO4cL CcObkIV5PcATZmUmwe2rla4nbPWNj4M/0hHvpaSssQ== X-Received: by 2002:a17:90b:1b4b:b0:256:3fc7:59fa with SMTP id nv11-20020a17090b1b4b00b002563fc759famr3963530pjb.9.1686241647804; Thu, 08 Jun 2023 09:27:27 -0700 (PDT) MIME-Version: 1.0 References: <20230608125820.726340-1-zhangmingyi5@huawei.com> In-Reply-To: <20230608125820.726340-1-zhangmingyi5@huawei.com> From: Stanislav Fomichev Date: Thu, 8 Jun 2023 09:27:16 -0700 Message-ID: Subject: Re: [PATCH] libbpf:fix use empty function pointers in ringbuf_poll To: zhangmingyi Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org, daniel@iogearbox.net, davem@davemloft.net, edumazet@google.com, hsinweih@uci.edu, jakub@cloudflare.com, john.fastabend@gmail.com, kongweibin2@huawei.com, kuba@kernel.org, linux-kernel@vger.kernel.org, liuxin350@huawei.com, netdev@vger.kernel.org, pabeni@redhat.com, syzbot+49f6cef45247ff249498@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, wuchangye@huawei.com, xiesongyang@huawei.com, yanan@huawei.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Jun 8, 2023 at 6:00=E2=80=AFAM zhangmingyi wrote: > > On 06/06,Stanislav Fomichev wrote: > > > On 06/05, Xin Liu wrote: > > > From: zhangmingyi > > > > > The sample_cb of the ring_buffer__new interface can transfer NULL. Ho= wever, > > > the system does not check whether sample_cb is NULL during > > > ring_buffer__poll, null pointer is used. > > > What is the point of calling ring_buffer__new with sample_cb =3D=3D NUL= L? > > Yes, as you said, passing sample_cb in ring_buffer__new to NULL doesn't > make sense, and few people use it that way, but that doesn't prevent this > from being a allowed and supported scenario. And when ring_buffer__poll i= s > called, it leads to a segmentation fault (core dump), which I think needs > to be fixed to ensure the security quality of libbpf. I dunno. I'd argue that passing a NULL to ring_buffer__new is an API misuse. Maybe ring_buffer__new should return -EINVAL instead when passed NULL sample_cb? Although, we don't usually have those checks for the majority of the arguments in libbpf...