Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1372344ybi; Fri, 31 May 2019 19:36:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu8RGCPUsVMpwavLqkl31tr/fI7ukRWIL9/tSPw+fvSWORGM1HstzKwqGv7GkRpwXUXagf X-Received: by 2002:a65:458f:: with SMTP id o15mr12800312pgq.376.1559356586131; Fri, 31 May 2019 19:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559356586; cv=none; d=google.com; s=arc-20160816; b=asVFvIyJS1xK8j//qnBQKJVeXN+MGsiMmFydZkGIBYZ/LpwdCJlDgFfl/oEmkNIizI 3+ujMx9J+RiaaMiN8g2UYoAIRnK/yYKf6pif+Mx9AXMaro7Ky4EeO2dn++5ZXrEjUBZH QAnJPdh88ryPwMsBZP8i8WugEruMY6QhgE3blqh2elUo49I2/XAsgu1E2u5ferce1O/6 R5U5/YBw0BRcSXcftbcFs9NSy3Frzg1sg943FI/AKtF9X6daL1cw3YwIei5JYo2pPhmY gnIUO19i3D2/C1uiY01LlTfR1jW7PkHVQNIDybgXHwl9CKvpzMcPIhpn+dSmaFFgsXHS B1+Q== 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; bh=NcKx2AgwuT6g2VtJMSL3rV/OH59gxmwsExukmNe7VrA=; b=wWLUeNmCZVkKcn7BXUa+hf6CQL7bH2VD16AA4byAdeTAyz2/qdi0p3RnJt6xiJsQEy D0C0zHIlC2v8I3fpqpjgBlrcV0zmcWWsl20afhrMn70jGdqfexqWioET4KoUowdS5lZl SaYjjzxHRRoa905E8E039fuwI0PO2SOV0t/d2AsGWbMvMKJB6yhboRbbBeR25oAI0E9V lA5SwsQ8JniFXEHvtWWKzG9wWgY7n1yYdF1WdvrItCC5grxe6ArQz8vIFyrF4tJwG+ZJ Ube1EbWNbR/Rrv4CGlGXxiBobyPJrsPw4D1RHBjpTwakmuVBAB4ZFXbzCv14dn1hGB+5 4H6Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z123si9107859pfz.168.2019.05.31.19.36.08; Fri, 31 May 2019 19:36:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbfFACey (ORCPT + 99 others); Fri, 31 May 2019 22:34:54 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:37734 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbfFACey (ORCPT ); Fri, 31 May 2019 22:34:54 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hWtr7-0004kh-Af; Sat, 01 Jun 2019 02:34:49 +0000 Date: Sat, 1 Jun 2019 03:34:49 +0100 From: Al Viro To: Gen Zhang Cc: paul@paul-moore.com, sds@tycho.nsa.gov, eparis@parisplace.org, omosnace@redhat.com, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v3] selinux: lsm: fix a missing-check bug in selinux_sb_eat_lsm_opts() Message-ID: <20190601023449.GS17978@ZenIV.linux.org.uk> References: <20190601021526.GA8264@zhanggen-UX430UQ> <20190601022527.GR17978@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190601022527.GR17978@ZenIV.linux.org.uk> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 01, 2019 at 03:25:27AM +0100, Al Viro wrote: > On Sat, Jun 01, 2019 at 10:15:26AM +0800, Gen Zhang wrote: > > In selinux_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul(). It > > returns NULL when fails. So 'arg' should be checked. And 'mnt_opts' > > should be freed when error. > > What's the latter one for? On failure we'll get to put_fs_context() > pretty soon, so > security_free_mnt_opts(&fc->security); > will be called just fine. Leaving it allocated on failure is fine... Actually, right now in mainline it is not (btrfs_mount_root() has an odd call of security_sb_eat_lsm_opts()); eventually we will be down to just the callers in ->parse_monolithic() instances, at which point the above will become correct. At the moment it is not, so consider the objection withdrawn (and I really need to get some sleep, seeing how long did it take me to recall the context... ;-/)