Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3950023rdb; Mon, 11 Dec 2023 05:02:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBPLD52e19ieMSmc+lbqD4lM5Hj8eABixnKXahzrX1WbN/rZH8onnlmWSKYEXt0VWTkj7g X-Received: by 2002:a05:6358:78a:b0:170:ddbe:d051 with SMTP id n10-20020a056358078a00b00170ddbed051mr810928rwj.59.1702299727126; Mon, 11 Dec 2023 05:02:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299727; cv=none; d=google.com; s=arc-20160816; b=DnYDVLFnnCJ1gZI13zRkh13AtqVuv9qG50DqBIlcpRQS7fm8iMH58ImcDpfr/KUCjY sF6X80ZnxBLhaHXwmdDAUysjMcsn1JEFaDLnTw4EdA3Z62ty1VxyfhzOY78m5SdlwIL8 Y3zLFDLjkbiszBNnaW+9UhlRM5eANFLKYc/eBAgDnaY2dpqLRMpo6KscguSzVVS4Ogf2 MIB8w3nGoG4PnYJDnNmu05Gjm7BbIur9R7uy1MMSjfsuycaErIDa9KjWzXqhGCVIVOSB n2WDjQs9y6o0NbnTuhZD94fNfKUfF1kwiBofVb7UK28z5+ySFNf+LkMz6XVNEoiTzpaM Jnvw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=JNQm7s7g+d3XsjrBpIIxNcsMxJriHJmGupSKhGUX004=; fh=2/DR6R/MW0b1E9yDCdwXheuoLa0XF/ynxBWRqSgNIXU=; b=Lh1Hu6UGhbSIWtIaAk873pfDF193xXdGVcpNIJaMNhFODvfMFT5y+hnB9WX0dA3rTi 4IqwvobDI95LT7/GnUd/eDENuUbgyZ06xJ133xMlXAbCZDcFXNxHrRGI5gNOjzFR4g8W igU09NB3+eMjLQc6H3zRGttH9INkslEAValq1ghUcRxSghqhcy8NSGu7DMQiT9sXMI1v PRyTvYeSCk5w6XV6VKKyRnaF6WJ19v6R2L4iIzRRfzfiVGNKQFzJY3tO1d16iN3i7Ool +cpfxZS57szkWLAHBPV65GXWlCs4bnF8BInRI4hdraA/MmjjIjzi1KaDtx2h18JpfPW9 SuqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="bgie8C/f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bw24-20020a056a02049800b005c6689f9d81si6102464pgb.215.2023.12.11.05.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:02:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="bgie8C/f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2179B809583F; Mon, 11 Dec 2023 05:02:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234945AbjLKNBq (ORCPT + 99 others); Mon, 11 Dec 2023 08:01:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234637AbjLKNBl (ORCPT ); Mon, 11 Dec 2023 08:01:41 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 655A0D6; Mon, 11 Dec 2023 05:01:47 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40c38de1ee4so25150425e9.0; Mon, 11 Dec 2023 05:01:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702299706; x=1702904506; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=JNQm7s7g+d3XsjrBpIIxNcsMxJriHJmGupSKhGUX004=; b=bgie8C/f4rYdCXEZ2VEzJvw6hR8ck/TDPMvaf5sTGzI9zQwb5r8sZhLo1rHh+th87w NLtdU4D1c9U+Gb2G4crLMwOAEg6XOklMwrVu7X3JA9lQb972Dp+OHDT3Rv0gkwFQXhr0 A/nEV8vW0la38Y44Hb7Y3UqENT2HT6ZlH/x4EGjqpnGpaiiOAXERkAUulf8j3aO57S2H ZB1wJxCSo/gslUUqaEhwOkUBkqTBqarPnr2X8JAz5jF4m7Qn3nsZMavNwqSJc1X6dSH2 lbWJ9UEopr+oH3OOC0S8ZBPmj8vzgGpGlIt/t6ovvyuziYFrOkuyGYthF/p/iB+kv+d6 MVFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702299706; x=1702904506; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JNQm7s7g+d3XsjrBpIIxNcsMxJriHJmGupSKhGUX004=; b=rtci17TF9I/yqpmhQQdTg9OLg02/3VfEoU7IbPIAkmnGB9AXl7xdK5jt6qHog5iVRg wOpJ2QZVACBHYay3NPHNdao+gOijHohyRoLXAkMPpBFYS7fKUhR14bpnxW9AZp4PduPY ys55UVD70UQ76vJ/NBKb5Rb89SS2wEwDwX4X4e9d0F/1r479WcmHlZpR7OLMwk8cvEjB BupidrIKlff5MN9EmOr2zJrgY/VngxlAWOA47/6iOW2ti85V006T2vnZHp6Kppyn3/He +xH1mY8paOdrNd9rJtXoEgMvSfwWqyNWL6HlF/6ydHtfCrLEEEeq4E8jcurBG7xbOq+a sITQ== X-Gm-Message-State: AOJu0YxekNGBpVCFxQIVIVvPWF931MiJrgXiqI7tJf5Eji9DfvbVdCDx ss4fbJVHOPusdFlCVdvBR4E= X-Received: by 2002:a05:600c:20d:b0:40c:3915:be5a with SMTP id 13-20020a05600c020d00b0040c3915be5amr2511796wmi.118.1702299705590; Mon, 11 Dec 2023 05:01:45 -0800 (PST) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id t14-20020a5d42ce000000b003333b0d603bsm8497641wrr.42.2023.12.11.05.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:01:45 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Mon, 11 Dec 2023 14:01:43 +0100 To: Hou Tao , mhiramat@kernel.org Cc: xingwei lee , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: WARNING: kmalloc bug in bpf_uprobe_multi_link_attach Message-ID: References: <689db41e-90f5-c5ba-b690-00586f22d616@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <689db41e-90f5-c5ba-b690-00586f22d616@huaweicloud.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:02:03 -0800 (PST) On Mon, Dec 11, 2023 at 07:29:40PM +0800, Hou Tao wrote: SNIP > > It seems a big attr->link_create.uprobe_multi.cnt is passed to > bpf_uprobe_multi_link_attach(). Could you please try the first patch in > the following patch set ? > > https://lore.kernel.org/bpf/20231211112843.4147157-1-houtao@huaweicloud.com/T/#t > > [ 68.389633][ T8223] ? __might_fault+0x13f/0x1a0 > > [ 68.390129][ T8223] ? bpf_kprobe_multi_link_attach+0x10/0x10 > > SNIP > > res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x20000140ul, /*size=*/0x90ul); > > if (res != -1) r[0] = res; > > memcpy((void*)0x20000000, "./file0\000", 8); > > syscall(__NR_creat, /*file=*/0x20000000ul, /*mode=*/0ul); > > *(uint32_t*)0x20000340 = r[0]; > > *(uint32_t*)0x20000344 = 0; > > *(uint32_t*)0x20000348 = 0x30; > > *(uint32_t*)0x2000034c = 0; > > *(uint64_t*)0x20000350 = 0x20000080; > > memcpy((void*)0x20000080, "./file0\000", 8); > > 0x20000350 is the address of attr->link_create.uprobe_multi.path. > > *(uint64_t*)0x20000358 = 0x200000c0; > > *(uint64_t*)0x200000c0 = 0; > > *(uint64_t*)0x20000360 = 0; > > *(uint64_t*)0x20000368 = 0; > > *(uint32_t*)0x20000370 = 0xffffff1f; > > The value of attr->link_create.uprobe_multi.cnt is 0xffffff1f, so? > 0xffffff1f * sizeof(bpf_uprobe) will be greater than INT_MAX, and > triggers the warning in mm/util.c: > > ??????? /* Don't even allow crazy sizes */ > ??????? if (unlikely(size > INT_MAX)) { > ??????????????? WARN_ON_ONCE(!(flags & __GFP_NOWARN)); > ??????????????? return NULL; > ??????? } > > Adding __GFP_NOWARN when doing kvcalloc() can fix the warning. hi, looks like that's the case.. thanks for fixing that btw while checking on that I found kprobe_multi bench attach test takes forever on latest bpf-next/master test_kprobe_multi_bench_attach:PASS:bpf_program__attach_kprobe_multi_opts 0 nsec test_kprobe_multi_bench_attach: found 56140 functions test_kprobe_multi_bench_attach: attached in 89.174s test_kprobe_multi_bench_attach: detached in 13.245s #113/1 kprobe_multi_bench_attach/kernel:OK Masami, any idea of any change on fprobe/ftrace side recently? I'm going to check ;-) thanks, jirka