Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp716637rwb; Wed, 9 Nov 2022 07:53:08 -0800 (PST) X-Google-Smtp-Source: AMsMyM54iRmiyaXAeBS6Cb0ozhfLjo/nhCbEfvoF95X+hhrfePVEvYtOA9p47YnJXpZn2Q24hqxC X-Received: by 2002:a17:90b:4d90:b0:213:687d:c0f0 with SMTP id oj16-20020a17090b4d9000b00213687dc0f0mr63732844pjb.212.1668009188413; Wed, 09 Nov 2022 07:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668009188; cv=none; d=google.com; s=arc-20160816; b=oZRFZlQ2r3bFnES86PuuE3ZQYHtW481AyXfdIpKHyyqxZsaj5BMdZ8GkwCKN50Bv6L tbdo6g8f+asIBYUT/cgy4tUnGM6RdCglV19DznROSHbd3ouupTa/5JFd0vRiQeVeUE7x nNZ1cl9hpE0xDdEqN/lH2Fd+2VPjwtdvvw18wmBzZncEZuz6s0wl+U+MQDnXrHdKzUrf G1LhfkD3fTAOeUdoi4sQo6793wPR6I8yoGd4/q7MaR8ZVpGeq74yscn9MpGHdFKr0qCs kQPLEz2NkGI2w7M0qxtQG8VelZquGwQBswCrgQv5V3FUMaN+jaK/AFvf3XFQMU4DQGzS IAzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=nZbMK++Zi47QA66u0FTYx8j/7aiY2h0XjxL4tQKhAUM=; b=AOt+ShrTwqghDTloA9lm9pcrpNE9HemcYLwpbmyXJEor39WdS7bOnd9l29R+zIBS3N hIS7Ntu+/6TcqMQCahIU72w+2OmHrpWOO/HKRGEauEvXckqhtSwkmv113lh0jssAN0VV 2FD4zVBBYSZSYBYQaycRS22C01sFrQk4C5QNw1TfMoCv9fhvyySP6nxfwbhm2uUD4+xq ygvHKb4Is6EC7FcTC1PThM347ujTYVbCBleRz13ZLWmdUBKyexM1hplVhAu3tZAGZg7s yUN/0xCdv1jFCwqlhA2Dw2VyhLkmHqQlJC2Dxd1L2AJciQILgrnHYB25QjcHYL5QHtDJ AAwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170902f7c600b00176d5b20ebesi15838655plw.355.2022.11.09.07.52.56; Wed, 09 Nov 2022 07:53:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231545AbiKIOin (ORCPT + 93 others); Wed, 9 Nov 2022 09:38:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbiKIOil (ORCPT ); Wed, 9 Nov 2022 09:38:41 -0500 Received: from mail.hallyn.com (mail.hallyn.com [178.63.66.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 548CAC76A; Wed, 9 Nov 2022 06:38:36 -0800 (PST) Received: by mail.hallyn.com (Postfix, from userid 1001) id E30EDD55; Wed, 9 Nov 2022 08:38:34 -0600 (CST) Date: Wed, 9 Nov 2022 08:38:34 -0600 From: "Serge E. Hallyn" To: Linus Torvalds Cc: Paul Moore , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, serge@hallyn.com Subject: Re: [GIT PULL] LSM fixes for v6.1 (#1) Message-ID: <20221109143834.GB24561@mail.hallyn.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 31, 2022 at 12:22:29PM -0700, Linus Torvalds wrote: > On Mon, Oct 31, 2022 at 4:07 AM Paul Moore wrote: > > > > A single patch to the capabilities code to fix a potential memory leak > > in the xattr allocation error handling. Please apply for v6.1-rcX. > > Pulled. > > However, I react to the strange test condition. Sure, it's > pre-existing, but does it really make sense? > > It does > > + if (ret < 0 || !tmpbuf) { > + size = ret; > + goto out_free; > + } > > and how the heck can 'tmpbuf' be NULL if vfs_getxattr_alloc() succeeded? I had to go through the history a bit - the !tmpbuf check was added https://www.spinics.net/lists/stable/msg463010.html because of a gcc warning. Perhaps there's a better way to tell gcc that it can't remain NULL if ret was < 0 ? > I think that's not only impossible in the first place, but if it *was* > possible, then that > > size = ret; > goto out_free; > > would be wrong, because this function would return success even if it > wasn't successful. > > That whole "cast to int, and then cast back to size_t" also smells of > some serious confusion in the return value handling. It looks to me > like vfs_getxattr_alloc() fundamentally returns an 'int', not a > 'ssize_t', just by looking at the ->get function. But it just all > looks weird. > > So this code has all kinds of oddities. > > Linus