Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3977726ybf; Tue, 3 Mar 2020 17:06:44 -0800 (PST) X-Google-Smtp-Source: ADFU+vsWFKocKOnt6AMIH8yofC7J0qn/Sue+20BkrBH8fcb7u6a00XXRcQyln3VRvG1WD369jFlT X-Received: by 2002:a9d:7411:: with SMTP id n17mr464895otk.159.1583284003964; Tue, 03 Mar 2020 17:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583284003; cv=none; d=google.com; s=arc-20160816; b=kQWhKPaE3NpQGwSSUraT+5zngrek0QEsTxpYCazcEGGnmea4r1lgeiq7iBWL/pUkHa WEGn1FXkPiMFKvvPByDB9PedsxF032eCEp86MoGpUDTZyNi094A9z9i0UIpLV4OyUb7m MEpRPTMywH5bcCuYq0jd7kffmdiP/oNBEeIEWW5OcWS8Y/J1dd0ZZRh5Wen7p/yxURJv kuP7xV2xOIayKvhf/9MlN75DbeT4O84P/KZ5lXKGDvWh4vgD2TdFKgXWuzhM6/TcJ+01 QACKbUjQU+742jPlE5EuRoIj/QU3aPGRqHBRCab9RjYIvSWpznujAPueYNHSlXEl+MKe LKQg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=ctoiEBV7oYQ+Ec8vuMBepnjoi9mkX/M9Ee8Z3sCdCxE=; b=nnDc5es4uP9Pai/cwemlTu3Yj145mrSBKlvYsGvIn+s/TVnKhOnX9bWXoZUyxeJxm0 oYHc4wAMqSl8t4k1mpGIfQkkEHwHMHQjwaLJBd7yNW/ttI4zy0rfSSimRgMhZJLTFJ9S ofebDN7g1TWLS4phRXWDrfm63VFEzl9jpBoVOcWISOmnBsp/G/4kMBPUU9KhPs6NiaeJ St+QcyjDtbsQgz83j5rX/Xhh8KNVT/JPgs5CB7kGUSdkmaNf4uUdL7q10ee+N3GF5e9p edwbtTA6TQRZYgM2P1uudE8k5y8152jkdE5ENa6L8wt5Xmr4gF+0v7gEwMocHFC2easV 5BZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iPgccfS1; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q81si265609oic.174.2020.03.03.17.06.31; Tue, 03 Mar 2020 17:06:43 -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=@chromium.org header.s=google header.b=iPgccfS1; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387425AbgCDBGW (ORCPT + 99 others); Tue, 3 Mar 2020 20:06:22 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:50817 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727854AbgCDBGW (ORCPT ); Tue, 3 Mar 2020 20:06:22 -0500 Received: by mail-wm1-f68.google.com with SMTP id a5so89271wmb.0 for ; Tue, 03 Mar 2020 17:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ctoiEBV7oYQ+Ec8vuMBepnjoi9mkX/M9Ee8Z3sCdCxE=; b=iPgccfS1xG4obi2LdzeZagYxTiUM5+2sjUgn03SpxHQENWRvN8ZboigVQDfXhAuwmZ LG85TxJex+PPxXCRpDkeZyMh0tPHllB+HZjkxzJp/RtbP4d3oS5BpJHKKH96iKC/a0ZG Jo4ERdUQY+Fz6m0HJ9lPq4EbJZRBNXcUGURXo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=ctoiEBV7oYQ+Ec8vuMBepnjoi9mkX/M9Ee8Z3sCdCxE=; b=ivnNgp7NVvwNMkR1zTc3Vtjv08m8I+OYnFpL6ASdKhuoEtOZJsArFN26DsFKswowhL lbFHDxKBesr7Q50Ye1C/tP2ug2Lc/6FT4R00vCbE+IvNOKHZ28bqjVMbV77S57y4MUkZ ZDiW0p8+mALJqdwVUTaSZ8Z5amVqL0WvoGYgWqed+C8+O1gNs8nlSseLGLoCR8wp7QUa PxrLNhkYSLpt6HzvHE91isoqS2bKRStbOXFI8ONddstNZnKVCrylkl8BfZ9mdKwimysd JDpvSn9Q3BjTKAup2kCZPfZ35ZnaPocE+gu/tpeB7263DoKSbbPJZGF5gNp7e36SiMD8 HGaQ== X-Gm-Message-State: ANhLgQ3mSPh20WeqMm3CJV8zw1pWhPNHC8Z4QZm+yWLPtQlCsAPa9/rl aN8ywANEFxybcX/T7F8n9KcdTw== X-Received: by 2002:a05:600c:4108:: with SMTP id j8mr367432wmi.188.1583283978996; Tue, 03 Mar 2020 17:06:18 -0800 (PST) Received: from chromium.org (77-56-209-237.dclient.hispeed.ch. [77.56.209.237]) by smtp.gmail.com with ESMTPSA id c14sm21550977wro.36.2020.03.03.17.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 17:06:18 -0800 (PST) From: KP Singh X-Google-Original-From: KP Singh Date: Wed, 4 Mar 2020 02:06:15 +0100 To: Alexei Starovoitov 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: <20200304010615.GA14634@chromium.org> References: <20200303140950.6355-1-kpsingh@chromium.org> <20200303140950.6355-5-kpsingh@chromium.org> <20200303232151.GB17103@chromium.org> <20200304000326.nk7jmkgxazl3umbh@ast-mbp> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200304000326.nk7jmkgxazl3umbh@ast-mbp> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03-M?r 16:03, Alexei Starovoitov wrote: > 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. Okay skipping the size check. - KP