From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A305C433E1 for ; Mon, 27 Jul 2020 02:55:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2052220715 for ; Mon, 27 Jul 2020 02:55:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727897AbgG0CzJ (ORCPT ); Sun, 26 Jul 2020 22:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbgG0CzJ (ORCPT ); Sun, 26 Jul 2020 22:55:09 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86A78C0619D2; Sun, 26 Jul 2020 19:55:09 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jztIB-003NQO-S9; Mon, 27 Jul 2020 02:55:07 +0000 Date: Mon, 27 Jul 2020 03:55:07 +0100 From: Al Viro To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, "H. Peter Anvin" , Song Liu , Linus Torvalds , linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 17/23] initramfs: switch initramfs unpacking to struct file based APIs Message-ID: <20200727025507.GC795125@ZenIV.linux.org.uk> References: <20200714190427.4332-1-hch@lst.de> <20200714190427.4332-18-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200714190427.4332-18-hch@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jul 14, 2020 at 09:04:21PM +0200, Christoph Hellwig wrote: > - ssize_t rv = ksys_write(fd, p, count); > + ssize_t rv = kernel_write(file, p, count, &file->f_pos); No. Sure, that'll work for ramfs with nobody else playing with those. However, this is the wrong way to do such things; do *NOT* pass the address of file->f_pos to anything. The few places that still do that are wrong. As a general rule, ->read() and ->write() instances should never be given &file->f_pos. Address of a local variable - sure, no problem. Copy it back into ->f_pos when they are done? Also fine. But not this, Keep that offset in a variable (static in file, argument of xwrite(), whatever).