Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp679371ybb; Wed, 25 Mar 2020 07:36:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv6nGXkhEYWOd8XlaMNqpu23o26e2PwgMeiYNG490Buh9RJ7JyxYQsN9f/kAl2PimMkKQR1 X-Received: by 2002:aca:a94a:: with SMTP id s71mr2541592oie.152.1585146983976; Wed, 25 Mar 2020 07:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585146983; cv=none; d=google.com; s=arc-20160816; b=TUscKQwpCmWlkpRpsakFq8i8s0yjToDckBDgF/jUQUamjvo4qSWStehwI35p/gWLkx BuD71mmHEZlVrHjaxomYkaHGqq5vVMK9G4sJOOAXGlp28VeGmbVMJH8njPdaLDwPGq0f 0yNTpI3poAzv3KgeP1sixgB9uHws0ohwLvoKQBQCCHh+Z6QO170cCVshAFoMgDPDKp2D DZkteRz/5qrmMo8Z9QjRiN0fUoysFwHrjYaCS8k588L4LeqJb9FxFZ8gz2ijsUHKN3Gi S7cGRVjiOH34qRbvJLYZvgxH7Q/agrfTgauztjCCC9uCcPlvtZ0B6QFG4SBPlHup1gu+ ghdQ== 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=4SCMfX4AFsAbSPoyRRB2akn3fbWQgwxVoxo/587s/z8=; b=NgmaPtE5LW5ify4e/+LjiwyDqCjcPCVOPnXBO6SGHuksdA0zkD0nN6jL6pR9mHcYDh ixn4uYF2FIFTcaSLQmdFATaGB6xsS/Uiw4ZfIpMIi20W6Elnv7DjXh7aLakHHYNyqYk6 SM2m3crWdCpi5SSEylNUdK9PHsMBmm+McVsYsld2rX1JapbkIyZ7ZW8Oqs49Xkng8+x+ phJTWbzq028oW2dKZ6uhSRmtCz8MAcTVOBraTYabEWWy0lFdOd1BdwFw9GAnUltAQqJ6 jJLYVb+4B9uqV+Sd6oGh1OuJde6fWgjx5/aRp7Dodky/4yF2JzoIiXB1cVps+8w4LyRu rDqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NSQNWZYg; 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 w83si10289913oie.244.2020.03.25.07.36.07; Wed, 25 Mar 2020 07:36:23 -0700 (PDT) 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=NSQNWZYg; 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 S1727751AbgCYOfe (ORCPT + 99 others); Wed, 25 Mar 2020 10:35:34 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36079 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727501AbgCYOfe (ORCPT ); Wed, 25 Mar 2020 10:35:34 -0400 Received: by mail-wm1-f67.google.com with SMTP id g62so2965781wme.1 for ; Wed, 25 Mar 2020 07:35:33 -0700 (PDT) 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=4SCMfX4AFsAbSPoyRRB2akn3fbWQgwxVoxo/587s/z8=; b=NSQNWZYgH7h9i9bJ/0fpcGqR+VH3MsRrjjNKsBw/qMvHIVxROtE/7whq7UFq7v5S/z QrMRhJWkncsPtnhD/cQ9XRdOB6fwTXuvNhcCY3r0VvanFGk9LmguhT/S1HwmklbCSygS FPlzURZP+Wp0rut/CEkrX0IAIb1QiGU5LO2WI= 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=4SCMfX4AFsAbSPoyRRB2akn3fbWQgwxVoxo/587s/z8=; b=F+WQDeM8hgcCARAHoUEW4PoNzjndy6lCjLn6gj+xAb9s3peuq9Fv7G8PA+o5mr3AIr HPNoJ73BX0TXH9oBzbENM9lSYqVliuQLFqLI8/ns7PSI8q0LmE9SnMa1BWmMZlYQfwOz s5/iza13mSrHbXRZ5XXgWKQE/w2c4VDRnr8SNUJEs2glkyl1B5VYmNzSSpc4PRZIdbCX FK0Iwyeh/bVdryJscxIJ5APCS2HgBCsfeVoZGCuuxVoSfSpg2LdMYD29bqe6PA9LxRId v6B6UgUXGYGD7r9ANoX7FhsJ5GSgQ63r+JW28gp6d8l269Dzvrx8wvUwWAb0rORpcyVf 0fPQ== X-Gm-Message-State: ANhLgQ00SqHPuSq5Fe4uE2tqdhb5FStL1oLLQuSrhBRjjcpcIxnOdiWM RZ9muL/qWseANsVLKKqO4jCYEQ== X-Received: by 2002:a05:600c:10ce:: with SMTP id l14mr3925012wmd.161.1585146932514; Wed, 25 Mar 2020 07:35:32 -0700 (PDT) Received: from chromium.org (77-56-209-237.dclient.hispeed.ch. [77.56.209.237]) by smtp.gmail.com with ESMTPSA id e9sm33653723wrw.30.2020.03.25.07.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 07:35:31 -0700 (PDT) From: KP Singh X-Google-Original-From: KP Singh Date: Wed, 25 Mar 2020 15:35:28 +0100 To: Kees Cook Cc: Casey Schaufler , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Brendan Jackman , Florent Revest , Alexei Starovoitov , Daniel Borkmann , James Morris , Paul Turner , Jann Horn , Florent Revest , Brendan Jackman , Greg Kroah-Hartman Subject: Re: [PATCH bpf-next v5 5/7] bpf: lsm: Initialize the BPF LSM hooks Message-ID: <20200325143528.GA22419@chromium.org> References: <20200323164415.12943-1-kpsingh@chromium.org> <20200323164415.12943-6-kpsingh@chromium.org> <202003231237.F654B379@keescook> <0655d820-4c42-cf9a-23d3-82dc4fdeeceb@schaufler-ca.com> <202003231354.1454ED92EC@keescook> <202003231505.59A11B06E@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202003231505.59A11B06E@keescook> 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 23-M?r 15:12, Kees Cook wrote: > On Mon, Mar 23, 2020 at 02:58:18PM -0700, Casey Schaufler wrote: > > That's not too terrible, I suppose. What would you be thinking for > > the calls that do use call_int_hook()? > > > > rc = call_int_hook(something, something_default, goodnesses); > > > > or embedded in the macro: > > > > rc = call_int_hook(something, goodnesses); > > Oh yes, good point. The hook call already knows the name, so: I learnt this the hard way that IRC that is passed to the call_int_hook macro is not the same as the default value for a hook call_int_hook accomdates for a different return value when no hook is implemented, but it does expect the default value of the hook to be 0 as it compares the return value of the callbacks to 0 instead of the default value whereas these special cases compare it with the default value. For example: If we define the default_value of the secid_to_secctx to -EOPNOTSUPP, it changes the behaviour and the BPF hook, which returns this default value always results in a failure. I noticed this when I saw a bunch of messages on my VM: audit: error in audit_log_task_context which comes from audit_log_task_context and calls security_secid_to_secctx which ends up being always denied by BPF. In anycase, I am still adding the default value in LSM_HOOK and using them in the following hooks: getprocattr -EINVAL inode_getsecurity -EOPNOTSUPP inode_setsecurity -EOPNOTSUPP setprocattr -EINVAL task_prctl -ENOSYS xfrm_state_pol_flow_match 1 Will send v6 out with these changes. - KP > > #define call_int_hook(FUNC, ...) ({ \ > int RC = FUNC#_default; \ > ... > > > -- > Kees Cook > >