Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2432310lqb; Mon, 27 May 2024 22:13:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrrV4Y9lAGSj7zlY5JAm+WJdcW4dx/7BENFl252FEVCEv1YaVSn8Rhp3wH+5zYjdXDlr223qIRg+DzjUyGIi4D2VT1AHAMQNX+5WEkeQ== X-Google-Smtp-Source: AGHT+IFS5GWbOCMHBGLU9YhbezxBzlipP97oHyQNoKDEUVMckmnTA/50Np9Fdp7zGp8bL8ZJF3ta X-Received: by 2002:a05:6a00:4c12:b0:6f3:ea67:48c3 with SMTP id d2e1a72fcca58-6f8f1a66df5mr12447471b3a.0.1716873184339; Mon, 27 May 2024 22:13:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716873184; cv=pass; d=google.com; s=arc-20160816; b=0XzVrHRXe0FYgRcGuiPEYPBVXWKatgVHwa3/Kux5XMHUuZYPtx1P+ARm9q3TcWiLP7 ntKi1ia5txoS1sZc1MHds1sbIUj3+V/VUUU2RoeInlZZzdkIa8m72ouPIajVqAv7NZTl 3ThGW6q4ciT1+I4K1BluJnVv1B9vo4vTytsT07NndOCklQrvYkMdIOlT6pnRtsUUOXPy 70+QH+Eu9eb35NWO9V8uXbf91IsXsJPqcfoqPVNzFUCTpwdDvr1AvzCMYuiPnPsEgB6u JDxbuZtjo1P8SY/2zA0jHgtR1hHFYLT6isN4Y2TUUQGwcoflPrrkBm+ZuJ3PmE9fPM9i +A6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=sEzBOXaIzbfMi17IPevGDHsDdowwd5GTFXbnEzHCSrk=; fh=0HZXeANX95FGibeR0tEv86V3p1wwaUbAOMiCgmoHuA0=; b=lzwyoOvMzRkCJhWlvE8Js64/ASXiOmn2Q91i+U2GOe3wYq1ojfrCvsJjB55T4hRC1E K9xfSrYM32dkGM0E5hu62G/+nNsZZdOts3LRbaevXWRZVEhYP7wEZD9DUEWJb8nX7qIa F0NPfrGrGFTiZcGaDvEOme7X5hrgbcdimWLQBJrkj9qaRtdpDJx33/NBwf0wtE3RKpzm qlmYS4FJw+QMxEN/JpAd7YVBo4fNQ0RY3oRSLm6WDWLxqRpMxL6DSquSdgcxA4wPpykH K2x9l/032yhpYH0M/u/vZ3hjYtBDLepJnJByAQwvqKCmMja69coIs0hpIq6KsByKfvr3 9rcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="aOUgv6/M"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-191755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191755-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-701c9788f7csi602823b3a.88.2024.05.27.22.13.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 22:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="aOUgv6/M"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-191755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191755-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 34675B21F60 for ; Tue, 28 May 2024 05:12:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33B494436C; Tue, 28 May 2024 05:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="aOUgv6/M" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89DFC182BB for ; Tue, 28 May 2024 05:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716873167; cv=none; b=WryNuCyRb6e+KO5aEehpT3hiMJ8Vqy3EUCXwOKZEQqof6SOs2GfA63cwMmokFAuJJxejbznDKzQqCXX0mnRNOG/sC5EFJu92JHORuCo809I4wgycjLBzHtgvs3qPP1bktMZpVy21ePwDAYep2WVXqoCZ8TbuJ1lEi5H6itTu6VM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716873167; c=relaxed/simple; bh=2ZGZeycdp5GJxWuvBsZV8gpu6cM4WHkuZaGF7VCG6/k=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=cP5rEbEG0KgbtBoX8Z0vt5HrJ00TVrs6bhN+gJaYQB7hYx+53FlVudJCIrvgVICRjhmXARd0IwD9zfkjXIzj8f7G3sLRSpa21VrQjolCuJ2AmkCMDgzW+OP7ODxJ+K+k0iF2/2lRu0WvpKjCGrHnpBgfVz9aOUp+nYfr+mU/PTE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=aOUgv6/M; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a633ec1cecdso22087366b.2 for ; Mon, 27 May 2024 22:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1716873164; x=1717477964; darn=vger.kernel.org; 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=sEzBOXaIzbfMi17IPevGDHsDdowwd5GTFXbnEzHCSrk=; b=aOUgv6/MvoCU8iHGHkp26EK5gjdQdCZHrrTzdBdwTVMK0ur4bBtHGtoQLmbHL+pZBz XANS12lTfjoTB+IR7PZQnWvWwL+1W590Y/BMhp0cK4y6SXUM6w6lqyPBemGVjkRf9Iw0 pDAMkZJIPiCCiU9kPoSzKPFc64SMW86CKrlue1IJ2ea4iSwSpHumYTjhqJt7drxi0/FO h/nHGeGURQPuokI6OXNCskMKwHhVsT40Il3Hr8p6SsffgSWjbt8Fmgpy959eoj0DijYr 1VFpsEbFJnpZw3xFRshPj8yD4L8h7jI/NtFx1vsIil4KvB86I8i3kCPbF8X9E3N3UGGg qiRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716873164; x=1717477964; 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=sEzBOXaIzbfMi17IPevGDHsDdowwd5GTFXbnEzHCSrk=; b=fPeyidj1CtREgnl9JRoBRsvYiIdeZGLvSHcgGMSNFUZI8AWm78oNXQJ/dwRkjBGiok jUcJl3ioIniFhrHVALRg9K/GFRdC0ZLEznK+VKzaywIG4qFXyMk42EVsd+HmXhkEE7lA kvqPly6dUi3HQwfIt60ypWWDoN4wIrhg0+jva738Yl8RwhgmJy6gD8nmmBjzVKygYZNr MAJ6LDE9v1YQj5Zs1xDcMc4uJSbEnH2SgUzsV5YvPOyrcN0SY2HOI4MUgqddourY7vp0 R8/UtmtWaKUi7XXLDXbubx/OK6t7ac+riKV5YZfC4Iu1+PJNHVvhCJkZ6JLkpBRtkgRW Z1bg== X-Forwarded-Encrypted: i=1; AJvYcCUZmTzBSPOB3AdC6r9iddXDkAj7tuQU6EcF2kcSmpSmomWuuGc9+WxULcy0A1cE/abHDJ250DWuGIMGjVxu+BDtTU0hDNRDxiYjr13F X-Gm-Message-State: AOJu0YwbVOIRusXEWTRWKrsiTabQk8xFawfXem4tqNBmA2JF/vnfPqMk 6VOsz6t8D60A2GJCeK5RnWsehJrtrUWmvWCUTWUuR+D/OYLJwfIpuUfxgmUN+uddlH6jrdA7j5d dDALm+9f9fEZWFtTKYNBG3rBjyX5geEG1dWbs3A== X-Received: by 2002:a17:906:69a:b0:a5a:7ce8:f52c with SMTP id a640c23a62f3a-a62641b1fccmr653519166b.16.1716873163902; Mon, 27 May 2024 22:12:43 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240527153137.271933-1-alexghiti@rivosinc.com> In-Reply-To: From: Alexandre Ghiti Date: Tue, 28 May 2024 07:12:31 +0200 Message-ID: Subject: Re: [PATCH -fixes] bpf: resolve_btfids: Fix integer overflow when calling elf_update() To: Jiri Olsa Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jiri, On Mon, May 27, 2024 at 6:00=E2=80=AFPM Jiri Olsa wrot= e: > > On Mon, May 27, 2024 at 05:31:37PM +0200, Alexandre Ghiti wrote: > > The following error was encoutered in [1]: > > > > FAILED elf_update(WRITE): no error > > hi, > this fix got already in, check this patch: > https://patchwork.kernel.org/project/netdevbpf/patch/20240514070931.199= 694-1-friedrich.vock@gmx.de/ Damn, I missed this. If possible, I think that adding the link to the bug report (or at least the "FAILED elf_update(WRITE): no error" string) would make sense, since it is not a "potential" overflow anymore. Thanks, Alex > > thanks, > jirka > > > > > elf_update() returns the total size of the file which here happens to b= e > > a ~2.5GB vmlinux file: this size overflows the integer used to hold the > > return value of elf_update() and is then interpreted as being negative. > > > > So fix this by using the correct type expected by elf_update() which is > > off_t. > > > > Fixes: fbbb68de80a4 ("bpf: Add resolve_btfids tool to resolve BTF IDs i= n ELF object") > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D218887 [1] > > Signed-off-by: Alexandre Ghiti > > --- > > tools/bpf/resolve_btfids/main.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids= /main.c > > index d9520cb826b3..af393c7dee1f 100644 > > --- a/tools/bpf/resolve_btfids/main.c > > +++ b/tools/bpf/resolve_btfids/main.c > > @@ -728,7 +728,7 @@ static int sets_patch(struct object *obj) > > > > static int symbols_patch(struct object *obj) > > { > > - int err; > > + off_t err; > > > > if (__symbols_patch(obj, &obj->structs) || > > __symbols_patch(obj, &obj->unions) || > > -- > > 2.39.2 > >