From owner-freebsd-current@freebsd.org Mon Apr 19 09:06:42 2021 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 79D095EA06A for ; Mon, 19 Apr 2021 09:06:42 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FP1CP4Kncz3QkB; Mon, 19 Apr 2021 09:06:41 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: by mail-ed1-f54.google.com with SMTP id d21so19633642edv.9; Mon, 19 Apr 2021 02:06:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=xNmn0omlLqLdDhnXTAl163et+gE9H1Vzv2l3eDy+xxw=; b=hpeCNQ0iJ+30mPDy4F+nfWVxKnAsRkuntpn6lqME8Rh28Cdf8VNzjKViITsOuzu2Ke aFdHAGi+stoaahAOt+ipjpYrUIQVSCyi/aNImNmGtsnKitR6uZojWcRv3E81bY2cPucv pUH9fQWayFXSXPmuPU3Cl/yTGHAv+rU4RrRn04Q6iH7b3T3olNh+zBZsSCroM/eyTfDP K0r8ybrHZHkWbXVGTknKcbyq4jXNF5Kflzr1VenQxppYQYiD+ZQJuFneJM/Rbyz7X3Wd oUarsIGb4aaVUoykH+IrrnKiyK7JeWzZW4sUMrL5zCnhIVyZA0kVBxmfPwz/A8IQTyrq z+NA== X-Gm-Message-State: AOAM530BEUuAnjQQRMIL0tBypatlEwtN/Y9+nVFGHIq398ypHJa66duo acGRVea5w5IAn8r8+hpvtlPj5mJBMKI8Qg== X-Google-Smtp-Source: ABdhPJz5mx4NSNVJF4p5VWM3HIJScWvtplEpvla7LwzMD9SferD8JJ/elp8pkOQRV4ccAN2NdlRtDA== X-Received: by 2002:aa7:c511:: with SMTP id o17mr23524693edq.335.1618823199907; Mon, 19 Apr 2021 02:06:39 -0700 (PDT) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com. [209.85.221.49]) by smtp.gmail.com with ESMTPSA id f20sm6725323ejw.36.2021.04.19.02.06.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Apr 2021 02:06:39 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id p6so26435696wrn.9; Mon, 19 Apr 2021 02:06:39 -0700 (PDT) X-Received: by 2002:a05:6000:8b:: with SMTP id m11mr6603335wrx.224.1618823199376; Mon, 19 Apr 2021 02:06:39 -0700 (PDT) MIME-Version: 1.0 References: <2160831618773765@mail.yandex.ru> In-Reply-To: <2160831618773765@mail.yandex.ru> From: Alexander Richardson Date: Mon, 19 Apr 2021 10:06:28 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: NSS issues after locking fixes To: =?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCd0LXQtNC+0YbRg9C60L7Qsg==?= Cc: freebsd-current , Brad Davis Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4FP1CP4Kncz3QkB X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of arichardsonkde@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=arichardsonkde@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[arichardson@freebsd.org,arichardsonkde@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.208.54:from]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_NEQ_ENVFROM(0.00)[arichardson@freebsd.org,arichardsonkde@gmail.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; SPAMHAUS_ZRD(0.00)[209.85.208.54:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.208.54:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.208.54:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-current] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2021 09:06:42 -0000 On Sun, 18 Apr 2021 at 20:58, =D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0= =B4=D1=80 =D0=9D=D0=B5=D0=B4=D0=BE=D1=86=D1=83=D0=BA=D0=BE=D0=B2 wrote: > > Hi All, > > After supposed locking fixes done in this commit: 5245bf7b92b74e556527b49= 16a8deba386fe5772 > we have a broken nsdispatch(3) when system has a threaded nss module plug= ged in. > > To illustrate the problem: > > $id bland > id: bland: no such user > t$LD_PRELOAD=3D/usr/lib/libthr.so id bland > uid=3D1001(bland) gid=3D500(domainusers) groups=3D500(domainusers),... > > $cat /etc/nsswitch.conf > group: files ldap > hosts: files mdns dns > netgroup: comapt > networks: files > passwd: files ldap > shells: files > services: files > protocols: files > rpc: files > > It seems that the commit in question was done under asumption that thread= ing model can never be changed during run-time, while previous code was tak= ing care of it by taking a copy of __isthreaded. > > I can not reach out Alex Rechardson who authored this change. Perhaps som= eone else can step in and take care of it? > > Thanks, > Alexander. Hi Alexander, I was away over the weekend so I wasn't able to revert it then. I've committed the revert as https://cgit.freebsd.org/src/commit/?id=3D738314e445ceac4d3dd6c77c636044141= 623b8dc and I am not convinced that __isthreaded changing is the real problem. This can only happen with fork() (which calls _thr_setthreaded(0)) since if it's currently false, the main thread is executing and we can't be spawning a new thread. I think the problem could be that fork() is called while the lock is held in one thread and therefore the new process ends up with a locked rwlock. I think the solution could be to add a pthread_atfork() callback that unlocks the rwlock. Sorry for the breakage! Alex