Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3929350ybf; Tue, 3 Mar 2020 16:03:53 -0800 (PST) X-Google-Smtp-Source: ADFU+vsHaTQx77ooMjQYj98Qg+NObeVV7Ha37rzKyKaGuZcnQZysu6jAGpYqpIZPxIPv32aDjEtT X-Received: by 2002:a9d:7d91:: with SMTP id j17mr342551otn.218.1583280232989; Tue, 03 Mar 2020 16:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583280232; cv=none; d=google.com; s=arc-20160816; b=hHQU4C4A5U5jPq7uHY4LkcGSLh/1bPuKCfNR5Yktb2Uv0nJp2ymToogrC9kCK0EQ2Z 0Ud6Sth4h9pAVyqUJDEBidPJVEy+ASgtTfdfgAtZwqgYBuobNLgWnEz88MPeH2BZpv7B tTUhgggo0UlQGnq+Qi95pO6vtlWvbOgd62zPNxPe7M5oqMTRz9+s8MdLXIBi+WE6JzK1 DnMH4dG6GF74F90DqMenPCDkviAyHKiw7XE3WID7MXBti3Tq6TBajQNxSE12WR5lBbMW bzvfrO/wVTFFHm07FsOjb2eeGVJKYRI8C3ozHi/VvdqLQck8CEzAT1PafcGjKbxE7yqL rdQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Cg+Bk6p3ng/oCqeB9jAP5HpcQ6wBIVVyIyzT0MMNq0k=; b=jtXgVa63PFDOMvzB6j8o3dA3h9XDPuwQL0JxElqJ+vmIwg6WVikL9b3bODoJFtP86s xuqllGJkgC+dRBw6L6ygF+95xYvu5+NRh3tnvMvQ4tjq0Ig6tfZw5mqWwETU22ys2T8k ddAg0Svy/8mQddkj+Pkam5dH7GGnAmKJDdy+wmrV3+WC9yz/EfhMuKsgYDfLk4VhhR7Z hD4oOWyHOtl5RTqHJjMEFJ0AdTfIxE7oKvMYVczek2lqENLu41Co2cA3lsTP80jZCln/ 6iB7tvF4fzUlBr6/36oLRL83c5MPlilOBfAIlzwHZjds6okd5NwAa29iAggStxaaKuN+ W1xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Wtdw/bpD"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si96025otc.315.2020.03.03.16.03.40; Tue, 03 Mar 2020 16:03:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Wtdw/bpD"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727903AbgCDADc (ORCPT + 99 others); Tue, 3 Mar 2020 19:03:32 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42590 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727604AbgCDADb (ORCPT ); Tue, 3 Mar 2020 19:03:31 -0500 Received: by mail-pg1-f196.google.com with SMTP id h8so72285pgs.9; Tue, 03 Mar 2020 16:03:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Cg+Bk6p3ng/oCqeB9jAP5HpcQ6wBIVVyIyzT0MMNq0k=; b=Wtdw/bpDAHegTWVPqPiInwTRdc+XxDNKZV5OyxUdLlV7JnWYcKCYo5WwcOqZBwoZgR lCMRDanCykEaZjdNDLpO9T5CqO7BcZg7jnRfbK4HKgL0nmUTQbR2CSv9dU3LQrWdftHN Ok2JGkqTvgMzihWyEv4rDsCvtgunV7D2BpPu2+FdHSA61Fo2ozHR7we/hDStKntnGNU3 yTaKQw5sIuR7Mb+sPgJue9DY26rhlMPuqGcVxhT3opQ9hKRVyjtmJ3Za+jzdRN06xyaY 5raGwMxS83abexPR9tjLNaRRvARn3H7mJcJfNYoQCe0IT9YYvseds7bNeO9X1HksqvWl hFLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Cg+Bk6p3ng/oCqeB9jAP5HpcQ6wBIVVyIyzT0MMNq0k=; b=pkHhtqN1ljR9QQrxQUrQDLnvnDZyfQtO0gCdy1JpjHjVOdKsNhvpuMeAWpg05ImXAS hOHFdB2HTfn1lLI6wGkgAiciYAXpFizqhQ+Z+koarU1Wl3FpDR86/Ae6n4q/49i46JWf VPeDweelFt59hQmtoTF0QPC15+CKPW0hdjS7L+/RxGpjP+FhqwIvICEo0lThUQPgfqNm fh7Awy8vicFbfvvk/W7pyxGkYrcdBO0kL5DmaaznaB522UcBZ/d9Y6bDJg2oi09FT7FG lGNS9PNaqTCFYinPFTR5yKSCdYFFENMuMGZF95WA2Oh5Xx6vBETdgABeC3zzp+xVtciZ or2A== X-Gm-Message-State: ANhLgQ0LINO0jpmCgd+kWaHnkPF9YRnx4AisherIovrOSXhodLW1o7XR ceKpHKi4y50cw6JYu4LfllA= X-Received: by 2002:a63:4103:: with SMTP id o3mr5683444pga.199.1583280210838; Tue, 03 Mar 2020 16:03:30 -0800 (PST) Received: from ast-mbp ([2620:10d:c090:500::4:a0de]) by smtp.gmail.com with ESMTPSA id z22sm4937779pgn.19.2020.03.03.16.03.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 16:03:29 -0800 (PST) Date: Tue, 3 Mar 2020 16:03:27 -0800 From: Alexei Starovoitov To: KP Singh Cc: Andrii Nakryiko , open list , bpf , Alexei Starovoitov , Daniel Borkmann , Paul Turner , Florent Revest , Brendan Jackman Subject: Re: [PATCH bpf-next 4/7] bpf: Attachment verification for BPF_MODIFY_RETURN Message-ID: <20200304000326.nk7jmkgxazl3umbh@ast-mbp> References: <20200303140950.6355-1-kpsingh@chromium.org> <20200303140950.6355-5-kpsingh@chromium.org> <20200303232151.GB17103@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200303232151.GB17103@chromium.org> User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 04, 2020 at 12:21:51AM +0100, KP Singh wrote: > > > > + t = btf_type_skip_modifiers(btf, t->type, NULL); > > > + if (!btf_type_is_int(t)) { > > > > Should the size of int be verified here? E.g., if some function > > returns u8, is that ok for BPF program to return, say, (1<<30) ? > > Would this work? > > if (size != t->size) { > bpf_log(log, > "size accessed = %d should be %d\n", > size, t->size); > return false; > } It will cause spurious failures later when llvm optimizes if (ret & 0xff) into u8 load. I think btf_type_is_int() is enough as-is.