Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5135440ybp; Mon, 14 Oct 2019 16:09:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxn4dr5QmM8u4xqCkJcY0CjG5doPY28XHcjbyvGy/zlWHHDLDHfLs8kEA3cgw25C34Kv00q X-Received: by 2002:a17:906:9487:: with SMTP id t7mr31017155ejx.231.1571094592265; Mon, 14 Oct 2019 16:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571094592; cv=none; d=google.com; s=arc-20160816; b=zn4nKZsynTuxiUA/aUHs5pjpllMSW4HBBNFx2964HBwljiRH2MAKEsEOujo7Mwfl8A /kJr2T8F+DA0ErKBGMxtpPh58kjdMXoRa4N4bu13rMrRm/JE9Ry8p1TakM8SyFsOZe0G 1oNfxxj+vwEIGaTwA3ZBfXYnmidDKlmCDQI55R1ShaspPQ/wiBlFYpnV8JgYjgaaF/FK 0R3gF8ciNk3gxHuUkV6OMOFLEP1WZuXWI66vEGQ913dVjfsKo+MlrFuhCKhrerrUo4Lh OYgF3PbKjYG25zlXxf/s3rOTsjM/Q0vtyLL+WEkdRCNEwZ9tbWEIoqT0QbC5P+NdubVr 4r2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=MIBRcx0ifowvcR39u0o/yTqzRxoaaM/WNcTZ/tvS6ro=; b=txl/YZl8y7CuexiZ+KCtttNo+lCy6INxI64GxdQD2sjjaCNSjDIexycHVriM8WeBxj lls5DG14ewWaunpDYMS3gQQ8DtfwZxxCahYqXOCgYpSxLMsg3H/FoHhc91mDwkbudor3 VFx+J2XmSy9e9dEzw7FFm780i1mNVXghMVfRMzM7Ua8GYz+fAxq4+CCFZ8/f8XPf9sXV s1WgqgKwWR2FF5ZVvUtmP+z1C5/RUN1QY25Wrc0xhkuVsEFVQWcuJl9hUb/g9GOt6tGG SiQQdLnwaqwWnvKKQwtvKOE+m13QwJIzKjC7xEsw1ygGEoP05WiOBxAS1xGxoD3bL7xY A12Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OeWJRcUg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si15506704eda.8.2019.10.14.16.09.29; Mon, 14 Oct 2019 16:09:52 -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=@google.com header.s=20161025 header.b=OeWJRcUg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388744AbfJNSQJ (ORCPT + 99 others); Mon, 14 Oct 2019 14:16:09 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:40445 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731955AbfJNSQJ (ORCPT ); Mon, 14 Oct 2019 14:16:09 -0400 Received: by mail-oi1-f193.google.com with SMTP id k9so14534949oib.7 for ; Mon, 14 Oct 2019 11:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MIBRcx0ifowvcR39u0o/yTqzRxoaaM/WNcTZ/tvS6ro=; b=OeWJRcUgEFxmkHpbnahx0BDp6S/Ozy0Bl3rOrSHIseNZuZLmKTZEQBNd0C4sfgGnzi t+w0+A7CFBRljCV40IDvG0WrnfNWMxa46gF7l6TDTUxKIXMEdaIjJYlnXNTSfJf7gQi7 iPpIy+HoaNN7lu7ME5QtEtS4EYWCPxlIwVK1KQJDQ4a4ILsMgCUUMwtUj0U1/8qkx6Pu ePCKTenz99fyKckB6S736oaiKJ5l81f8n5VJReMhYfwQQJYn/9MVoIOpzbxUIdOHBfFc m2/gS7idPQA6uGdH74+QYKnFYK4bJ7JxKEwdYkOjcLSnlitIlGJGO0uMtz/CoYYYXbhC C6qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MIBRcx0ifowvcR39u0o/yTqzRxoaaM/WNcTZ/tvS6ro=; b=lZe68QdoVr765Ph5ntrGEbtlLsnJ07XsIVk28SXqlGgVngUIqMai68RqVeMciVw7Th b84RDdSRM4E9d9IcHwCEUwcMM3XJpkQvH7IPl5Rh+QRG72EYS+FthyTkDxWPdAj7yG3l n9cnwgxEkaFMBlt2rjvEeCkPDg+dwb8W4+6vW2cDoEmQh0YAztMxz9RDbARt03d3Y5lC TT/gegVDZlz2oJqEpllZE8GsNDMG8r5L9OR5R9c/gjC+Ne7Owbp8jLeswQ+MnUPPRDL0 Hgdg6EVU0Z6nIGDtlIkG0v5wPwKPZmexql4lR7KvpMWFfweFgNBAx7jirMnfgYpvJcPe pnUg== X-Gm-Message-State: APjAAAWJHaqX3Kww7FvIc7/nRJJa1UWamRWJFDpVJwxCoIL/1nCFjOZD Y7+oASbo1CMHerSU89YJS7VcUdkkpGs6Kx1TFHXtvVuuI3U= X-Received: by 2002:aca:4557:: with SMTP id s84mr25179212oia.101.1571076967291; Mon, 14 Oct 2019 11:16:07 -0700 (PDT) MIME-Version: 1.0 References: <20191012191602.45649-1-dancol@google.com> <20191012191602.45649-2-dancol@google.com> In-Reply-To: From: Daniel Colascione Date: Mon, 14 Oct 2019 11:15:30 -0700 Message-ID: Subject: Re: [PATCH 1/7] Add a new flags-accepting interface for anonymous inodes To: Jann Horn Cc: Linux API , kernel list , Lokesh Gidra , Nick Kralevich , Nosh Minwalla , Tim Murray Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for taking a look On Mon, Oct 14, 2019 at 8:39 AM Jann Horn wrote: > > On Sat, Oct 12, 2019 at 9:16 PM Daniel Colascione wrote: > > Add functions forwarding from the old names to the new ones so we > > don't need to change any callers. > > This patch does more than the commit message says; it also refactors > the body of the function. (I would've moved that refactoring over into > patch 2, but I guess this works, too.) > > [...] > > -struct file *anon_inode_getfile(const char *name, > > - const struct file_operations *fops, > > - void *priv, int flags) > > +struct file *anon_inode_getfile2(const char *name, > > + const struct file_operations *fops, > > + void *priv, int flags, int anon_inode_flags) > > (AFAIK, normal kernel style is to slap a "__" prefix in front of the > function name instead of appending a digit, but I guess it doesn't > really matter.) I thought prefixing "_" was for signaling "this is an implementation detail and you probably don't want to call it unless you know what you're doing", not "here's a new version that does a new thing". > > { > > + struct inode *inode; > > struct file *file; > > > > - if (IS_ERR(anon_inode_inode)) > > - return ERR_PTR(-ENODEV); > > - > > - if (fops->owner && !try_module_get(fops->owner)) > > - return ERR_PTR(-ENOENT); > > + if (anon_inode_flags) > > + return ERR_PTR(-EINVAL); > > > > + inode = anon_inode_inode; > > + if (IS_ERR(inode)) > > + return ERR_PTR(-ENODEV); > > /* > > - * We know the anon_inode inode count is always greater than zero, > > - * so ihold() is safe. > > + * We know the anon_inode inode count is always > > + * greater than zero, so ihold() is safe. > > */ > > This looks like maybe you started editing the comment, then un-did the > change, but left the modified line wrapping in your patch? Please > avoid that - code changes with no real reason make "git blame" output > more annoying and create trouble when porting patches between kernel > versions. I'll fix it. > > [...] > > EXPORT_SYMBOL_GPL(anon_inode_getfile); > > +EXPORT_SYMBOL_GPL(anon_inode_getfile2); > [...] > > EXPORT_SYMBOL_GPL(anon_inode_getfd); > > +EXPORT_SYMBOL_GPL(anon_inode_getfd2); > > Since anon_inode_getfd() is now a static inline function in > include/linux/anon_inodes.h, exporting it doesn't make sense anymore. > Same for anon_inode_getfile(). I didn't want to break modules unnecessarily. Declaring the function inline and also exporting it gives us an efficiency win while avoiding an ABI break, right? > [...] > > +#define ANON_INODE_SECURE 1 > > That #define belongs in a later patch, right? Yep.