Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp44856pxb; Thu, 15 Apr 2021 22:17:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz436PTcRLB9l/GuPpgkW8P0tmwFuCK/w+lqJ6MXKsxcS+0z4QykcRSYIQQVEHxLTCZlo4 X-Received: by 2002:a05:6402:35c8:: with SMTP id z8mr8008699edc.341.1618550269313; Thu, 15 Apr 2021 22:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618550269; cv=none; d=google.com; s=arc-20160816; b=KWXoAN5bvuwlVuSTVpj4NYM7pcahDyLuqT9xYiNmkaQmmQqkBboZqgs98FJQssBKv5 DyfZJXFzZ9y5U5mJaXeRzwLsHG/uhjdewCSJDP5NTFZlOWANjVTzWHk82q9RiORShF// f8fE9u1m9Wu3oAdBiUkqF8o3G5WoApOgYNpm+Sm6g90Cv9zZWsrasu70Ugz1marvpPKk tIK8WxYMJI4VOzb+1u+UAfLK3QZmAd+FyQYArc+B5nBolH+XONB+1ttq7rJflTt07fkh UbToVOtAuvjGNvTq2l5eJKmYTxeb6gXwiFb59zy4tG4qg44221qjqX5U18oISDsk7UrR inEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=bkL6RyxNV2vxepViy4Z4WN2+hyZKSGOyjG8as5sFhOE=; b=C9EYLaaou5u6/2gBHghlhUKzfaD9VjBYdNlbWySG33HUan6++lrboB3lhjm0Y5u+Ug SGIQIDvnwhVvVns+48KXGpANe74ri9eEKn3Bd77HwAsHGn+fXHO2kjaB1DyuhYAb8pt+ TBqa2J056s9Aoc4scjXlGGeJqXLMbDKnA3tD9mCnrEkLYgB6Qn6/ySa4f/TY/WGKfCql Qn8HqghUbXgfLYR2EqocxB6mFP22uyWVd1D6EbdD4/a2cOzOt2JzNFkTllDMUJURrJtd XjB93Wi7sRSm93D4qiu0BW8W882/8/zt+Nw/8u5nJBYcYdFRprM6VYxZ7ZFmE18Vw9VL Hykw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 27si4010241ejx.312.2021.04.15.22.17.04; Thu, 15 Apr 2021 22:17:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238010AbhDPDih (ORCPT + 99 others); Thu, 15 Apr 2021 23:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234816AbhDPDig (ORCPT ); Thu, 15 Apr 2021 23:38:36 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C8CBC061574; Thu, 15 Apr 2021 20:38:13 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lXFJ3-005fLg-Lp; Fri, 16 Apr 2021 03:38:09 +0000 Date: Fri, 16 Apr 2021 03:38:09 +0000 From: Al Viro To: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , Andy Lutomirski , Will Drewry Subject: Re: [PATCH] fs: split receive_fd_replace from __receive_fd Message-ID: References: <20210325082209.1067987-1-hch@lst.de> <20210325082209.1067987-2-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210325082209.1067987-2-hch@lst.de> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 25, 2021 at 09:22:09AM +0100, Christoph Hellwig wrote: > receive_fd_replace shares almost no code with the general case, so split > it out. Also remove the "Bump the sock usage counts" comment from > both copies, as that is now what __receive_sock actually does. Nice, except that you've misread that, er, lovely API. This > -static inline int receive_fd_replace(int fd, struct file *file, unsigned int o_flags) > -{ > - return __receive_fd(fd, file, NULL, o_flags); > + return __receive_fd(file, NULL, o_flags); > } can get called with negative fd (in which case it turns into an alias for receive_fd(), of course). As the result, that ioctl got broken in case when SECCOMP_ADDFD_FLAG_SETFD is not set. Trivially fixed by having the only caller check the damn condition and call either receive_fd_replace() or receive_fd().