From patchwork Sat May 17 16:36:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 4196711 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E50349F32B for ; Sat, 17 May 2014 16:36:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FE8320395 for ; Sat, 17 May 2014 16:36:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE771202A1 for ; Sat, 17 May 2014 16:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964884AbaEQQgP (ORCPT ); Sat, 17 May 2014 12:36:15 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:54977 "EHLO mail-ob0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964781AbaEQQgO (ORCPT ); Sat, 17 May 2014 12:36:14 -0400 Received: by mail-ob0-f173.google.com with SMTP id wm4so4368633obc.18 for ; Sat, 17 May 2014 09:36:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=cYwXfE52k0+7i9B7FB/STKA0Vn7T2yY0WVDu9ZW3U6Q=; b=FgwpXA/g9ZTA4LCJPoqzmnKjKVEgxt10LyLE1DoL1o1GrwDaa62fbFCWJyWCB34Q8P gyaiwWoKbZinJsiRdF0BG1eVqsRIrLN69auir2A+SchO2MRvh5IXuZqHJMLp3oe1euRP xqnlNqMavwDHPH0KvzW7MXA6IN6R8XG8yy6YPb2CrgXYRnPauSTLCIaqnBdPMHqv2+Yp YdwapwwMqfN6CLe1vXp8Nln6kgzVRjq/7YVG801gQG9cLMeJk4Vs0zDlB/VurHwvja8N MkoVle2/aYkgVh+D39Mx6BiAu1YgTr5ZS+7EGleRf7e1E8I0yMYj9oQfa3Zrss2aseCj j3pw== X-Gm-Message-State: ALoCoQna4nUU6mVuWuwDg3MIQjrX2ngRW3D8P+b4TqIQD4O7GEZWaNGDREnrBJ3lmxHfmzNFBnTP MIME-Version: 1.0 X-Received: by 10.60.39.103 with SMTP id o7mr24460696oek.17.1400344573800; Sat, 17 May 2014 09:36:13 -0700 (PDT) Received: by 10.182.96.2 with HTTP; Sat, 17 May 2014 09:36:13 -0700 (PDT) In-Reply-To: <5376025B.6010202@cogentembedded.com> References: <1400190998-28153-1-git-send-email-rickard_strandqvist@spectrumdigital.se> <5376025B.6010202@cogentembedded.com> Date: Sat, 17 May 2014 18:36:13 +0200 Message-ID: Subject: Re: [PATCH] Fix for possible null pointer dereference in auth.c From: Rickard Strandqvist To: Sergei Shtylyov Cc: "J. Bruce Fields" , Trond Myklebust , "David S. Miller" , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi I have made a new patch according Sergei specification. But there remains Tronds question though. Best regards Rickard Strandqvist 2014-05-16 14:19 GMT+02:00 Sergei Shtylyov : > Hello. > > > On 16-05-2014 1:56, Rickard Strandqvist wrote: > >> There is otherwise a risk of a possible null pointer dereference. > > >> Was largely found by using a static code analysis program called cppcheck. > > >> Signed-off-by: Rickard Strandqvist >> >> --- >> net/sunrpc/auth.c | 10 +++++++--- >> 1 fil ändrad, 7 tillägg(+), 3 borttagningar(-) > > >> diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c >> index 5285ead..3a55698 100644 >> --- a/net/sunrpc/auth.c >> +++ b/net/sunrpc/auth.c >> @@ -801,10 +801,14 @@ rpcauth_invalcred(struct rpc_task *task) >> { >> struct rpc_cred *cred = task->tk_rqstp->rq_cred; >> >> - dprintk("RPC: %5u invalidating %s cred %p\n", >> - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); >> - if (cred) >> + if (cred) { >> + dprintk("RPC: %5u invalidating %s cred %p\n", >> + task->tk_pid, cred->cr_auth->au_ops->au_name, >> cred); >> + >> clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); >> + } >> + else > > > } and *else* should be on the same line, and there should be {} in the > *else* arm since there's {} in the *if* arm already, according to > Documentation/CodingStyle. > > >> + dprintk("RPC: %5u invalidating is NULL\n", task->tk_pid); > > > That's not a proper English, I'm afraid. > >> } > > > WBR, Sergei > > From 210994905f7f7b13f6c621f110699f28fd134980 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sun, 11 May 2014 18:51:42 +0200 Subject: [PATCH] net: sunrpc: auth.c: Fix for possible null pointer dereference There is otherwise a risk of a possible null pointer dereference. Was largely found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist --- net/sunrpc/auth.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 5285ead..a9e1866 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -801,10 +801,14 @@ rpcauth_invalcred(struct rpc_task *task) { struct rpc_cred *cred = task->tk_rqstp->rq_cred; - dprintk("RPC: %5u invalidating %s cred %p\n", - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); - if (cred) + if (cred) { + dprintk("RPC: %5u invalidating %s cred %p\n", + task->tk_pid, cred->cr_auth->au_ops->au_name, cred); + clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); + } else { + dprintk("RPC: %5u cred pointer is 0", task->tk_pid); + } } int -- 1.7.10.4