Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1567331pxp; Sun, 6 Mar 2022 19:25:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuWILjEEIaG1q/1TJ9QEwhLzhTv5Rndq/glMdGo4UvWegPxO2bX7Nzq7g28fhyEAsgumH9 X-Received: by 2002:a17:906:39da:b0:6cf:7f09:a7bc with SMTP id i26-20020a17090639da00b006cf7f09a7bcmr7953277eje.457.1646623500596; Sun, 06 Mar 2022 19:25:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646623500; cv=none; d=google.com; s=arc-20160816; b=M9nwWifVItm4chejaRj70efkvgHO84PdJxa0P3/IBuRnpfSQtPsStxnw2eEqIOF1uV dqB+PZrQnOhG5qNjQ6F45FJeNII7IIegBj70OPVnhit/a63Oo9sOxXaBlBzrcJDRdbTz HfUC4dIjz7GpfrtVxsL4p0b9TweJq2ZZMsHjHHs3KRHbwWL7GqdyU/rJPSm2kuZ5Y0bZ kLgotWgAbPhGrRM1gNSGD+5wJkDCg0Esn3jkSvAvciMj/BZU6ayHIWbqBVk0kjck40aI 0O1/zwR0ceQ3s9yEVF8hGcAOH/VUwTaCmY7mZ7eyUueYgRLcONUWYRpYY9zKmUoWps0g mjAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=W4/OOhsYIUeVHmDM2SWsQOWi+B+oFhl/nI7c5RX4BKk=; b=jU4UMLDBSI2+P4jzvbBl66OdTOabWiu3oZyUvrKo/Ve/P0vita1xq/1ZU1JEgbpdUP mq7VEwHabtxWbn7T69oojXJX7e192lC47N113jJSSQRPCH02SYPaYW75dKQD6y5VeExl qigXw54/20MdSEYjPgM0lFdIkgrBbYpGYzVGuFCKpWv8iP2FE6J1Fvk95uGDbnDyk7s/ zv62O2DjDVhehbgGM3OAUc06vtESpC2lfaSSlUhtctQV0t+TglXBdJw4mSYhY+7qRzxZ NyKNz+BjHIdivW4aA1wksJZV5hRFcuKpQzN2mTCkbR4V3NTo8Ew/70AnJgJHlH7wIbQO u+0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="k/G44Yt5"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg17-20020a170907a41100b006da9e3e3a1esi7465887ejc.154.2022.03.06.19.24.29; Sun, 06 Mar 2022 19:25:00 -0800 (PST) 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=@gmail.com header.s=20210112 header.b="k/G44Yt5"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233890AbiCFR3p (ORCPT + 99 others); Sun, 6 Mar 2022 12:29:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiCFR3o (ORCPT ); Sun, 6 Mar 2022 12:29:44 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 037CE2613C; Sun, 6 Mar 2022 09:28:52 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id i8so19909632wrr.8; Sun, 06 Mar 2022 09:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=W4/OOhsYIUeVHmDM2SWsQOWi+B+oFhl/nI7c5RX4BKk=; b=k/G44Yt5DvmreJLgQI3GuAgC3wsb0j+ZJByjP5drkWfERt+YNmstc2W0TTfGm1HxVS 3G2VKahdAIEqjtFVK8rujNynCstafulKqH5XtTZLRa2c6jHvSy8v2dPBRKV6QQXkYQ3t HKbY5GdjOKvLFJVrFe6Efa+7pU/nGCOYrS7KHCVzgfmswKjplqS6URV2g8GGrcLa9zpj R7IQevo1KkJxzjSkaeFTWrL3zhA4t4U08BGo4Gc6FJ0b7JMOQaFifVg2IloQy25BDbNa 40z9Fq8Ra6Lwt3zV74EBEpiLTaDUjePKwn647y5A4ALQb/qSEJxVN1/E7tOCd2ZcgRPC GJfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=W4/OOhsYIUeVHmDM2SWsQOWi+B+oFhl/nI7c5RX4BKk=; b=pj0MLWLtI54fvuJ6xwrH1x86zH3Rc2ikwlve36eTh8H1dCNfRRZt9bSH1jQlZBC5pu 39ptICXuOu0PCcskP88zzO+ib2mCKlHnV2K8UnlAtr/8lT9cj88mARKAbbNtdLMlRSFM iUM9G4p9olUOBLT5S9by7snOeIEFrbxS9Na2LYPQRz8pRozhpCi/kexSoVA82rkkZODI QuxW4ZcFgNmwwuZZm+RvmNcYPGQg7BL/5SyKv+FvqrN1tr0SK0GNPVKJ0cNlWxZsHo/V sKmXRYASmOXx0tvpCj1Fc7x76KN2mGwMwV7yiyPz4VJk8FBRbZ6cUSwTZUhOnptlUZEb HPBQ== X-Gm-Message-State: AOAM533P2h4T3ZOCKW3B4UBEiq4H743RfIrIBt9YDZcLzEYHcZSZtlws 8ksB33O5nLuZb18XCE1aN7o= X-Received: by 2002:a5d:648f:0:b0:1f0:567b:5619 with SMTP id o15-20020a5d648f000000b001f0567b5619mr5581201wri.66.1646587730449; Sun, 06 Mar 2022 09:28:50 -0800 (PST) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id l5-20020a5d6745000000b001f1e4e40e42sm3504346wrw.77.2022.03.06.09.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Mar 2022 09:28:50 -0800 (PST) Date: Sun, 6 Mar 2022 18:28:47 +0100 From: Jiri Olsa To: Andrii Nakryiko Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu , Networking , bpf , lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Steven Rostedt Subject: Re: [PATCH 02/10] bpf: Add multi kprobe link Message-ID: References: <20220222170600.611515-1-jolsa@kernel.org> <20220222170600.611515-3-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Fri, Mar 04, 2022 at 03:11:01PM -0800, Andrii Nakryiko wrote: SNIP > > +static int > > +kprobe_multi_resolve_syms(const void *usyms, u32 cnt, > > + unsigned long *addrs) > > +{ > > + unsigned long addr, size; > > + const char **syms; > > + int err = -ENOMEM; > > + unsigned int i; > > + char *func; > > + > > + size = cnt * sizeof(*syms); > > + syms = kvzalloc(size, GFP_KERNEL); > > + if (!syms) > > + return -ENOMEM; > > + > > + func = kmalloc(KSYM_NAME_LEN, GFP_KERNEL); > > + if (!func) > > + goto error; > > + > > + if (copy_from_user(syms, usyms, size)) { > > + err = -EFAULT; > > + goto error; > > + } > > + > > + for (i = 0; i < cnt; i++) { > > + err = strncpy_from_user(func, syms[i], KSYM_NAME_LEN); > > + if (err == KSYM_NAME_LEN) > > + err = -E2BIG; > > + if (err < 0) > > + goto error; > > + > > + err = -EINVAL; > > + if (func[0] == '\0') > > + goto error; > > wouldn't empty string be handled by kallsyms_lookup_name? it would scan and compare all symbols with empty string, so it's better to test for it jirka > > > + addr = kallsyms_lookup_name(func); > > + if (!addr) > > + goto error; > > + if (!kallsyms_lookup_size_offset(addr, &size, NULL)) > > + size = MCOUNT_INSN_SIZE; > > + addr = ftrace_location_range(addr, addr + size - 1); > > + if (!addr) > > + goto error; > > + addrs[i] = addr; > > + } > > + > > + err = 0; > > +error: > > + kvfree(syms); > > + kfree(func); > > + return err; > > +} > > + > > [...]