Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp725093ybg; Sun, 26 Jul 2020 19:57:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLzUOVJ5lnR4prqRNV2+9iK+KnSCSxarQCyAoiAhikuJme2vEwl1mU7ivpiEXJKzzTRiAj X-Received: by 2002:a05:6402:1457:: with SMTP id d23mr7519666edx.149.1595818663129; Sun, 26 Jul 2020 19:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595818663; cv=none; d=google.com; s=arc-20160816; b=EGx5EpypYVej/cIuZElkYAN5XMvV90dutXaAGOfTw+KH7VGjbP88mwKIvLpEIGH4rr OJ3rqYY3C0VeWiycEgbIlgFrj+zOko21aUQHVQyLuA+nSYctPamFuFx9vmUn7EZE9dMu TP4+GBBruPx7DKjwEJ2ew4hBiF3xPyb3mehs9hHXVwUxv5Up123lsKRRwpIxb9im6Lgk /kGN3I07N2DM/EunuCtYzPBuKOjiAkucFvtS7kEq0RqzNBORre8E5xV5N0s7Z9kg7Kxx M4uZ/I0HOO+mhZqvdaFQSUOklIy5mcL8cR5IYFFysG4jQcseNUiUB82LR/vJ0JCvYhEv LmTA== 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=gW2ZCBB75z7PFV2ceVpD5H0LoJh+q6fVX6hqzsrd8vw=; b=MZE9utp0zraK3bu4Jn5+9YQFT3FtjGbkMtWY8xnrpPWj/Oyfa472mKXvPOEWSrA2gq wWAP3EPOth+mIlh3+8ZSZWjK8aJMsDZPwxrOXqvTuyu1dAa/LQghMZNhmrbcl22yZfMB fuhSo/MvezwHZkiOyEUUz2x1edMY+mKVUpagkAplFM5JtmecnKMI00ZC4QaL5BzCVx2z j6ANWoA1T3SQDEpeMc/dUoBljIE+E+kca2Jr65JH9UZUbyeC9zv38PIWSwUS6v+SqBRy 0yCZVS4RA7jVRKCXF/tq97lBoRAra7Gcm2dMFqZRi0Ehwln/Ta/2+r+N9G25sxAed5oQ yR9Q== 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 bu5si5051096edb.553.2020.07.26.19.57.21; Sun, 26 Jul 2020 19:57:43 -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 S1727917AbgG0CzK (ORCPT + 99 others); Sun, 26 Jul 2020 22:55:10 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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).