Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp1448121rwb; Sat, 3 Sep 2022 16:30:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR728msbzJRINYNW82IqtWg7NAHeDWp2I+IOo7O/ZGkln0V/abaqphL3ZFQbIZNCsocWLKQQ X-Received: by 2002:a17:907:6095:b0:731:87a0:b9e8 with SMTP id ht21-20020a170907609500b0073187a0b9e8mr32102959ejc.124.1662247808325; Sat, 03 Sep 2022 16:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662247808; cv=none; d=google.com; s=arc-20160816; b=uMboLQwv7LEiftuQF1+C1XIaZBDcBirDT2o/fZGop5iEOaIXPVdzCqjVH7yMYE1HuH HHD8NavBxch1O/NCT1TqNU6KEn6h4/FO4O9l2S1+SeCArBqFZh8YtAHZbKZIg6Z5dckV Hd8HJoOKRHMadgsy4KPrF7ao2z9bjwvd/+FMjVl2YBJ+c53OBPVvNIxXGaVGG2VUzLZe KJarSmus/AEq0PVApG85rZGH1aLiwqQ3/L0G2RSlT0pLqE+i0a9uplFUer1KZ8cFB/Vi XQjPlA32T52Xcb3me7cUQoNhyL77RocXijQtefO2A1hAuVrOqNqcQ4PuW3Y7hwPhcxeM A6og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/UIVvNPGGuVuyXHfCkfmj/E2Gp1v4KdZ0mdzCPC+OYw=; b=r0GYa9ZDQFPu68fcetaXtgrb7VxARUDM1YUER9BnK6Jbg9M8P/Mwi/dZwf1Nr2onXI Gp5YoJA273qwDROO+WjWEhqgGzy3x7jM0EGgozCWrKOoLd5Sz/fh7hu0A6GXefGXS01R EtTae2jkNcp5pivYgdWytof8PLJxU4yAoV1PrIcs+m0x4xkbH+9sYicm+q37P4YyJ1Ke 3WTBDMxoqLKw1wfnYcR5X6QynPAsCif+dlPcpGZwB+wIQave+U+1deu15K1SdbLYMeoy VPKzDVaiBFaxMYLhdbf+j8SeXI9lrbcGLBi8STYHvA8LdDRYKXkz2ZNyVIY/HDg29yQW 38Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dAOkDv23; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh11-20020a1709076e8b00b00741827c6304si4520610ejc.772.2022.09.03.16.29.43; Sat, 03 Sep 2022 16:30:08 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dAOkDv23; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbiICXPO (ORCPT + 99 others); Sat, 3 Sep 2022 19:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbiICXPM (ORCPT ); Sat, 3 Sep 2022 19:15:12 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8A91F639; Sat, 3 Sep 2022 16:15:10 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id y136so399210pfb.3; Sat, 03 Sep 2022 16:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=/UIVvNPGGuVuyXHfCkfmj/E2Gp1v4KdZ0mdzCPC+OYw=; b=dAOkDv239fvFc7/ElwPWxTQH97P40kR/orJoA9Xlw9ccnznIfgqb7O7ekI18YfqFzL CrbNXeJuh1WRELXO5l5EEyfLyPNCmvr5BcoUy/8utEYpzcqWRskhJK/8S1V+vcI6fP5F G6dCyUGPo1QT5tC/KxnkhuQaO5MB6iYety1tAk0VMZEvWNxaH8mVOSDeWdF2E8lRdLQ0 sbzXagjXQM76ElnUNNA+bdtahiI0yYy9RbVitZe3tNynkJQgszj/zjNXVfexLscw/m7q OUIg4Nl+Xgu/Uk36j/7Z4ZjsNGh4NNRTGrTjibMMqq4inQeMx7P28opw1ii3f2cO/yi+ 25Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=/UIVvNPGGuVuyXHfCkfmj/E2Gp1v4KdZ0mdzCPC+OYw=; b=QN896bwRbdDJIk3Kec0qTDO8Y4EXzNUTMQlD7R4f6d6HyjqyMsXwdeurD/bWBqWa9E zhVBJVIl8b6egETATO1boHZy7o2O4DG87HODo95HEPnEz7/rSFlJShFi6kXM4DumZdZg aUoNQv5wmL7pHBTds6GmsztIwe0wLPb+xdRutXqB9njovEEvsznPboPmbvPNIxJvZ4OJ u5TbjfiWqQzLkcFnF+nqzM6qO622qsEE2RFhEIZ6opZmPnEcYFMec1Yab4FRSHidJUca yOAlMKhwzhxhTv9OOlK1+04jKLmcHDAWC6cjncFLKBphcxLF6ie/hOPafl322rGiZBFc CelA== X-Gm-Message-State: ACgBeo1bH0Ksn2STTnomt/jqAX94rEYqJK1l1f/KTP7S7UuIf7EXvp6E i+RVRT+8HEJoPxrRPhPI4VMawnVSwXfWkv1ImGesAJaZxg2tFg== X-Received: by 2002:a63:62c3:0:b0:434:2b09:6f62 with SMTP id w186-20020a6362c3000000b004342b096f62mr2166716pgb.374.1662246910212; Sat, 03 Sep 2022 16:15:10 -0700 (PDT) MIME-Version: 1.0 References: <20220826083612.1699194-1-floridsleeves@gmail.com> <2033d06d-10a4-5a57-d650-7541c39990ee@linux.intel.com> <40e16474-99d2-2359-a545-4a437f555ec1@linux.intel.com> In-Reply-To: <40e16474-99d2-2359-a545-4a437f555ec1@linux.intel.com> From: Li Zhong Date: Sat, 3 Sep 2022 16:14:59 -0700 Message-ID: Subject: Re: [PATCH v2] drivers/tty/serial: check the return value of uart_port_check() To: =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= Cc: Andy Shevchenko , "open list:SERIAL DRIVERS" , Linux Kernel Mailing List , Greg Kroah-Hartman , Jiri Slaby Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Tue, Aug 30, 2022 at 12:20 AM Ilpo J=C3=A4rvinen wrote: > > On Mon, 29 Aug 2022, Li Zhong wrote: > > > On Mon, Aug 29, 2022 at 12:09 AM Ilpo J=C3=A4rvinen > > wrote: > > > > > > On Sun, 28 Aug 2022, Li Zhong wrote: > > > > > > > On Fri, Aug 26, 2022 at 9:01 AM Andy Shevchenko > > > > wrote: > > > > > > > > > > On Fri, Aug 26, 2022 at 11:38 AM Li Zhong wrote: > > > > > > > > > > > > uart_port_check() will return NULL pointer when state->uart_por= t is > > > > > > NULL. Check the return value before dereference it to avoid > > > > > > null-pointer-dereference error. > > > > > > > > > > Have you taken the locking into consideration? > > > > > If no, please do, if yes, expand your commit message to explain w= hy > > > > > the current locking scheme doesn't prevent an error from happenin= g. > > > > > > > > > > > > > The locking is taken into consideration but these three checks do n= ot need to > > > > unlock in error-handling because unlock() will be called in the cal= lers. Will > > > > add the comment in v2 patch. > > > > > > I think he meant you should indicate why the current locking doesn't = cover > > > the case you're fixing, not whether this function should call unlock(= ) or > > > not. > > > > > > > Thanks for clarifications. The locking does not guarantee the return va= lue of > > uart_port_check() is not NULL. > > Please put such explanation into the commit message like Andy was asking, > thank you. > Thanks! I'll add this into the v3 patch. > And make sure you properly mention what has changed for any new version > of any patch you send so that Greg don't need to auto-mail you about it > (and end up ignoring your patch). > I'll mention this in the commit message of new patch. > > Actually in line 773 of this file > > (drivers/tty/serial/serial_core.c), uart_port_check() is also called in > > critical section but still there is check on whether the return value i= s NULL. > > Existance of such a check elsewhere alone isn't enough to guarantee that > the check is necessary (and not even that the check in that other place > would be necessary). You need a deeper analysis than that. I'm not > claiming its either way here, just pointing out to the direction/details > you should consider while writing the analysis of the problem. > Thanks for the suggestions. We will try consider more factor into our analy= sis tools to reduce false postives. > > -- > i.