Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp465223rdb; Thu, 5 Oct 2023 10:56:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhenLBDe2nVgIWz0DefUQmmSOrvbZC2Uu7hN3CpFbdya1eOGobjGj5FteUAu4FGhv2nV3f X-Received: by 2002:a05:6358:7e07:b0:139:c75f:63eb with SMTP id o7-20020a0563587e0700b00139c75f63ebmr6315596rwm.21.1696528600919; Thu, 05 Oct 2023 10:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696528600; cv=none; d=google.com; s=arc-20160816; b=QWjyJiw9Dgn7tDWCVE+M1i7j9hzfEqm5LJ1l/unMdUCvkZF9ozj3f9TcgXNWZlrWoM V4XDNxFdAohJHwf0wasj3XNLijPGarSJ6OFfavzB27GwIfbS+b0imfCtCBogDPJbQ1LD mAHUYbKsUWXaGKD+eZcfeTI6Bb/jBMDqw8iW3C8h8PnIHjutbVyYNUr9z6WjrRXvYBuX XcS3tMasHLX3DHYUIqnNS2Kp2RFz684V3mBR4a4GAvboqzC53xlOFs12ocSmYKkevb2c K1bU77/SmA4yPnGPGh3gVCsdXXS2TiILp/KWwUak0cjQx5w4I9xMynEEalA30GNnCGQ+ 6VfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GMAYWu6s5jgJfytNXvk2jc8sZheLLSMNR+isOuI846I=; fh=BwVUpj1L5YCEoAXraaMUzREx5HQvyFMNY5mR4grDcG4=; b=zBhuCujOSPDvOLGoz1BjgDHY7L23/lmSmraYjopP5h+tElGw4zwlNTIC/xwhNZLM2u SKNEIlMdZUEnGv7Y098ZGIPkvQUP5WEuW/D8XQguZIALK4n0oqmAWomFYCiQJKZ8UL6w MUYiHRunOczHizg8Bi6jwvEJZIhRykK5Esu4TXV/nOpNcIfXmLxlQfayutiWfMpAwdhb edNAq27UxiPiCXBxrdbrBoANmvTUVIXMAgPJo4oTjnE78cPX5k6KeZXtQQqZM5c0v22e 3gvRlLWMuAD6kLgwXMT+KNon7iTIH+vLCY9Ry1Wtp64UwVPSI2DsY+fpNdY8CtY6e9vO adig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CmqQBLZ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id n21-20020a638f15000000b00578dfa34d95si1929816pgd.574.2023.10.05.10.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:56:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CmqQBLZ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BD5D58026AC4; Thu, 5 Oct 2023 10:56:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbjJER4J (ORCPT + 99 others); Thu, 5 Oct 2023 13:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjJERzk (ORCPT ); Thu, 5 Oct 2023 13:55:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FA53EE; Thu, 5 Oct 2023 10:55:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82002C433C7; Thu, 5 Oct 2023 17:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696528538; bh=syrxBjcZsi/Kog//nnV2tNttcVlAwK5eng/5m4lhvGY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CmqQBLZ1xFpKi+cuDEg6u4hCv7CRv257LFpQZs9CWOAr5UGFLNwni2tKsA9Qm9oiD VSaetGacFCk323jeULlESt+CsK0pMCQOwPbAbmFz3ZzbYFZrx2HCRVulSJ6/iTt/Kv Jq4nLoxThnUyL5Keov8m02Q97IJc5cuyyhLEv/oM= Date: Thu, 5 Oct 2023 19:55:34 +0200 From: Greg Kroah-Hartman To: Alexey Dobriyan Cc: Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: stack leak via uart_get_info() ? Message-ID: <2023100517-washer-why-7513@gregkh> References: <967b9ef1-fb36-48bf-9e6a-1b99af24c052@p183> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <967b9ef1-fb36-48bf-9e6a-1b99af24c052@p183> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 05 Oct 2023 10:56:22 -0700 (PDT) On Thu, Oct 05, 2023 at 07:34:21PM +0300, Alexey Dobriyan wrote: > If this check ever triggers > > static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) > { > > uport = uart_port_check(state); > if (!uport) > goto out; > > then all those sysfs users will print stack contents to userspace. > > Can it trigger while sysfs read is executing? I don't think it can ever fail, we don't even check the result in other places, so it should all be fine. > Signed-off-by: Alexey Dobriyan > --- > > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -775,6 +775,8 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) > struct uart_port *uport; > int ret = -ENODEV; > > + *retinfo = (struct serial_struct){}; This is good (although I hate the implied memcpy), a real memset would be best to ensure that any holes are also filled. Want to do that, or want me to? thanks, greg k-h