Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp379367pxf; Thu, 18 Mar 2021 02:37:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSnJTICFjyIDP4JC7Qoe4kfH5EDCdR5tdUCLdxPiVgS8J4RowoK+GfsIqs3yNY2n3d42lz X-Received: by 2002:a05:6402:614:: with SMTP id n20mr2458471edv.58.1616060248346; Thu, 18 Mar 2021 02:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616060248; cv=none; d=google.com; s=arc-20160816; b=zFsF8P7gjE1W1yVVUVqW8918IKEvyZBg7kCjv0chDstUt7o1SVxhiAw08TZOSWZGbN ptESUYBjWrkPMbzCDtr3yQnP2Sbxg7qxRiHlJ9ejUrZl2eCTigHp7TCgoiqhyvyQqpy2 otn9nt4Tk72cGUhFJhKzwLNrJWGBHm38L/53h5mC1usJwfZi1WZGZen89u7POrEBu1Ir u1kahvfFrWR2dKLTilHtBjNjuxohfcFon736I5n74N7Xji/V4Qi/7DfPd59ea3ANlaNL XTDdPLHCjpYuqf9saxOsbWtwiOqxUN2KHlgG30Q36npFpobWskocQT4qTI9dCujAcOI1 rkgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=sl7cEhiUIMADl4v3EO8n/srS+Vr5PqbxeqcHQz+xluQ=; b=jviIWHWjkLdrqaPOYxp9WKoOdozqWAeivR+3iet5BwRz34rUG8qpj3xeOGtzREi95h fY+uWbd3oMTY8ot85/Lvnag8ltHPaZxwyVSvJA3fl6BXfXh3S4EdUDEx1vkanRx5mqbI sYaSz401GSFyfdenImtOwktmG5q40Lqw3AFZsya3cJuu4ECkueeBwZ2bTGdke29ZpuAv GDpFjucEGHkJXv232Hns+hF04N3YW3SJTv3my/wHAFyU6qcTN9O/SVX3NRNTHegg7cCi mi7RfkAgTMD7DR7Ne+RhWs6ALzP9dbSE+bX3Lex08JyqUNcScLJSBxUFr0rnAhXUtrcf eWjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 t18si1143720ejj.437.2021.03.18.02.37.05; Thu, 18 Mar 2021 02:37:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229690AbhCRJgc (ORCPT + 99 others); Thu, 18 Mar 2021 05:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbhCRJgX (ORCPT ); Thu, 18 Mar 2021 05:36:23 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 449F4C06174A; Thu, 18 Mar 2021 02:36:23 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lMp4m-0006Ym-56; Thu, 18 Mar 2021 10:36:20 +0100 Message-ID: <54859a03b8789a2800596067e06c8adb49a107f5.camel@sipsolutions.net> Subject: Re: systemd-rfkill regression on 5.11 and later kernels From: Johannes Berg To: Takashi Iwai , Emmanuel Grumbach Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 18 Mar 2021 10:36:19 +0100 In-Reply-To: (sfid-20210318_092815_512625_74D8A8A5) References: (sfid-20210318_092815_512625_74D8A8A5) Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Takashi, Oh yay :-( > we've received a bug report about rfkill change that was introduced in > 5.11. While the systemd-rfkill expects the same size of both read and > write, the kernel rfkill write cuts off to the old 8 bytes while read > gives 9 bytes, hence it leads the error: >   https://github.com/systemd/systemd/issues/18677 >   https://bugzilla.opensuse.org/show_bug.cgi?id=1183147 > As far as I understand from the log in the commit 14486c82612a, this > sounds like the intended behavior. Not really? I don't even understand why we get this behaviour. The code is this: rfkill_fop_write(): ... /* we don't need the 'hard' variable but accept it */ if (count < RFKILL_EVENT_SIZE_V1 - 1) return -EINVAL; # this is actually 7 - RFKILL_EVENT_SIZE_V1 is 8 # (and obviously we get past this if and don't get -EINVAL /* * Copy as much data as we can accept into our 'ev' buffer, * but tell userspace how much we've copied so it can determine * our API version even in a write() call, if it cares. */ count = min(count, sizeof(ev)); # sizeof(ev) should be 9 since 'ev' is the new struct if (copy_from_user(&ev, buf, count)) return -EFAULT; ... ret = 0; ... return ret ?: count; Ah, no, I see. The bug says: EDIT: above is with kernel-core-5.10.16-200.fc33.x86_64. So you've recompiled systemd with 5.11 headers, but are running against 5.10 now, where the short write really was intentional - it lets you detect that the new fields weren't handled by the kernel. If The other issue is basically this (pre-fix) systemd code: l = read(c.rfkill_fd, &event, sizeof(event)); ... if (l != RFKILL_EVENT_SIZE_V1) /* log/return error */ So ... honestly, I don't have all that much sympathy, when the uapi header explicitly says we want to be able to change the size. But I guess "no regressions" rules are hard, so ... dunno. I guess we can add a version/size ioctl and keep using 8 bytes unless you send that? johannes