~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Analysis/AliasDebugger.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- AliasDebugger.cpp - Simple Alias Analysis Use Checker --------------===//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This simple pass checks alias analysis users to ensure that if they
 
11
// create a new value, they do not query AA without informing it of the value.
 
12
// It acts as a shim over any other AA pass you want.
 
13
//
 
14
// Yes keeping track of every value in the program is expensive, but this is 
 
15
// a debugging pass.
 
16
//
 
17
//===----------------------------------------------------------------------===//
 
18
 
 
19
#include "llvm/Analysis/Passes.h"
 
20
#include "llvm/Module.h"
 
21
#include "llvm/Pass.h"
 
22
#include "llvm/Instructions.h"
 
23
#include "llvm/Constants.h"
 
24
#include "llvm/DerivedTypes.h"
 
25
#include "llvm/Analysis/AliasAnalysis.h"
 
26
#include <set>
 
27
using namespace llvm;
 
28
 
 
29
namespace {
 
30
  
 
31
  class AliasDebugger : public ModulePass, public AliasAnalysis {
 
32
 
 
33
    //What we do is simple.  Keep track of every value the AA could
 
34
    //know about, and verify that queries are one of those.
 
35
    //A query to a value that didn't exist when the AA was created
 
36
    //means someone forgot to update the AA when creating new values
 
37
 
 
38
    std::set<const Value*> Vals;
 
39
    
 
40
  public:
 
41
    static char ID; // Class identification, replacement for typeinfo
 
42
    AliasDebugger() : ModulePass(ID) {}
 
43
 
 
44
    bool runOnModule(Module &M) {
 
45
      InitializeAliasAnalysis(this);                 // set up super class
 
46
 
 
47
      for(Module::global_iterator I = M.global_begin(),
 
48
            E = M.global_end(); I != E; ++I) {
 
49
        Vals.insert(&*I);
 
50
        for (User::const_op_iterator OI = I->op_begin(),
 
51
             OE = I->op_end(); OI != OE; ++OI)
 
52
          Vals.insert(*OI);
 
53
      }
 
54
 
 
55
      for(Module::iterator I = M.begin(),
 
56
            E = M.end(); I != E; ++I){
 
57
        Vals.insert(&*I);
 
58
        if(!I->isDeclaration()) {
 
59
          for (Function::arg_iterator AI = I->arg_begin(), AE = I->arg_end();
 
60
               AI != AE; ++AI) 
 
61
            Vals.insert(&*AI);     
 
62
          for (Function::const_iterator FI = I->begin(), FE = I->end();
 
63
               FI != FE; ++FI) 
 
64
            for (BasicBlock::const_iterator BI = FI->begin(), BE = FI->end();
 
65
                 BI != BE; ++BI) {
 
66
              Vals.insert(&*BI);
 
67
              for (User::const_op_iterator OI = BI->op_begin(),
 
68
                   OE = BI->op_end(); OI != OE; ++OI)
 
69
                Vals.insert(*OI);
 
70
            }
 
71
        }
 
72
        
 
73
      }
 
74
      return false;
 
75
    }
 
76
 
 
77
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
 
78
      AliasAnalysis::getAnalysisUsage(AU);
 
79
      AU.setPreservesAll();                         // Does not transform code
 
80
    }
 
81
 
 
82
    /// getAdjustedAnalysisPointer - This method is used when a pass implements
 
83
    /// an analysis interface through multiple inheritance.  If needed, it
 
84
    /// should override this to adjust the this pointer as needed for the
 
85
    /// specified pass info.
 
86
    virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
 
87
      if (PI == &AliasAnalysis::ID)
 
88
        return (AliasAnalysis*)this;
 
89
      return this;
 
90
    }
 
91
    
 
92
    //------------------------------------------------
 
93
    // Implement the AliasAnalysis API
 
94
    //
 
95
    AliasResult alias(const Value *V1, unsigned V1Size,
 
96
                      const Value *V2, unsigned V2Size) {
 
97
      assert(Vals.find(V1) != Vals.end() && "Never seen value in AA before");
 
98
      assert(Vals.find(V2) != Vals.end() && "Never seen value in AA before");    
 
99
      return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
 
100
    }
 
101
 
 
102
    ModRefResult getModRefInfo(ImmutableCallSite CS,
 
103
                               const Value *P, unsigned Size) {
 
104
      assert(Vals.find(P) != Vals.end() && "Never seen value in AA before");
 
105
      return AliasAnalysis::getModRefInfo(CS, P, Size);
 
106
    }
 
107
 
 
108
    ModRefResult getModRefInfo(ImmutableCallSite CS1,
 
109
                               ImmutableCallSite CS2) {
 
110
      return AliasAnalysis::getModRefInfo(CS1,CS2);
 
111
    }
 
112
    
 
113
    bool pointsToConstantMemory(const Value *P) {
 
114
      assert(Vals.find(P) != Vals.end() && "Never seen value in AA before");
 
115
      return AliasAnalysis::pointsToConstantMemory(P);
 
116
    }
 
117
 
 
118
    virtual void deleteValue(Value *V) {
 
119
      assert(Vals.find(V) != Vals.end() && "Never seen value in AA before");
 
120
      AliasAnalysis::deleteValue(V);
 
121
    }
 
122
    virtual void copyValue(Value *From, Value *To) {
 
123
      Vals.insert(To);
 
124
      AliasAnalysis::copyValue(From, To);
 
125
    }
 
126
 
 
127
  };
 
128
}
 
129
 
 
130
char AliasDebugger::ID = 0;
 
131
INITIALIZE_AG_PASS(AliasDebugger, AliasAnalysis, "debug-aa",
 
132
                   "AA use debugger", false, true, false);
 
133
 
 
134
Pass *llvm::createAliasDebugger() { return new AliasDebugger(); }
 
135