Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1178000rwi; Wed, 19 Oct 2022 07:34:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MGifwFO054FDXEJnXxlEpRrCrFPTuzXNfwyc7p5JrOWH/hME1QgGAxDQlq13U4LgBq8nD X-Received: by 2002:a05:6402:ea8:b0:456:d188:b347 with SMTP id h40-20020a0564020ea800b00456d188b347mr7818692eda.15.1666190052323; Wed, 19 Oct 2022 07:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666190052; cv=none; d=google.com; s=arc-20160816; b=RQ37GlNQHFza5Vva9Wav9DaMYFQH8q0r9b/yxWgM1vHf2kg2pM7rjU+tfJ5KARPAoN P/9VA7YXwDhyac8C6CCW+TnvqxZlr+z/1EA9502n2TkGNA2ixTFdK1Tgx6YMWcFr/ir1 GBVwkTEk4Fo/WUVAp7BYVXn5lL+2D+nPjxbMvmoPqfK5MZDfNGmSkd5UPRkI2OlPyaNp lnMfqFFStPXALPbBLxZjK2F6W5OWGITqdHS/LdaypzqEpuj5tiSPR7f7vHYEP8nAVreq C75+P6C8Jlv7xWY0weqt5LQZNKVBSq3oUvbUHpxgZIjlcIeIdlYKAijKoEYl2jFhM/LL 2n6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:in-reply-to:mime-version :user-agent:date:message-id:subject:autocrypt:from:references:to; bh=QKuR3HYN8/TROcIyMc8fUlKPMEYl+seOWe6ZUddrJ3o=; b=QIADts7P6ZiSb6BxqWg0sn89h8+uG22ZF4ODIVX+3r/N90m2dMDZwUd40gPFuC5hV+ V66Ti5baBj/WJDHwdyAigVRod4/GFBdu3MHqx0mPxqP/9tYhBNHTnxygG8mdx0w4QW/U 70i0rFNLaCWCPCr7+CJhS8lsyXM6i0OidCjuNSdyfJWln+YBnw1htR9x4k3SAUI78nbC bv/I7VOo+YVxATEnnpK3nIMW6SQnLSe2Oc3TOqlN3uVfaMV9esdh6CN5gs3LNJ1RoExQ vsMxGPuBwuPx7+kfnCTVg7CVK9JzjYIn0PCM4gGZyF8xMlOTfX4mHT4CnqtzNHz9G8hB v1mQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a1709064d4e00b0078dc7dab177si12553793ejv.311.2022.10.19.07.33.43; Wed, 19 Oct 2022 07:34:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232413AbiJSNNd (ORCPT + 99 others); Wed, 19 Oct 2022 09:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbiJSNNN (ORCPT ); Wed, 19 Oct 2022 09:13:13 -0400 Received: from a.mx.secunet.com (a.mx.secunet.com [62.96.220.36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9939A53003 for ; Wed, 19 Oct 2022 05:58:17 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 4F08B204D9; Wed, 19 Oct 2022 14:50:43 +0200 (CEST) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mGVPu9q_G-D8; Wed, 19 Oct 2022 14:50:42 +0200 (CEST) Received: from mailout1.secunet.com (mailout1.secunet.com [62.96.220.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id AFEBD20184; Wed, 19 Oct 2022 14:50:42 +0200 (CEST) Received: from cas-essen-01.secunet.de (unknown [10.53.40.201]) by mailout1.secunet.com (Postfix) with ESMTP id A9B3980004A; Wed, 19 Oct 2022 14:50:42 +0200 (CEST) Received: from mbx-essen-02.secunet.de (10.53.40.198) by cas-essen-01.secunet.de (10.53.40.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 14:50:42 +0200 Received: from [10.36.110.53] (10.36.110.53) by mbx-essen-02.secunet.de (10.53.40.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 14:50:42 +0200 To: Petr Vorel , , Andrew Morton , Kroah-Hartman References: <0c2b92a6-0f25-9538-178f-eee3b06da23f@secunet.com> From: Torsten Hilbrich Autocrypt: addr=torsten.hilbrich@secunet.com; prefer-encrypt=mutual; keydata= mQENBFs5uIIBCAD4qbEieyT7sBmcro1VrCE1sSnV29a9ub8c0Xj0yw0Cz2N7LalBn4a+YeJN OMfL1MQvEiTxZNIzb1I0bRYcfhkhjN4+vAoPJ3q1OpSY+WUgphUbzseUk/Bq3gwvfa6/U+Hm o2lvEfN2dewBGptQ+DrWz+SPM1TQiwShKjowY/avaVgrABBGen3LgB0XZXEH8Q720kjP7htK tCGRt1T+qNIj3tZDZfPkqEVb8lTRcyn1hI3/FbDTysletRrCmkHSVbnxNzO6lw2G1H61wQhw YVbIVNohY61ieSJFhNLL6/UTGHtUE2IAicnsUAUKR8GiI1+3cTf233O5HaWYeOjBmTCLABEB AAG0L1RvcnN0ZW4gSGlsYnJp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iDga1K4H2HzHAqlvfzCurqe616S4S1ax+erg3KTEXylxmzcFjJU8AUZURy/lQt VElzs4Km1p3v6GUciCAb+Uhd12sQG2mL05jmEems9uRe3Wfke/RKp8A+Yq+p6E0A0ZOP+Okm LXB2q+ckPvZG Subject: Re: v6.1-rc1: Regression in notification of sethostname changes Message-ID: Date: Wed, 19 Oct 2022 14:50:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------8E72B37259581E8BD9D09621" Content-Language: en-US X-ClientProxiedBy: cas-essen-02.secunet.de (10.53.40.202) To mbx-essen-02.secunet.de (10.53.40.198) X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --------------8E72B37259581E8BD9D09621 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On 19.10.22 14:31, Petr Vorel wrote: >> Hi Torsten, > >>> Hello Petr, > >>> your commit > >>> commit bfca3dd3d0680fc2fc7f659a152234afbac26e4d >>> Author: Petr Vorel >>> Date: Thu Sep 1 21:44:03 2022 +0200 > >>> kernel/utsname_sysctl.c: print kernel arch > >>> Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch. > >>> This helps people who debug kernel with initramfs with minimal environment >>> (i.e. without coreutils or even busybox) or allow to open sysfs file >>> instead of run 'uname -m' in high level languages. > >>> broke the notification mechanism between the sethostname syscall and the pollers of /proc/sys/kernel/hostname. > >>> The table uts_kern_table is addressed within uts_proc_notify by the enum value, however no new enum value was added in "enum uts_proc". > >>> I noticed the problem when journald-systemd failed to detect hostname changes made with the sethostname syscall (as used by the hostname tool). >>> When setting the hostname through /proc/sys/kernel/hostname the poll notification was working. > >> Thanks a lot for your report, working on a fix! >> Andrew, Greg, sorry for a regression. > > Hi Torsten, > > could you please post exact steps to reproduce the problem. > Although the required fix to add new enum into enum uts_proc is trivial, > I was not able to reproduce the problem with 6.1.0-rc1 (actually > 6.1.0-rc1-4.g1d716d8-default which contains few extra patches). > > # hostname; hostnamectl hostname; cat /proc/sys/kernel/hostname > opensuse-tumbleweed.20221001 > opensuse-tumbleweed.20221001 > opensuse-tumbleweed.20221001 > > # hostnamectl set-hostname foo; echo $? > 0 > # hostname; hostnamectl hostname; cat /proc/sys/kernel/hostname > foo > foo > foo > > # hostname bar; echo $? > 0 > # hostname; hostnamectl hostname; cat /proc/sys/kernel/hostname > bar > bar > bar > > # echo "baz" > /proc/sys/kernel/hostname > # hostname; hostnamectl hostname; cat /proc/sys/kernel/hostname > baz > baz > baz > > > # hostnamectl set-hostname foo; reboot > After reboot it's 'foo'. > What am I missing? > > BTW I originally tested the feature only on dracut initramfs (with rapido [1]), > which obviously bypass systemd. For a fix I'm creating rpm package (binrpm-pkg). The problem is happening in the systemd-journald poll notification. I was checking for the problem by attaching gdb to the running systemd-journald and setting a breakpoint to the server_cache_hostname function. This function is triggered via dispatch_hostname_change whenever the hostname changes. This is done via sd_event API in systemd. Here is an example program for this functionality without any further dependency: #include #include #include #include #include int main() { struct pollfd info; info.fd = open("/proc/sys/kernel/hostname", O_RDONLY); info.events = 0; info.revents = 0; while (true) { int res = poll(&info, 1, -1); if (res > 0) { if (info.revents != 0) { char buffer[64]; gethostname(buffer, sizeof(buffer)); printf("Hostname has changed to: %s\n", buffer); } } } } I have also attached this program. If you call this program and issue calls of the hostname utility to change the hostname some message should be printed. Torsten --------------8E72B37259581E8BD9D09621 Content-Type: text/x-csrc; charset="UTF-8"; name="hostname-poll-test.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="hostname-poll-test.c" #include #include #include #include #include int main() { struct pollfd info; info.fd =3D open("/proc/sys/kernel/hostname", O_RDONLY); info.events =3D 0; info.revents =3D 0; while (true) { int res =3D poll(&info, 1, -1); if (res > 0) { if (info.revents !=3D 0) { char buffer[64]; gethostname(buffer, sizeof(buffer)); printf("Hostname has changed to: %s\n", buffer); } } } } --------------8E72B37259581E8BD9D09621--