Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp777913imm; Thu, 31 May 2018 09:13:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJxe3Tj/WHeSZDThVMcHLs2qDP4MJf9hDi53eoDKsqiKlGN56nSxFLjrXEIzuG6GF7vu9uS X-Received: by 2002:a62:c8a:: with SMTP id 10-v6mr7394597pfm.27.1527783191682; Thu, 31 May 2018 09:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527783191; cv=none; d=google.com; s=arc-20160816; b=1E7ptF8o1J/tXATvQ0zBiH+RBMeqLygCCMfpQKhWR8r010MdbUMI59ifVD1+5NGqpE +EpL877ju6eoBthQcPTypKFFbb1x1avokm/lzK+bW2CTz3kgLl7VrnXmhnT4/3cVz+bV enW9Smymz9WVNogNjAtyBAaDQLRslcv9eNWOF7KEdvmLL0YpYKcZ4ucgNXvaXozJEHlc EbRBMnPMKDlemO4wMgupk0wN1dM7Gx05+1GhLhz4+7/k7tVlse5b1gb65MHGWyhM88PB uoCKO6gSvekLBRaVcIl0HCXWxZVzUEvmK9bBt3HddzOvic2EraxtnUaYqMKlXtGZyK7n S/+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:dkim-signature:arc-authentication-results; bh=sEBCLQ2dJuqkxvxhXY1EgSdaKREmMFHhZG1CccnoPAk=; b=xBbpsWFVxT1Y8GTGxKTqp6+asMxFgipNEn2LHN3WIco4keVGrMm+hD0AXjOIJ1TDvv pB1+l8l4VW2+Npp1fwHiIL+CJPs7AES8LKo52xJV4IzsY0HJf8hYj1wanFOfEiyKJomJ Y3kOvfkGCw6KIjB8/jcSspTZAy3HR+q6z5PeVRW7KACZfAl63jcTl9nhb9kOPXAfnlg8 dYTnAAHLGN0VEYCEC1/0FwvFQYrHzfKqAmEXQ+AV0Kmv/4X9JIa722T3reoXCxCSCLOy meCln/qYult3yRz278WyQ/lehW5eT7gWYNuiBm4pEWK49MsKPck5VsjfWFtbUl7CgLu/ cufA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qj9nqHvb; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w69-v6si13510391pgd.101.2018.05.31.09.12.57; Thu, 31 May 2018 09:13:11 -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=fail header.i=@gmail.com header.s=20161025 header.b=qj9nqHvb; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755727AbeEaQLM (ORCPT + 99 others); Thu, 31 May 2018 12:11:12 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:33286 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755562AbeEaQLK (ORCPT ); Thu, 31 May 2018 12:11:10 -0400 Received: by mail-yw0-f194.google.com with SMTP id u124-v6so6202040ywg.0; Thu, 31 May 2018 09:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sEBCLQ2dJuqkxvxhXY1EgSdaKREmMFHhZG1CccnoPAk=; b=qj9nqHvbXEztCR0I8lIhijj3Af0eNjcqQtb4oYStniP/lfChbu68AcFKDTfqBJHLNQ UutR0LuHlwpms3UhVza9AZLIwa5ycFwv4OSXwoYR6ZSP2MpmJOolOo9p+fKeumOFAJhU Tvhz5hbZP1CWgj3FqYya5H8y0mc34XLeyb4vzaRXUCCjkLyRoHks1RpH9vzj5AeYZLA/ dr/IA0qBSzDmYVYoEnvTCdibtmmULbRsd/KPM3GXiZgWXAEcpvKiuveP+1gvzCACfggm b3zDhMG0JY8WFcK0LqqtObWGfF2fICLUhVv9OwKH25PtNcj6mWupS2bKkvyv8AIYHGVM dYKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=sEBCLQ2dJuqkxvxhXY1EgSdaKREmMFHhZG1CccnoPAk=; b=UiXxCL+8wQ2mRQJhDmL19skvNj1Q6F2pged+/lOEF9zODJLz1GmSb477L487vXIAQc OmcOTVBFL4gtaf3ujDt/Dcrzbqkg23NsQg4nGSObZaClzJ2Jt1JG1lmf1tfvhL9WqgQ/ 2gdz0s+hD+O3jaA+NrDlFpunJWgc7IVJwYT1cR+PTmLLC/vzQj0goRkd7A0ehHsd7Mo4 wBZgeK6Jr4malZ0ViFSVc2ihYUoKhXC8x8mKYqrH7yWmTaRXoTj9qnfdFheKPXf3gXIV B3lAHyK7V8BJdqrDvGNfsXaU+oPo+mOJKy+9Yq2Rk424OEuRS/rLbEnXseV0+ZyjH/wV uhRA== X-Gm-Message-State: ALKqPwefhdSbpU13PnkAhCGYI7uT/xPu8p9zKkWmYHt8JD6IXKruK0ew Jovlnbclr6fFBai224Bmf3g= X-Received: by 2002:a81:53c4:: with SMTP id h187-v6mr4013374ywb.505.1527783069798; Thu, 31 May 2018 09:11:09 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::3:bd3d]) by smtp.gmail.com with ESMTPSA id r64-v6sm5049789ywg.47.2018.05.31.09.11.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 09:11:08 -0700 (PDT) Date: Thu, 31 May 2018 09:11:07 -0700 From: Tejun Heo To: Casey Schaufler Cc: CHANDAN VN , gregkh@linuxfoundation.org, bfields@fieldses.org, jlayton@kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, cpgs@samsung.com, sireesha.t@samsung.com, Chris Wright , linux-security-module@vger.kernel.org Subject: Re: [PATCH 1/1] Fix memory leak in kernfs_security_xattr_set and kernfs_security_xattr_set Message-ID: <20180531161107.GV1351649@devbig577.frc2.facebook.com> References: <1527758911-18610-1-git-send-email-chandan.vn@samsung.com> <20180531153943.GR1351649@devbig577.frc2.facebook.com> <4f00f9ae-3302-83b9-c083-d21ade380eb2@schaufler-ca.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4f00f9ae-3302-83b9-c083-d21ade380eb2@schaufler-ca.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 09:04:25AM -0700, Casey Schaufler wrote: > On 5/31/2018 8:39 AM, Tejun Heo wrote: > > (cc'ing more security folks and copying whole body) > > > > So, I'm sure the patch fixes the memory leak but API wise it looks > > super confusing. Can security folks chime in here? Is this the right > > fix? > > security_inode_getsecctx() provides a security context. Technically, > this is a data blob, although both provider provide a null terminated > string. security_inode_getsecurity(), on the other hand, provides a > string to match an attribute name. The former releases the security > context with security_release_secctx(), where the later releases the > string with kfree(). > > When the Smack hook smack_inode_getsecctx() was added in 2009 > for use by labeled NFS the alloc value passed to > smack_inode_getsecurity() was set incorrectly. This wasn't a > major issue, since labeled NFS is a fringe case. When kernfs > started using the hook, it became the issue you discovered. > > The reason that we have all this confusion is that SELinux > generates security contexts as needed, while Smack keeps them > around all the time. Releasing an SELinux context frees memory, > while releasing a Smack context is a null operation. Any chance this detail can be hidden behind security api? This looks pretty error-prone, no? Thanks. -- tejun