Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp493748ybt; Fri, 10 Jul 2020 05:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy9ec2LGLyjU7jlZS4Jw/iNjqJ3yXPNfwMmW+bd1bCT39wcT0lqL9cEhOgAWRK5AuPCoA8 X-Received: by 2002:aa7:d4d2:: with SMTP id t18mr50294723edr.166.1594383618866; Fri, 10 Jul 2020 05:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594383618; cv=none; d=google.com; s=arc-20160816; b=pKk/Mx5+dj4YJt7AeevJVeiKsaurHpDl8bV+LNH+J+nvNEkv4mS8Ljatg33sv3Bwrq ihpFrMQAbxhRgEqX+gzwSj0zLWThgHDHHwetaQQ5RdHu9VGOBBrJEEvLj2UN5g4KbNQa dJdEk7IvEv+foMWHx5GWlk/vyXvOWM81qtkwXHElxW4zfrKJe9pthL33ITQ0+vmJYoGO kDXlRk1FCzq9bBz2Oe42ZzPFzCHmNBmLCZ2ZNxaHR+dig0hAUPmYHBI0qxyeUvBHlWF3 rPmtTPkh2OTCkoWOMLKqXlqUWuk1+OTEvf2yFRYFNUU2iQC2WcH6ncKv9CF1XIcXa6bN +slQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GDI5gaHeKtEkNIVvJp+RI8TlF3xZHXMiFj+nmfZcwvE=; b=xxJ21LYgS42eABaXlFjJU6yyXn1z9onCKCdsGb6R9SDC6WjoEhhmuj0EdPuzxKP0Ia AcbvhmJqraKsMI2Rnw+Tls9+EwtS8Ijl2w2a7mnYQaI/YPKwCkGv73FejjYaM9slyFyj kQbmd6mKE/LctXCcHJDFwqPZFWycCIxCMQzUCc4TcwKd5BpRIBKFsRN3lY+YUtyL70QI Nz3YyVfwHp1xXTTfJ6/g1NZPLY27gvvmhc98zzGpZcmqMHpEiq2y9OD7IFmjdX39eztH 5JRgIvfoXM75ma13grz/kzzbvOi6JxvQhU+zgPwaBRauDVS2NMSiIGbLCRdWnZH4S/ll CM3g== 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 g7si3673734ejr.748.2020.07.10.05.19.55; Fri, 10 Jul 2020 05:20:18 -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 S1727771AbgGJMTZ (ORCPT + 99 others); Fri, 10 Jul 2020 08:19:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:38280 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbgGJMTZ (ORCPT ); Fri, 10 Jul 2020 08:19:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EB156AC46; Fri, 10 Jul 2020 12:19:23 +0000 (UTC) Date: Fri, 10 Jul 2020 14:19:23 +0200 From: Petr Mladek To: Bruno Meneguele Cc: linux-kernel@vger.kernel.org, sergey.senozhatsky@gmail.com, torvalds@linux-foundation.org, Jason@zx2c4.com Subject: Re: [PATCH] doc:kmsg: explictly state the return value in case of SEEK_CUR Message-ID: <20200710121923.GO4751@alley> References: <20200709155415.41207-1-bmeneg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200709155415.41207-1-bmeneg@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2020-07-09 12:54:15, Bruno Meneguele wrote: > The commit 625d3449788f ("Revert "kernel/printk: add kmsg SEEK_CUR > handling"") reverted a change done to the return value in case a SEEK_CUR > operation was performed for kmsg buffer based on the fact that different > userspace apps were handling the new return value (-ESPIPE) in different > ways, breaking them. > > At the same time -ESPIPE was the wrong decision because kmsg /does support/ > seek() but doesn't follow the "normal" behavior userspace is used to. > Because of that and also considering the time -EINVAL has been used, it was > decided to keep this way to avoid more userspace breakage. > > This patch adds an official statement to the kmsg documentation pointing to > the current return value for SEEK_CUR, -EINVAL, thus userspace libraries and > apps can refer to it for a definitive guide on what to expected. > > --- a/Documentation/ABI/testing/dev-kmsg > +++ b/Documentation/ABI/testing/dev-kmsg > @@ -56,6 +56,11 @@ Description: The /dev/kmsg character device node provides userspace access > seek after the last record available at the time > the last SYSLOG_ACTION_CLEAR was issued. > > + Considering that the seek operation is supported but has > + special meaning to the device, any attempt to seek specific > + positions on the buffer (i.e. using SEEK_CUR) results in an > + -EINVAL error returned to userspace. Sigh, I see that devkmsg_llseek() returns -ESPIPE when offset is not zero. This is a real mess. I wonder if we could afford to switch this one to -EINVAL and reduce the mess. Anyway, for a random reader, it might be pretty unclear what is exactly special about /dev/kmsg. I wonder if the following might be more explanatory and strightforward: Other seek operations or offsets are not supported because of the special behavior. The device allows to read or write only whole variable lenght messages that are stored in a ring buffer. Because of the non-standard behavior also the error values are non-standardand. -ESPIPE is returned for non-zero offset. -EINVAL is returned for other operations, e.g. SEEK_CUR. This behavior is historical and could not be modified wihtout the risk of breaking userspace. Finally, only few people read documentation. We should add some warning also to the code. I think about a something like: /* * Be careful when modifying this function!!! * * Only few operations are supported because the device works only with * the entire variable length messages. Non-standard error values are * returned in the other cases. User space applications might depend * on this behavior. */ Best Regards, Petr